Classes | Macros | Typedefs | Functions | Variables
cassio.c File Reference
#include "cassio.h"
#include "event.h"
#include "options.h"
#include "search.h"
#include "settings.h"
#include "ybwc.h"
#include "stats.h"
#include "util.h"
#include <assert.h>
#include <stdarg.h>
#include <math.h>

Classes

struct  Engine
 

Macros

#define ENGINE_N_POSITION   1024
 

Typedefs

typedef struct Engine Engine
 

Functions

static void engine_send (const char *format,...)
 Send a message on stdout. More...
 
static void engine_get_input (Engine *engine)
 Read an input line. More...
 
static void engine_wait_input (Engine *engine, char **cmd, char **param)
 Engine wait input. More...
 
static void * engine_input_loop (void *v)
 Read event loop. More...
 
static bool is_position_new (Engine *engine, Board *board)
 
static void engine_observer (Result *result)
 Call back function use by search to print its results. More...
 
static Searchengine_create_search (void)
 Create engine search. More...
 
static int engine_open (Search *search, const Board *board, const int player, const int alpha, const int beta, const int depth, const int precision)
 Open search engine. More...
 
static void engine_close (Search *search)
 Finalize search. More...
 
void * engine_init (void)
 Create a new Othello engine. More...
 
void engine_free (void *v)
 free resources allocated More...
 
void feed_all_hash_table (Search *search, Board *board, const int depth, const int selectivity, const int lower, const int upper, const int move)
 
void engine_feed_hash (void *v, Board *board, int lower, int upper, const int depth, const int precision, Line *pv)
 feed hash table More...
 
void engine_empty_hash (void *v)
 Empty (ie completely clear) the engine hash table. More...
 
static bool skip_search (Engine *engine, int *old_score)
 Check if a search has already been done here. More...
 
double engine_midgame_search (void *v, const char *position, const double alpha, const double beta, const int depth, const int precision)
 Midgame search. More...
 
int engine_endgame_search (void *v, const char *position, const int alpha, const int beta, const int precision)
 Endgame search. More...
 
void engine_stop (void *v)
 Stop searching. More...
 
void engine_loop (void)
 Loop event. More...
 

Variables

Log engine_log [1]
 
static char engine_result [1024]
 
static char last_line_sent [1024]
 

Detailed Description

Engine low level Protocol to communicate with Cassio by Stephane Nicolet.

The main purpose of this protocol is to help Cassio in this research. Cassio still does a lot of works like time management, etc.

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Macro Definition Documentation

◆ ENGINE_N_POSITION

#define ENGINE_N_POSITION   1024

Typedef Documentation

◆ Engine

typedef struct Engine Engine

Engine management data

Function Documentation

◆ engine_close()

static void engine_close ( Search search)
static

Finalize search.

Parameters
searchSearch engine.

◆ engine_create_search()

static Search* engine_create_search ( void  )
static

Create engine search.

Returns
a pointer to a newly allocated search structure.

◆ engine_empty_hash()

void engine_empty_hash ( void *  v)

Empty (ie completely clear) the engine hash table.

Parameters
vEngine.

◆ engine_endgame_search()

int engine_endgame_search ( void *  v,
const char *  position,
const int  alpha,
const int  beta,
const int  precision 
)

Endgame search.

Practically, Edax does the same things than in midgame search, with depth set as the number of empty squares. In case (beta - alpha) < 1, Edax will reajust beta so that beta = alpha + 1.

Parameters
vEngine.
positionString description of the position.
alphaAlpha bound.
betaBeta bound.
precisionProbcut percentage.

◆ engine_feed_hash()

void engine_feed_hash ( void *  v,
Board board,
int  lower,
int  upper,
const int  depth,
const int  precision,
Line pv 
)

feed hash table

Parameters
vEngine.
boardPosition to add.
upperUpper score bound.
lowerLower score bound.
depthdepth.
precisionProbcut percentage.
pvMain line to add to the hashtable.

◆ engine_free()

void engine_free ( void *  v)

free resources allocated

Parameters
vEngine.

◆ engine_get_input()

static void engine_get_input ( Engine engine)
static

Read an input line.

Parameters
engineEngine.

◆ engine_init()

void* engine_init ( void  )

Create a new Othello engine.

Allocate engine resources & launch user-input event thread.

Returns
A pointer to a newly allocated engine structure.

◆ engine_input_loop()

static void* engine_input_loop ( void *  v)
static

Read event loop.

Parameters
vEngine.

◆ engine_loop()

void engine_loop ( void  )

Loop event.

◆ engine_midgame_search()

double engine_midgame_search ( void *  v,
const char *  position,
const double  alpha,
const double  beta,
const int  depth,
const int  precision 
)

Midgame search.

Edax evaluation resolution is only one disc, so the doubleing point accuracy is not actually used here. In case (beta - alpha) < 1, Edax will reajust beta so that beta = alpha + 1. For some depths, extension-pv heuristics will return endgame score.

Parameters
vEngine.
positionString description of the position.
alphaAlpha bound.
betaBeta bound.
depthSearch depth.
precisionProbcut percentage.

◆ engine_observer()

static void engine_observer ( Result result)
static

Call back function use by search to print its results.

Parameters
resultSearch results.

◆ engine_open()

static int engine_open ( Search search,
const Board board,
const int  player,
const int  alpha,
const int  beta,
const int  depth,
const int  precision 
)
static

Open search engine.

Set the board to analyze with the alpha-beta bounds and the depth-precision targets.

Parameters
searchSearch engine.
boardPosition to analyze.
playerPlayer on turn.
alphaAlpha bound.
betaBeta bound.
depthTarget depth to reach.
precisionTarget precision to reach.

◆ engine_send()

static void engine_send ( const char *  format,
  ... 
)
static

Send a message on stdout.

Parameters
formatFormat string.
...variable arguments.

◆ engine_stop()

void engine_stop ( void *  v)

Stop searching.

Parameters
vSearch.

◆ engine_wait_input()

static void engine_wait_input ( Engine engine,
char **  cmd,
char **  param 
)
static

Engine wait input.

Parameters
engineEngine.
cmdCommand.
paramCommand's parameters.

◆ feed_all_hash_table()

void feed_all_hash_table ( Search search,
Board board,
const int  depth,
const int  selectivity,
const int  lower,
const int  upper,
const int  move 
)

◆ is_position_new()

static bool is_position_new ( Engine engine,
Board board 
)
static

Check if a position has been already analyzed.

◆ skip_search()

static bool skip_search ( Engine engine,
int *  old_score 
)
static

Check if a search has already been done here.

Parameters
engineSearch engine.
old_scorePreviously found score.
Returns
true if a new search can be skipped, false otherwise.

Variable Documentation

◆ engine_log

Log engine_log[1]

◆ engine_result

char engine_result[1024]
static

a global variable used to display the search result

◆ last_line_sent

char last_line_sent[1024]
static

a global string with the last result sent to avoid duplicate result lines