![]() ![]() If it yields a losing board it will receive the grade of -1. Let’s decide that if a move yields a winning board we will grade it 1. We need to grade the possible moves so we can compare them.Please concentrate for the next essential steps: Send this board to the getResult functionįrom the 3 boards in the figure above, when we send the second board to the getResult function, we will receive our trophy.Add our symbol to the corresponding empty cell.We can do this by iterating over the possible moves, and for each of them: Lets check the result for each of these options. There are 3 empty cells that correspond with 3 possible moves. Let’s try to identify the best possible move with the tools we already have. Lets decide that the next move is ours, and that our symbol is an “X”. Let’s use this populated board as our starting point. ![]() When the board becomes populated, the best possible move pops out to our eyes. ![]() Which is the best possible possible move? When the board is empty it is very difficult to identify the best possible move. ![]() Then it lets us know the current state of that board. The getResult function receives a board array, iterates over all the rows, through all the columns and across both diagonals.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |