< p>Interface:
Player, then I will be able to implement several player classes according to the way I want opponents, for example, random players, smart players, etc.
Categories:
Board class, With a two-dimensional integer array, 0 means open, 1 means me, and -1 means opponent. The evaluation function will also be here to return the next best move based on the current board layout, and it’s its turn.
Referee class, will create a board instance and two player instances, and then start the game.
This is a rough concept of my OO design. Does anyone criticize me? I find this really helpful. Thank you very much.
1) Ask the “object” to ask questions
2) Command the “object” to do something
< p>That said, it doesn’t make sense for me to ask the “board of directors” about the best next move. The board of directors should just hold value and tell you its status.
I might have one Specifically used to determine the object of the best next action for a given “intelligence”. Let’s call it’move_brain’. Then you can say, “Hey move_brain, given this board and this level of intelligence, the next best move What is it?”
The board course you are now outlined has many responsibilities: maintaining state, allowing users to move, and thinking about how to move next. That’s too important.
After all, I Will say this: Since this program is not very big, almost any solution is fine.
Good luck!
I will use Java (or other OO languages) to develop a Tic-Tac-Toe game. Now I have a picture of general design in my mind.
< /p>
Interface:
Player, then I will be able to implement several player classes according to the way I want opponents, for example, random players, smart players, etc.
Categories:
Board class, with a two-dimensional integer array, 0 means open, 1 means me, -1 means opponent. The evaluation function will also be here to return the next best move based on the current board layout, and it’s its turn.
The referee class will create a board instance and two player instances, and then start the game.
This is a rough concept of my OO design. Does anyone criticize me? I found this to be really helpful. Thank you very much.
When I think about object structure, I think my approach is to do one of two things:
1) Ask the “subject” a question
2) Command the “subject” to do something
That being said, for me, ask The next best move of the “board” is meaningless. The board should just hold value and tell you its status.
I might have a dedicated one to determine the best for a given “intelligence” The object of the next move. We call it’move_brain’. Then you can say, “Hey move_brain, given this board and this level of intelligence, what is the next best move?”
You The board course outlined now has many responsibilities: maintaining state, allowing users to move, and thinking about how to move the next step. That’s too important.
After all, I’ll say this: given that the program is not very big, almost Any solution is fine.
Good luck!