|
|
— |
pl:prolog:pllib:game_framework [2019/06/27 15:50] (aktualna) |
| ====== Game framework ====== |
| {{tag>game framework}} |
| ===== Description ===== |
| Framework for Game Playing. |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{game_framework.pl}} |
| ===== Listing ===== |
| <code prolog> |
| /* |
| play(Game) :- Play game with name Game. |
| */ |
| play(Game) :- |
| initialize(Game,Position,Player), |
| display_game(Position,Player), |
| play(Position,Player,Result). |
| |
| play(Position,Player,Result) :- |
| game_over(Position,Player,Result), !, announce(Result). |
| play(Position,Player,Result) :- |
| choose_move(Position,Player,Move), |
| move(Move,Position,Position1), |
| display_game(Position1,Player), |
| next_player(Player,Player1), |
| !, play(Position1,Player1,Result). |
| |
| % Program 20.8 : Framework for Game Playing. |
| </code> |
| ===== Comments ===== |
| |