![]() Basically you need 4 main functions for your game: You seem to have lots of unnecessary functions and your minimax code looks way too complicated than it needs to be. Then afterwards just simply return any move since that means the player will lose. Then if that doesn't happen, look for moves that result in 0(a tie). What I have done for the algorithm is depending on the player, first look for moves that will result in either 1 or -1 depending on the player. #all the moves will result in a loss, so i just return the first moveīasically X aims to maximise and O aims to minimise. #change the aim to be a draw since winning is no longer possible #if nodes down the chain return a value cos they have reached the aim, return this current move #if move leads to the aimed score, return move Returns the optimal action for the current player on the board. Returns 1 if X has won the game, -1 if O has won, 0 otherwise. Returns True if game is over, False otherwise. Returns the winner of the game, if there is one. Raise BoardError("Tried to place on full square") Returns the board that results from making move (i, j) on the board. Returns set of all possible actions (i, j) available on the board. Returns player who has the next turn on a board. ![]() Would really appreciate any help, thank you all! I am also pretty sure that all my other functions are correct and that only the minimax function is incorrect. My algorithm doesn't work at all (it is really easy to beat the computer) and I was wondering what I was doing wrong. ![]() I am currently doing this problem in cs50 AI where we need to make a minimax algorithm for playing tictactoe. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |