@@ -156,7 +156,7 @@ def movable_tigers(self):
156156
157157 return  sum (int (self ._movable (t )) for  t  in  self .board .tigerPos )
158158
159-  def  generate_move_list (self ):
159+  def  generate_move_list (self ,  rdm = True ):
160160 """ 
161161 Generate a list of all moves for the board and turn 
162162 """ 
@@ -172,12 +172,26 @@ def generate_move_list(self):
172172 else :
173173 move_list .extend (self ._movements ())
174174
175+  # randomly shuffling the move list 
176+  # so the ai doesn't make the same move every time 
177+ 178+  if  rdm :
179+  random .shuffle (move_list )
175180 # turn = Tiger 
176181 else :
177182 # captures 
178-  move_list .extend (self ._captures ())
179-  # moves 
180-  move_list .extend (self ._movements ())
183+  # captures are kept before movements 
184+  # to improve the efficiency of ab pruning 
185+  moves  =  self ._captures ()
186+  if  rdm :
187+  random .shuffle (moves )
188+  move_list .extend (moves )
189+ 190+  # movements 
191+  moves  =  self ._movements ()
192+  if  rdm :
193+  random .shuffle (moves )
194+  move_list .extend (moves )
181195
182196 return  move_list 
183197
0 commit comments