Skip to content

Commit dc47ee3

Browse files
committed
Fix simple min-max algorithm
generation of possible moves used wrong argument compare with implementation of alpha-beta-pruning was already part of PR rishal-hurbans#9 but not taken over
1 parent 89002a4 commit dc47ee3

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

ch03-intelligent_search/adversarial_search/connect_ai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def minmax(connect, depth, min_or_max, move):
3838
best_score = INFINITY_NEGATIVE * min_or_max
3939
best_max_move = -1
4040
# Get possible moves given the board size
41-
moves = random.sample(range(0, connect.board_size_y + 1), connect.board_size_x)
41+
moves = random.sample(range(0, connect.board_size_x), connect.board_size_x)
4242
# Try each move
4343
for slot in moves:
4444
neighbor = copy.deepcopy(connect)

ch03-intelligent_search/adversarial_search/connect_puzzle_game.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
while connect.has_winner() == 0:
88
connect.print_turn()
99
connect.play_move(caiab.choose_move(connect, SEARCH_DEPTH))
10+
#connect.play_move(cai.choose_move(connect, SEARCH_DEPTH))
1011
connect.print_board()
1112
print(connect.has_winner())
1213

ch03-intelligent_search/adversarial_search/connect_puzzle_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import connect_ai_alpha_beta_pruning as caab
2+
import connect_ai as cai
23
import connect_puzzle as cp
34

45
# Initialize a Connect game with default board size
@@ -47,6 +48,7 @@
4748
print(connect.get_score_for_ai())
4849

4950
chosen_move = caab.choose_move(connect, 100)
51+
#chosen_move = cai.choose_move(connect, 100)
5052
print('MOVE: ', chosen_move)
5153
connect.play_move(chosen_move)
5254
print(connect.get_score_for_ai())

0 commit comments

Comments
 (0)