Skip to content

Commit

Permalink
corection faute de frappe + variable depth
Browse files Browse the repository at this point in the history
  • Loading branch information
gubace committed Apr 16, 2024
1 parent 698f230 commit 5e9c9d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
current_player = 1
size = 5
size_px = size
depth = 4

# Player vs IA variables
player = 0
Expand Down Expand Up @@ -119,7 +120,7 @@ def hexiaia_place_piece():
try:
if game_board is not None:

move_IA = game_board.get_best_move(2,current_IA)
move_IA = game_board.get_best_move(depth,current_IA)
game_board.place_piece(current_IA, move_IA) # Try to place the piece
iamove = "hex" + str(move_IA[0]) + "-" + str(move_IA[1])

Expand Down Expand Up @@ -152,7 +153,7 @@ def players_hexia():
@app.route('/first_move_IA',methods=['POST']) #Return IA's first move if player=2
def first_move_IA():
global game_board, IA
move = game_board.get_best_move(4,IA)
move = game_board.get_best_move(depth,IA)
game_board.place_piece(IA, move)
iamove = "hex" + str(move[0]) + "-" + str(move[1])
return jsonify({'result': 'Success','iamove':iamove})
Expand Down Expand Up @@ -198,7 +199,7 @@ def undo_move():
@app.route('/game_awale', methods=['POST']) # Hex play page
def game_awale():
global game_board, current_player
game_board = AweleBoard() # Create a new game board
game_board = AwaleBoard() # Create a new game board
game_board.display_board() # Display the game board in the console
current_player = 1 # Set player 1 as the starting player
return render_template('game_awale.html',current_player=current_player)
Expand Down
4 changes: 2 additions & 2 deletions src/main/game_logic/hexgame/board/hexboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def dfs(r, c):

return components

def idee(self, player):
def eval(self, player):
center = (self.size//2,self.size//2)
cv = self.get_neighbors(center,self.size,self.size)
cv.append(center)
Expand Down Expand Up @@ -601,7 +601,7 @@ def idee(self, player):

def minimax(self, depth, player, alpha, beta):
if depth == 0 or self.check_winner() is not None:
return self.idee(player)*((depth+1)*(depth+1)), None
return self.eval(player)*((depth+1)*(depth+1)), None

if player == 1: # Maximizing player
best_score = float('-inf')
Expand Down

0 comments on commit 5e9c9d8

Please sign in to comment.