Console Tic-Tac-Toe App (continued)

Tram Ho

So in order for the Computer to balance the results of the game, we need to add logic to block User ‘s double-opportunity move. In this case, the new procedure will have a lower priority than Get_Prioritized; . So in the code used at Get (Computer_Move, App_State); , we will put the additional new procedure in between Get_Prioritized; and Block_Direct_Winning; .

And to define for Computer about User ‘s double chance move, we will still perform an iterative operation to generate predictive states of User_Set and Common_Set , and then continue based on this predictive state. calculate the number of winning moves on the next turn.

If the number of winning moves in the last turn is more than 1 , it means that the previous predicted move is a move that creates a Double_Threat , and we need to assign the value of this predicted move to Computer_Move to block it. .

Finally, we need to make sure the procedure are fully declared in the configuration file of the package AI_Mockup .

To see if the Computer was able to balance the outcome of the game in the previous situation.

Oh… So here, when User: X pre-selects the lower left corner and the upper right corner, the remaining corners are still empty and are all possible moves to create Double_Threat . If so, even if the Computer blocks any moves, it will not be able to balance the outcome of the game. Perhaps we still need to add one more processing logic with higher priority than Block_Double_Threat; .

Share the news now

Source : Viblo