Answer the question
In order to leave comments, you need to log in
What to read for tic-tac-toe?
I'm going to write tic-tac-toe (player vs pc) in PascalABC.NET, because the teacher asked (optional), but the fact is that I don’t know anything. With algorithms tight, I know the basics of Pascal. Weekends are planned, I would like to read the literature on algorithms, which to some extent will help to understand this. I read about minimax in general terms in pseudo-language, but did not understand the principle.
Answer the question
In order to leave comments, you need to log in
Google about minimax and game state scores.
This will work on any board with any rules.
Everything is primitive there.
1. You build all sorts of options for moves, all combinations (both profitable for you and your opponent, that is, everything is absolutely).
2. You look where the moves lead after the opponent's move.
3. You choose the branch that is beneficial to you, not to him.
I borrowed from one AI book (but it will be pseudocode since the book is in C++).
To make the simplest AI, here is a pseudo-code:
If the computer makes a move that will bring him a win, he does it
If the player's next move will bring him a win, deprive him of this code (According to the rules, of course)
Otherwise, take a priority cell. Priority is - first in the middle, then in the corners, and then the rest.
We write all the combinations that bring victory, run randomly, and that's it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question