This is the doxygen documentation for gtkboard.
.
#include <glib.h>
Go to the source code of this file.
Data Structures | |
struct | Game |
The Game struct gives essential information about the game. More... | |
struct | GtkboardEvent |
Abstraction of a user event. More... | |
struct | HeurTab |
If you have implemented more than one evaluation function then you put them in an array of structs of type HeurTab. Its unlikely that you'll need to know about this. See game_htab for more details. More... | |
struct | MoveInfo |
The move and all the info. associated with it. More... | |
struct | Pos |
A struct describing a position in a game. More... | |
Defines | |
#define | byte gint8 |
Both moves and positions are arrays of byte s. | |
#define | FILERANK_LABEL_TYPE_MASK 0x3 |
#define | FILERANK_LABEL_DESC (1 << 2) |
if game_file_label or game_rank_label is ORed with this the order of file/rank labels will be reversed. | |
#define | GAME_EVAL_INFTY (1.0e10) |
The return value of game_eval should be larger than GAME_EVAL_INFTY in absolute value to indicate that the game is over. | |
#define | ISINBOARD(x, y) ((x)>=0 && (y)>=0 && (x)<board_wid && (y)< board_heit) |
Indicates whether the square (x, y) is legal. | |
#define | GAME_DEFAULT_URL(x) "http://gtkboard.sourceforge.net/showgame.pl?game="x |
Home page for the game x . | |
Enumerations | |
enum | Player { WHITE, BLACK } |
Used in a two player game to represent whose move it is. More... | |
enum | GtkboardEventType { GTKBOARD_BUTTON_PRESS = 1, GTKBOARD_BUTTON_RELEASE, GTKBOARD_MOTION_NOTIFY, GTKBOARD_LEAVE_NOTIFY, GTKBOARD_KEY_PRESS, GTKBOARD_KEY_RELEASE, GTKBOARD_GAME_START, GTKBOARD_HUMAN_MOVE, GTKBOARD_MACHINE_MOVE, GTKBOARD_HISTORY_MOVE } |
Used for representing the type of user input in game_getmove and game_getmove_kb. More... | |
enum | ResultType { RESULT_WHITE, RESULT_BLACK, RESULT_TIE, RESULT_NOTYET, RESULT_WON, RESULT_LOST, RESULT_MISC } |
Used for representing the result of game_who_won. More... | |
enum | InputType { INPUT_ILLEGAL = -1, INPUT_NOTYET = 0, INPUT_LEGAL = 1 } |
The return type of game_event_handler. More... | |
enum | FILERANK_LABEL_TYPE { FILERANK_LABEL_TYPE_NONE, FILERANK_LABEL_TYPE_NUM, FILERANK_LABEL_TYPE_ALPHA, FILERANK_LABEL_TYPE_ALPHA_CAPS } |
values of game_file_label and game_rank_label. More... | |
enum | RenderType { RENDER_NONE, RENDER_HIGHLIGHT1, RENDER_HIGHLIGHT2, RENDER_HIGHLIGHT3, RENDER_SHADE1, RENDER_SHADE2, RENDER_SHADE3, RENDER_BUTTONIZE, RENDER_HIDE, RENDER_REPLACE } |
How to render a square. More... | |
enum | SCORE_FIELD { SCORE_FIELD_NONE, SCORE_FIELD_RANK, SCORE_FIELD_USER, SCORE_FIELD_SCORE, SCORE_FIELD_TIME, SCORE_FIELD_DATE, SCORE_FIELD_MISC1, SCORE_FIELD_MISC2 } |
The columns that will be shown in the highscores. More... | |
Variables | |
ResultType (* | game_eval )(Pos *pos, Player player, float *eval) |
A pointer to the game's evaluation function. More... | |
ResultType (* | game_eval_incr )(Pos *pos, Player player, byte *move, float *eval) |
A pointer to the game's incremental evaluation function. More... | |
gboolean (* | game_use_incr_eval )(Pos *pos, Player player) |
Should we use the incr eval function. | |
void (* | game_search )(Pos *pos, byte **move) |
A function to search and return the best move - for games for which minimax is not appropriate. | |
byte* (* | game_movegen )(Pos *) |
A pointer to the game's move generation function. More... | |
int (* | game_getmove )(Pos *pos, int x, int y, GtkboardEventType type, Player to_play, byte **movp, int **renderp) |
This takes a mouse click and returns the move that it corresponds to. More... | |
InputType (* | game_event_handler )(Pos *pos, GtkboardEvent *event, MoveInfo *move_info_p) |
The all-in-one function that makes game_getmove and game_getmove_kb deprecated. | |
int (* | game_getmove_kb )(Pos *pos, int key, Player to_play, byte **movp, int **rmovp) |
Takes a keypress and returns the move that it corresponds to. More... | |
ResultType (* | game_who_won )(Pos *pos, Player player, char **scorep) |
Checks if the game is over, and if so, who has won. More... | |
void (* | game_set_init_pos )(Pos *pos) |
Pointer to function which sets the game's initial position. More... | |
void (* | game_set_init_render )(Pos *pos) |
Sets the initial state of the rendering hints. | |
void (* | game_get_render )(Pos *pos, byte *move, int **rmovp) |
The rendering hints associated with the move. | |
char** (* | game_get_pixmap )(int piece, int color) |
Returns the pixmap for a piece. More... | |
guchar* (* | game_get_rgbmap )(int piece, int color) |
Same as game_get_pixmap but returns a rgbmap instead of pixmap. | |
int (* | game_animate )(Pos *pos, byte **movp) |
Pointer to animation callback which will be called periodically. | |
void* (* | game_newstate )(Pos *pos, byte *move) |
Pointer to function which will compute the new state from the current position and the move. More... | |
void (* | game_free )() |
Called at the end of every game. | |
void (* | game_reset_uistate )() |
This is called after each move the user completes. More... | |
int | board_wid |
int | board_heit |
int | cell_size |
int | num_pieces |
int | game_single_player |
Are we a single player game or a two-player game? DEFAULT: FALSE. | |
gboolean | game_allow_undo |
Is the user allowed to undo move and still get on the highscores (only for single player games; default: FALSE). | |
int | game_animation_time |
Determines how frequently to call the game's animation callback function (game_animate). Default: 0. | |
gboolean | game_animation_use_movstack |
Whether or not to consider animations "moves". Default: TRUE. | |
gboolean | game_stateful |
Are we a stateful game. Default: FALSE. | |
gboolean | game_draw_cell_boundaries |
Should the lines between the rows and columns be drawn. Default: FALSE. More... | |
char* | game_highlight_colors |
Colors to use for highlighting squares. | |
gboolean | game_allow_back_forw |
Should we allow the user to move back and forward in the game. Default: TRUE. More... | |
gboolean | game_start_immediately |
Should the user's clock start ticking as soon as the game is selected. Default: FALSE. More... | |
gboolean | game_allow_flip |
(Only for two player games) Is Settings->Flip Board active. For single player games it is always inactive. | |
gboolean | game_file_label |
How to display names of rows and columns. This should be of type FILERANK_LABEL_TYPE, optionally ORed with FILERANK_LABEL_DESC. | |
gboolean | game_rank_label |
How to display names of rows and columns. This should be of type FILERANK_LABEL_TYPE, optionally ORed with FILERANK_LABEL_DESC. | |
int | game_state_size |
Size of the Pos::state structure. More... | |
HeurTab* | game_htab |
Array of structs representing evaluation functions. | |
gchar* | game_doc_about |
The text to be shown in the About dialog for the game (Help->GameName->About). | |
gchar* | game_doc_rules |
The text to be shown in the Rules dialog for the game (Help->GameName->Rules). | |
gchar* | game_doc_strategy |
The text to be shown in the Strategy dialog for the game (Help->GameName->Strategy). | |
gchar* | game_white_string |
User visible labels for white and black. | |
gchar * | game_black_string |
User visible labels for white and black. | |
char** | game_bg_pixmap |
Background image for the board. | |
SCORE_FIELD* | game_score_fields |
Used to override the default highscore columns. More... | |
gchar** | game_score_field_names |
The names of the column titles in the highscores. More... | |
int (* | game_scorecmp )(gchar *, int, gchar *, int) |
Pointer to the comparison function used to order highscores. More... | |
int (* | game_scorecmp_def_dscore )(gchar *, int, gchar *, int) |
Default highscore comparison function: decreasing order of Score field. | |
int (* | game_scorecmp_def_iscore )(gchar *, int, gchar *, int) |
Default highscore comparison function: increasing order of Score field. | |
int (* | game_scorecmp_def_time )(gchar *, int, gchar *, int) |
Default highscore comparison function: increasing order of Time field. |
This is the only file that the games need to include.
Definition in file game.h.
|
if game_file_label or game_rank_label is ORed with this the order of file/rank labels will be reversed.
|
|
|
|
Home page for the game
Definition at line 147 of file game.h. Referenced by antichess_init(), ataxx_init(), blet_init(), breakthrough_init(), checkers_init(), chess_init(), cpento_init(), dnb_init(), eightqueens_init(), fifteen_init(), flw_init(), hiq_init(), hypermaze_init(), infiltrate_init(), knights_init(), kttour_init(), mastermind_init(), maze_init(), memory_init(), ninemm_init(), othello_init(), pacman_init(), pentaline_init(), plot4_init(), quarto_init(), rgb_init(), samegame_init(), stopgate_init(), tetris_init(), towers_init(), and wordtris_init(). |
|
The return value of game_eval should be larger than GAME_EVAL_INFTY in absolute value to indicate that the game is over.
|
|
Indicates whether the square (x, y) is legal.
Definition at line 144 of file game.h. Referenced by add_hints(), antichess_movegen(), antichess_movegen_line(), antichess_movegen_square(), blet_event_handler(), breakthrough_movegen(), checkers_movegen(), chess_movegen(), chess_movegen_line(), chess_movegen_square(), eval_disconnected(), eval_max_path_len(), get_chain_info(), get_degree(), get_min_degree(), infiltrate_movegen(), knights_eval_real(), knights_movegen(), othello_eval_liberty(), pentaline_newstate(), recursive_pathgen(), and stopgate_movegen(). |
|
Both moves and positions are arrays of
|
|
values of game_file_label and game_rank_label.
|
|
Used for representing the type of user input in game_getmove and game_getmove_kb. This layer of abstraction exists so that to write a game it will not be necessary to have the g[dt]k headers |
|
The return type of game_event_handler.
|
|
Used in a two player game to represent whose move it is.
|
|
How to render a square.
|
|
Used for representing the result of game_who_won.
|
|
The columns that will be shown in the highscores. SCORE_FIELD_NONE acts as a NULL terminator for the game_score_fields array. Note that highscores make sense only for single player games. |
|
|
|
|
|
|
|
Should we allow the user to move back and forward in the game. Default: TRUE. You should not set this to FALSE unless you have a compelling reason to do so. Don't worry about the user cheating and getting a highscore that they don't deserve -- if the user ever clicks back, highscores will be disabled for that game :-) Currently only tetris (tetris.c) sets this to FALSE, because of some complex client-server related issues. |
|
(Only for two player games) Is Settings->Flip Board active. For single player games it is always inactive.
|
|
Is the user allowed to undo move and still get on the highscores (only for single player games; default: FALSE).
|
|
Pointer to animation callback which will be called periodically.
|
|
Determines how frequently to call the game's animation callback function (game_animate). Default: 0.
|
|
Whether or not to consider animations "moves". Default: TRUE.
|
|
Background image for the board.
|
|
User visible labels for white and black.
|
|
The text to be shown in the About dialog for the game (Help->GameName->About).
|
|
The text to be shown in the Rules dialog for the game (Help->GameName->Rules).
|
|
The text to be shown in the Strategy dialog for the game (Help->GameName->Strategy).
|
|
Should the lines between the rows and columns be drawn. Default: FALSE. Example of game which draws boundaries: pentaline (pentaline.c) Example of game which doesn't draw boundaries: memory (memory.c) |
|
A pointer to the game's evaluation function. Only for two player games. It must be implemented if you want the computer to be able to play the game. |
|
A pointer to the game's incremental evaluation function. Only for two player games. This is an advanced feature: if you feel that being forced to look at the whole board for each call to game_eval is inefficient, you can write an incremental evaluation function which takes a position and the move being made and returns the difference in the eval of the original and final positions. Note that you still need to implement game_eval even if you implement this function. Since premature optimization is the root of all evil, it is highly recommended that you get your game working and stable before you think of implementing this function :) |
|
The all-in-one function that makes game_getmove and game_getmove_kb deprecated.
|
|
How to display names of rows and columns. This should be of type FILERANK_LABEL_TYPE, optionally ORed with FILERANK_LABEL_DESC.
|
|
Called at the end of every game.
|
|
Returns the pixmap for a piece. In many games, the pixmaps are generated at runtime (see aaball.c). Such games use this function. The second argument color is 0 or 1 depending on whether the piece will be shown on a light square or a dark square. If your pixmap is antialiased you need this. |
|
The rendering hints associated with the move.
|
|
Same as game_get_pixmap but returns a rgbmap instead of pixmap.
|
|
This takes a mouse click and returns the move that it corresponds to.
|
|
Takes a keypress and returns the move that it corresponds to.
|
|
Colors to use for highlighting squares.
|
|
Array of structs representing evaluation functions.
|
|
A pointer to the game's move generation function. Only for two player games. It must be implemented if you want the computer to be able to play the game. It returns a list of moves possible in a given position. See move.h for documentation of the MOVLIST format. Plot4's movegen function (plot4_movegen()) is a good example of a simple movegen function. The move list (array) should be malloc'd inside this function and will be freed by the caller. |
|
Pointer to function which will compute the new state from the current position and the move. The returned state should be a pointer to a statically declared structure. |
|
How to display names of rows and columns. This should be of type FILERANK_LABEL_TYPE, optionally ORed with FILERANK_LABEL_DESC.
|
|
This is called after each move the user completes. The user may have made some clicks which do not complete a move and then clicked the back button, for example. Then the game must forget the saved clicks. |
|
The names of the column titles in the highscores. If you set game_score_fields you also have to set game_score_field_names which gives the titles to use for the respective columns. |
|
Used to override the default highscore columns. By default, the columns shown in the highscores are User, Score, Time and Date. This sequence can be overridden by specifying a game_score_fields array terminated by SCORE_FIELD_NONE. SCORE_FIELD_MISC1 and SCORE_FIELD_MISC2 are used to specify some field which is none of the 5 available by default. The MISC functionality is currently unimplemented |
|
Pointer to the comparison function used to order highscores. Highscores work by applying the comparison function on the score string returned by game_who_won. Three defaults are availble (see below), one of which will likely fit what you want. If not you can write your own function and set this pointer to it. |
|
Default highscore comparison function: decreasing order of Score field.
|
|
Default highscore comparison function: increasing order of Score field.
|
|
Default highscore comparison function: increasing order of Time field.
|
|
A function to search and return the best move - for games for which minimax is not appropriate.
|
|
Pointer to function which sets the game's initial position. In some games such as maze (maze.c), the initial position is not constant but randomly generated. Such functions use game_set_init_pos. The function is expected to set the value of pos->board. |
|
Sets the initial state of the rendering hints.
|
|
Are we a single player game or a two-player game? DEFAULT: FALSE.
|
|
Should the user's clock start ticking as soon as the game is selected. Default: FALSE. Doesn't make a lot of sense for two player games. In games like maze (maze.c), the user can solve the maze without even making a move, so it would be unfair to let them look at the maze without starting the clock. |
|
Size of the Pos::state structure. For stateful games, you need to specify the size of the state structure (as defined by the sizeof operator.) |
|
Are we a stateful game. Default: FALSE.
|
|
Should we use the incr eval function.
|
|
User visible labels for white and black.
|
|
Checks if the game is over, and if so, who has won. This function is called after every move, both for single player and two player games.
|
|
|