This is the doxygen documentation for gtkboard.
.#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <glib.h>
#include <gmodule.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "config.h"
#include "ui.h"
#include "prefs.h"
#include "move.h"
#include "menu.h"
#include "ui_common.h"
#include "board.h"
Go to the source code of this file.
Defines | |
#define | DEF_TIME_PER_MOVE 2000 |
Default thinking time per move. | |
Functions | |
void | engine_main (int, int) |
This is the main function for the engine. | |
ResultType | engine_eval (Pos *, Player, float *) |
gboolean | impl_check () |
void | ui_check_who_won () |
void | game_set_init_pos_def (Pos *) |
int | ui_get_machine_move () |
void | ui_make_human_move (byte *, int *) |
void | set_game_params () |
game specific initialization. | |
void | ignore () |
void | ui_cleanup () |
void | ui_segv_cleanup () |
void | ui_child_cleanup () |
int | ui_animate_cb () |
void | reset_game_params () |
void | ui_terminate_game () |
void | ui_start_game () |
void | ui_send_make_move () |
int | ui_move_now_cb () |
void | ui_cancel_move () |
void | ui_start_player () |
void | parse_opts (int argc, char **argv) |
void | gui_init () |
int | main (int argc, char **argv) |
Variables | |
Game | Othello |
Game | Samegame |
Game | Rgb |
Game | Fifteen |
Game | Memory |
Game | Tetris |
Game | Chess |
Game | Antichess |
Game | Hiq |
Game | Checkers |
Game | Plot4 |
Game | Maze |
Game | Infiltrate |
Game | Hypermaze |
Game | Ataxx |
Game | Pentaline |
Game | Mastermind |
Game | Pacman |
Game | Flw |
Game | Wordtris |
Game | Ninemm |
Game | Stopgate |
Game | Knights |
Game | Breakthrough |
Game | CapturePento |
Game | Towers |
Game | Quarto |
Game | Kttour |
Game | Eightqueens |
Game | Dnb |
Game | Blet |
Game* | games [] |
const int | num_games = sizeof (games) / sizeof (games[0]) |
gboolean | engine_flag = FALSE |
FILE* | move_fin |
FILE * | move_fout |
GIOChannel* | ui_in = NULL |
Pos | cur_pos = {NULL, NULL, WHITE, NULL, 0, NULL} |
int | board_wid |
int | board_heit |
int | engine_pid = -1 |
gint | animate_tag = -1 |
gboolean | game_allow_undo = FALSE |
Is the user allowed to undo move and still get on the highscores (only for single player games; default: FALSE). | |
gboolean | game_single_player = FALSE |
Are we a single player game or a two-player game? DEFAULT: FALSE. | |
gboolean | game_animation_use_movstack = TRUE |
Whether or not to consider animations "moves". Default: TRUE. | |
gboolean | game_allow_back_forw = TRUE |
Should we allow the user to move back and forward in the game. Default: TRUE. More... | |
int | game_animation_time = 0 |
Determines how frequently to call the game's animation callback function (game_animate). Default: 0. | |
gchar* | game_doc_about = NULL |
The text to be shown in the About dialog for the game (Help->GameName->About). | |
gchar* | game_doc_rules = NULL |
The text to be shown in the Rules dialog for the game (Help->GameName->Rules). | |
gchar* | game_doc_strategy = NULL |
The text to be shown in the Strategy dialog for the game (Help->GameName->Strategy). | |
gchar* | game_white_string = "White" |
User visible labels for white and black. | |
gchar * | game_black_string = "Black" |
User visible labels for white and black. | |
gboolean | ui_gameover = FALSE |
gboolean | ui_stopped = TRUE |
gboolean | ui_cheated = FALSE |
gboolean | game_stateful = FALSE |
Are we a stateful game. Default: FALSE. | |
gboolean | state_gui_active = FALSE |
gboolean | game_draw_cell_boundaries = FALSE |
Should the lines between the rows and columns be drawn. Default: FALSE. More... | |
gboolean | game_start_immediately = FALSE |
Should the user's clock start ticking as soon as the game is selected. Default: FALSE. More... | |
gboolean | game_allow_flip = FALSE |
(Only for two player games) Is Settings->Flip Board active. For single player games it is always inactive. | |
gboolean | game_file_label = 0 |
gboolean | game_rank_label = 0 |
char* | game_highlight_colors = NULL |
Colors to use for highlighting squares. | |
char | game_highlight_colors_def [9] = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0} |
HeurTab* | game_htab = NULL |
Array of structs representing evaluation functions. | |
int | game_state_size = 0 |
Size of the Pos::state structure. More... | |
SCORE_FIELD* | game_score_fields = prefs_score_fields_def |
Used to override the default highscore columns. More... | |
gchar** | game_score_field_names = prefs_score_field_names_def |
The names of the column titles in the highscores. More... | |
char** | game_bg_pixmap = NULL |
Background image for the board. | |
Game* | opt_game = NULL |
FILE* | opt_infile = NULL |
FILE* | opt_logfile = NULL |
int | opt_delay = DEF_TIME_PER_MOVE |
int | opt_quiet = 0 |
int | opt_white = NONE |
int | opt_black = NONE |
int | ui_white = NONE |
int | ui_black = NONE |
int | opt_verbose = 0 |
ResultType (* | game_eval )(Pos *, Player, float *)=NULL |
A pointer to the game's evaluation function. More... | |
ResultType (* | game_eval_incr )(Pos *, Player, byte *, float *)=NULL |
A pointer to the game's incremental evaluation function. More... | |
gboolean (* | game_use_incr_eval )(Pos *, Player)=NULL |
Should we use the incr eval function. | |
float (* | game_eval_white )(Pos *, int)=NULL |
float (* | game_eval_black )(Pos *, int)=NULL |
void (* | game_search )(Pos *, byte **)=NULL |
A function to search and return the best move - for games for which minimax is not appropriate. | |
byte* (* | game_movegen )(Pos *)=NULL |
A pointer to the game's move generation function. More... | |
InputType (* | game_event_handler )(Pos *, GtkboardEvent *, MoveInfo *)=NULL |
The all-in-one function that makes game_getmove and game_getmove_kb deprecated. | |
int (* | game_getmove )(Pos *, int, int, GtkboardEventType, Player, byte **, int **)=NULL |
This takes a mouse click and returns the move that it corresponds to. More... | |
int (* | game_getmove_kb )(Pos *, int, Player, byte **, int **)=NULL |
Takes a keypress and returns the move that it corresponds to. More... | |
ResultType (* | game_who_won )(Pos *, Player, char **)=NULL |
Checks if the game is over, and if so, who has won. More... | |
int (* | game_animate )(Pos *, byte **)=NULL |
Pointer to animation callback which will be called periodically. | |
char** ( * | game_get_pixmap )(int, int)=NULL |
Returns the pixmap for a piece. More... | |
guchar* ( * | game_get_rgbmap )(int, int)=NULL |
Same as game_get_pixmap but returns a rgbmap instead of pixmap. | |
void (* | game_free )()=NULL |
Called at the end of every game. | |
void* (* | game_newstate )(Pos *, byte *)=NULL |
Pointer to function which will compute the new state from the current position and the move. More... | |
void (* | game_set_init_pos )(Pos *)=game_set_init_pos_def |
Pointer to function which sets the game's initial position. More... | |
void (* | game_set_init_render )(Pos *)=NULL |
Sets the initial state of the rendering hints. | |
void (* | game_get_render )(Pos *, byte *, int **)=NULL |
The rendering hints associated with the move. | |
void (* | game_reset_uistate )()=NULL |
This is called after each move the user completes. More... | |
int (* | game_scorecmp )(gchar *, int, gchar *, int)=NULL |
int (* | game_scorecmp_def_dscore )(gchar *, int, gchar *, int)=prefs_scorecmp_dscore |
Default highscore comparison function: decreasing order of Score field. | |
int (* | game_scorecmp_def_iscore )(gchar *, int, gchar *, int)=prefs_scorecmp_iscore |
Default highscore comparison function: increasing order of Score field. | |
int (* | game_scorecmp_def_time )(gchar *, int, gchar *, int)=prefs_scorecmp_time |
Default highscore comparison function: increasing order of Time field. | |
GtkWidget* | main_window |
The main application window. | |
GtkWidget * | board_area = NULL |
GtkWidget* | board_rowbox = NULL |
GtkWidget * | board_colbox = NULL |
|
Default thinking time per move.
|
|
|
|
This is the main function for the engine.
Definition at line 379 of file engine.c. Referenced by ui_start_player(). |
|
|
|
Definition at line 803 of file ui.c. Referenced by main(). |
|
|
|
Definition at line 553 of file ui.c. Referenced by board_signal_handler(), and menu_start_stop_game(). |
|
|
|
Definition at line 570 of file ui.c. Referenced by main(). |
|
|
|
game specific initialization.
|
|
|
|
Definition at line 520 of file ui.c. Referenced by menu_start_stop_game(). |
|
Definition at line 397 of file ui.c. Referenced by menu_back_forw(), ui_get_machine_move(), ui_make_human_move(), and ui_start_game(). |
|
|
|
Definition at line 173 of file ui.c. Referenced by ui_check_who_won(). |
|
Definition at line 475 of file ui.c. Referenced by ui_move_now_cb(). |
|
Definition at line 454 of file ui.c. Referenced by board_signal_handler(), and ui_animate_cb(). |
|
|
|
|
|
Definition at line 435 of file ui.c. Referenced by main(), menu_start_stop_game(), ui_get_machine_move(), and ui_make_human_move(). |
|
Definition at line 317 of file ui.c. Referenced by menu_start_game(), and menu_start_stop_game(). |
|
Definition at line 531 of file ui.c. Referenced by main(). |
|
Definition at line 293 of file ui.c. Referenced by menu_set_game(), menu_start_stop_game(), and ui_cleanup(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
Definition at line 154 of file ui.c. Referenced by ui_animate_cb(). |
|
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. Definition at line 143 of file ui.c. Referenced by ab_with_tt(), and ab_with_tt_incr(). |
|
Definition at line 147 of file ui.c. Referenced by engine_eval(). |
|
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 :) Definition at line 144 of file ui.c. Referenced by ab_with_tt_incr(). |
|
Definition at line 146 of file ui.c. Referenced by engine_eval(). |
|
The all-in-one function that makes game_getmove and game_getmove_kb deprecated.
Definition at line 150 of file ui.c. Referenced by board_signal_handler(). |
|
|
|
Called at the end of every game.
Definition at line 157 of file ui.c. Referenced by reset_game_params(). |
|
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.
Definition at line 161 of file ui.c. Referenced by board_apply_refresh(). |
|
Same as game_get_pixmap but returns a rgbmap instead of pixmap.
Definition at line 156 of file ui.c. Referenced by board_init(). |
|
This takes a mouse click and returns the move that it corresponds to.
Definition at line 151 of file ui.c. Referenced by board_signal_handler(). |
|
Takes a keypress and returns the move that it corresponds to.
Definition at line 152 of file ui.c. Referenced by board_signal_handler(). |
|
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. Definition at line 149 of file ui.c. Referenced by ab_dfid(), ab_with_tt(), and ab_with_tt_incr(). |
|
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. Definition at line 158 of file ui.c. Referenced by ab_with_tt(), ab_with_tt_incr(), engine_make_move(), and engine_take_move(). |
|
|
|
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. Definition at line 162 of file ui.c. Referenced by menu_back_forw(), and ui_terminate_game(). |
|
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 |
|
Definition at line 163 of file ui.c. Referenced by prefs_add_highscore(). |
|
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.
Definition at line 148 of file ui.c. Referenced by engine_search(). |
|
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. Definition at line 159 of file ui.c. Referenced by engine_reset_game(), menu_load_file(), and set_game_params(). |
|
Sets the initial state of the rendering hints.
Definition at line 160 of file ui.c. Referenced by set_game_params(). |
|
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.
Definition at line 153 of file ui.c. Referenced by engine_who_won(). |
|
Initial value: { &Antichess, &Ataxx, &Blet, &Breakthrough, &Checkers, &Chess, &CapturePento, &Dnb, &Eightqueens, &Fifteen, &Flw, &Hiq, &Hypermaze, &Infiltrate, &Knights, &Kttour, &Mastermind, &Maze, &Memory, &Ninemm, &Othello, &Pacman, &Pentaline, &Plot4, &Quarto, &Rgb, &Samegame, &Stopgate, &Tetris, &Towers, &Wordtris} |
|
The main application window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|