Games¶
In this module there is explained the structure of a Game or Rule. It also enumerates the different games supported so far by the library.
Interfaces¶
There are 3 main interfaces that represent a game. The IGameRules holds the logic of the game. The IPosition represents a position or state of the game regarding a specific set of rules. The IMovement represents a movement of the game that goes from one position to another.
IRules¶
Represent the rules of a game implementing the following methods:
Method |
Description |
Arguments type |
Return type |
Must be implemented for each game |
|
The number of players |
|
|
Yes. |
|
The initial position. |
|
|
Yes. |
|
The next position giving a position and a move. |
|
|
Yes. |
|
The possible moves giving a position. |
|
|
Yes. |
|
Whether a position is terminal. |
|
|
Yes. |
|
The score of a terminal position. |
|
|
Yes. |
|
Whether a move is possible giving a position. |
|
|
No. |
IMovement¶
Represent a movement of a game. It does not have general methods, as each movement depends on the rules of the specific game.
IPosition¶
Represent a position of a game. This means, a state, a position of a board, a position in a map, etc. Some variables referring to the position may be stored in the rules object that has generated this position.
Method |
Description |
Arguments type |
Return type |
Must be implemented for each game |
|
The next player to play. |
|
|
Yes. |
|
Rules that has generated this position. |
|
|
No. |
ScoreBoard¶
The Score measured in a float variable indicates for each player how good the final game went.
After finishing any game, you get a ScoreBoard that holds the score for each player.
Note
Always remember that the lowest score is the best one.
Games available¶
This is a list of all the games supported and its characteristics:
Game name |
Folder |
Tutorial |
Short description |
Number of players |
Deterministic / Random |
Perfect information / Hidden information |
Details |
Hanoi |
|
The classic Hanoi’s Tower game. |
1 |
Deterministic |
Perfect information |
||
SlicingPuzzle |
|
The classic Slicing Puzzle game. |
1 |
Deterministic |
Perfect information |
||
NQueens |
|
The classic N-Queens game. |
1 |
Deterministic |
Perfect information |
Min score: 0 |
|
FieldWalk |
|
Minimum cost path search. |
1 |
Deterministic |
Perfect information |
||
Coins |
|
Roman’s coin game. |
2 |
Deterministic |
Perfect information |
0 sum game |
|
Nim |
|
Nim game. |
2 |
Deterministic |
Perfect information |
0 sum game |
|
Tic-Tac-Toe |
|
Tic-Tac-Toe game (3 in a row). |
2 |
Deterministic |
Perfect information |
0 sum game |
|
Mastermind |
|
The classic Mastermind game. |
1 |
Deterministic |
Hidden information |
||
Prisoner |
|
Prisoner Dilemma 2 player game. |
2 |
Deterministic |
Hidden information |
||
Highest card |
|
Highest card N player game. |
N |
Random |
Hidden information |