This is the doxygen documentation for gtkboard.

.
Main Page   Data Structures   File List   Data Fields   Globals  

engine.c File Reference

The engine forms the backend that does the number crunching. More...

#include "game.h"
#include "move.h"
#include "stack.h"
#include "engine.h"
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>

Go to the source code of this file.

Defines

#define NUM_COMMANDS   (sizeof (commands) / sizeof (commands[0]))

Functions

byte* engine_search (Pos *)
void reset_game_params ()
void set_game_params ()
 game specific initialization.

void game_set_init_pos_def (Pos *)
byte* ab_dfid (Pos *, int)
 Alpha-beta search function (using depth first iterative deepening).

gboolean engine_hup_cb ()
ResultType engine_eval (Pos *pos, float *eval)
void engine_set_to_play (char *line)
void engine_take_move (char *line)
void engine_make_move ()
void engine_new_game (char *gamename)
void engine_reset_game ()
void engine_back_move ()
void engine_forw_move ()
void engine_msec_per_move (char *line)
void engine_who_won (char *line)
void engine_move_now (char *line)
int engine_timeout_cb ()
void engine_cancel_move (char *line)
void execute_command (char *line)
 Parse the command and pass control to the corresponding function pointer.

gboolean process_line ()
gboolean channel_process_input ()
void engine_poll ()
 Functions that do the actual thinking must periodically call this function. More...

void ignore ()
void engine_main (int infd, int outfd)
 This is the main function for the engine.


Variables

int board_wid
int board_heit
int opt_verbose
gboolean engine_flag
Pos cur_pos
Gameopt_game
Gamegames []
int num_games
FILE* engine_fin
FILE * engine_fout
ResultType (* game_eval_white )(Pos *, Player, float *)
 Eval fn for white (can be NULL, in which case game_eval will be used for both).

ResultType (* game_eval_black )(Pos *, Player, float *)
 Eval fn for black (can be NULL, in which case game_eval will be used for both).

GIOChannel* channel_in = NULL
 The input pipe is accessed through a GIOChannel so that we can register a callback for events.

gboolean engine_stop_search = FALSE
 If an event occurs when we are thinking this will be set to TRUE so that we will know to stop thinking.

gboolean cancel_move = FALSE
 Indicates whether we have to stop and return the move or stop and cancel the move.

int time_per_move = 5000
 Max time per move. alpha-beta will often return earlier than this.

Command commands []
 This structure defines the protocol. More...

GSList* command_list = NULL


Detailed Description

The engine forms the backend that does the number crunching.

Definition in file engine.c.


Define Documentation

#define NUM_COMMANDS   (sizeof (commands) / sizeof (commands[0]))
 

Definition at line 291 of file engine.c.


Function Documentation

byte* ab_dfid ( Pos * pos,
int player )
 

Alpha-beta search function (using depth first iterative deepening).

Definition at line 284 of file ab.c.

Referenced by engine_search().

gboolean channel_process_input ( ) [static]
 

Definition at line 329 of file engine.c.

void engine_back_move ( )
 

Definition at line 179 of file engine.c.

void engine_cancel_move ( char * line )
 

Definition at line 262 of file engine.c.

ResultType engine_eval ( Pos * pos,
float * eval )
 

Definition at line 80 of file engine.c.

void engine_forw_move ( )
 

Definition at line 194 of file engine.c.

gboolean engine_hup_cb ( )
 

Definition at line 72 of file engine.c.

void engine_main ( int infd,
int outfd )
 

This is the main function for the engine.

Definition at line 379 of file engine.c.

void engine_make_move ( )
 

Definition at line 112 of file engine.c.

void engine_move_now ( char * line )
 

Definition at line 251 of file engine.c.

void engine_msec_per_move ( char * line )
 

Definition at line 211 of file engine.c.

void engine_new_game ( char * gamename )
 

Definition at line 138 of file engine.c.

void engine_poll ( )
 

Functions that do the actual thinking must periodically call this function.

It checks if new commands have arrived.

Definition at line 361 of file engine.c.

Referenced by ab_with_tt(), and ab_with_tt_incr().

void engine_reset_game ( )
 

Definition at line 169 of file engine.c.

byte* engine_search ( Pos * pos )
 

Definition at line 400 of file engine.c.

Referenced by engine_make_move().

void engine_set_to_play ( char * line )
 

Definition at line 88 of file engine.c.

void engine_take_move ( char * line )
 

Definition at line 96 of file engine.c.

int engine_timeout_cb ( )
 

Definition at line 256 of file engine.c.

void engine_who_won ( char * line )
 

Definition at line 219 of file engine.c.

void execute_command ( char * line ) [static]
 

Parse the command and pass control to the corresponding function pointer.

Definition at line 294 of file engine.c.

Referenced by process_line().

void game_set_init_pos_def ( Pos * pos )
 

Definition at line 223 of file ui.c.

void ignore ( ) [static]
 

Definition at line 376 of file engine.c.

gboolean process_line ( ) [static]
 

Definition at line 318 of file engine.c.

Referenced by channel_process_input(), and engine_poll().

void reset_game_params ( )
 

Definition at line 236 of file ui.c.

Referenced by engine_new_game(), main(), and ui_terminate_game().

void set_game_params ( )
 

game specific initialization.

Definition at line 354 of file ui.c.

Referenced by engine_new_game(), main(), and ui_start_game().


Variable Documentation

int board_heit
 

Definition at line 33 of file engine.c.

int board_wid
 

Definition at line 33 of file engine.c.

gboolean cancel_move = FALSE [static]
 

Indicates whether we have to stop and return the move or stop and cancel the move.

Definition at line 67 of file engine.c.

GIOChannel* channel_in = NULL [static]
 

The input pipe is accessed through a GIOChannel so that we can register a callback for events.

Definition at line 61 of file engine.c.

GSList* command_list = NULL [static]
 

Definition at line 317 of file engine.c.

Command commands
 

Initial value:

 
{
        { "MSEC_PER_MOVE"  , 1 , engine_msec_per_move},
        { "SUGGEST_MOVE"    , 0 , NULL},
        { "TAKE_MOVE"       , 1 , engine_take_move},
        { "BACK_MOVE"       , 1 , engine_back_move},
        { "FORW_MOVE"       , 1 , engine_forw_move},
        { "MAKE_MOVE"       , 1 , engine_make_move},
        { "MOVE_NOW"            , 1 , engine_move_now },
        { "CANCEL_MOVE"         , 1 , engine_cancel_move },
        { "END_GAME"        , 0 , NULL},
        { "RESET_GAME"      , 1 , engine_reset_game},
        { "TO_PLAY"         , 1 , engine_set_to_play},
        { "SET_POSITION"    , 0 , NULL},
        { "NEW_GAME"        , 1 , engine_new_game},
        { "GET_EVAL"        , 0 , NULL},
        { "SET_HEUR"        , 0 , NULL},
        { "SET_STRATEGY"    , 0 , NULL},
        { "WHO_WON"                     , 1 , engine_who_won},
}
This structure defines the protocol.

Definition at line 270 of file engine.c.

Pos cur_pos
 

Definition at line 40 of file engine.c.

FILE* engine_fin [static]
 

Definition at line 45 of file engine.c.

gboolean engine_flag
 

Definition at line 38 of file engine.c.

FILE * engine_fout [static]
 

Definition at line 45 of file engine.c.

gboolean engine_stop_search = FALSE
 

If an event occurs when we are thinking this will be set to TRUE so that we will know to stop thinking.

Definition at line 64 of file engine.c.

ResultType(* game_eval_black)(Pos *, Player, float *)
 

Eval fn for black (can be NULL, in which case game_eval will be used for both).

Definition at line 50 of file engine.c.

ResultType(* game_eval_white)(Pos *, Player, float *)
 

Eval fn for white (can be NULL, in which case game_eval will be used for both).

Definition at line 48 of file engine.c.

Game * games[]
 

Definition at line 42 of file engine.c.

int num_games
 

Definition at line 43 of file engine.c.

Game* opt_game
 

Definition at line 42 of file engine.c.

int opt_verbose
 

Definition at line 34 of file engine.c.

int time_per_move = 5000
 

Max time per move. alpha-beta will often return earlier than this.

Definition at line 70 of file engine.c.