This is the doxygen documentation for gtkboard.

.
Main Page   Data Structures   File List   Data Fields   Globals  

move.h File Reference

Operations on moves. More...

#include <stdio.h>
#include <glib.h>

Go to the source code of this file.

Defines

#define byte   gint8

Functions

byte* movdup (byte *)
 Make a copy of the move. More...

gboolean movcmp_literal (byte *move1, byte *move2)
 Compares two moves byte by byte. Literal not semantic comparison. Returns TRUE if the moves are equal.

int movcpy (byte *dest, byte *src)
 Makes the move src to the move dest. More...

byte* mov_getinv (byte *, byte *)
 Returns the inverse of a move in the given board. More...

void move_apply (byte *, byte *)
 Applies the move to the board.

void move_fwrite (byte *, FILE *)
 Writes a move to the pipe in human friendly format.

byte* move_read (char *)
 Parses a string into a move.

byte* move_fread (FILE *)
 Reads a move from the pipe.

byte* move_fread_ack (FILE *)
 Same as move_fread(), except it expects the stream to begin with "ACK ". Returns NULL otherwise.

char* line_read (FILE *)
 Reads a line from the stream.

void move_fwrite_ack (byte *, FILE *)
 Same as move_fwrite(), but precedes line with "ACK ".

void move_fwrite_nak (char *, FILE *)
 Writes "NAK " followed by arbitrary error message.

byte* movlist_next (byte *)
 Returns the next move in a movlist. More...


Detailed Description

Operations on moves.

A move is an array of bytes, which are simply gint8s. A move is a sequence of movelets terminated by -1. A movelet is a sequence of 3 bytes which describes what happens to a particular square in the board. Movelet format is "x y val" where val is the new value of the square (x, y). Thus the move corresponding to "1. e4" in chess is "4 1 0 4 3 6 -1" (i.e, square (4, 0), which means e2 becomes empty, and square (4, 3), which is e4, becomes 6, assuming that white pawn is represented by 6. Note that row and col numbers start from 0.) When the move is written to file or sent to the engine, it will be converted to a human friendly format.

Definition in file move.h.


Define Documentation

#define byte   gint8
 

Definition at line 40 of file move.h.


Function Documentation

char* line_read ( FILE * fin )
 

Reads a line from the stream.

Definition at line 153 of file move.c.

Referenced by ui_check_who_won().

byte* mov_getinv ( byte * board,
byte * move )
 

Returns the inverse of a move in the given board.

The move format does not specify the old value of the squares. So it is not possible to go from the new Pos to the old Pos. To be able to do this we need to get the "inverse" of the move using the current board

Definition at line 171 of file move.c.

Referenced by ab_with_tt_incr(), and movstack_push().

gboolean movcmp_literal ( byte * move1,
byte * move2 )
 

Compares two moves byte by byte. Literal not semantic comparison. Returns TRUE if the moves are equal.

Definition at line 44 of file move.c.

Referenced by ab_with_tt().

int movcpy ( byte * dest,
byte * src )
 

Makes the move src to the move dest.

Memory is assumed to have already been allocated for dest.

Definition at line 35 of file move.c.

Referenced by ab_dfid(), ab_with_tt(), and ab_with_tt_incr().

byte* movdup ( byte * move )
 

Make a copy of the move.

The new move is malloc()d and so must be free()d by the caller.

Definition at line 160 of file move.c.

Referenced by ab_with_tt(), hash_insert(), mov_getinv(), and movstack_push().

void move_apply ( byte * board,
byte * move )
 

Applies the move to the board.

Definition at line 63 of file move.c.

Referenced by ab_with_tt(), ab_with_tt_incr(), engine_back_move(), engine_forw_move(), engine_make_move(), engine_take_move(), and leads_to_check().

byte* move_fread ( FILE * fin )
 

Reads a move from the pipe.

Definition at line 138 of file move.c.

Referenced by ui_get_machine_move().

byte* move_fread_ack ( FILE * fin )
 

Same as move_fread(), except it expects the stream to begin with "ACK ". Returns NULL otherwise.

Definition at line 144 of file move.c.

Referenced by menu_back_forw(), and ui_get_machine_move().

void move_fwrite ( byte * move,
FILE * fout )
 

Writes a move to the pipe in human friendly format.

Definition at line 76 of file move.c.

Referenced by ab_dfid(), move_fwrite_ack(), ui_get_machine_move(), and ui_make_human_move().

void move_fwrite_ack ( byte * move,
FILE * fout )
 

Same as move_fwrite(), but precedes line with "ACK ".

Definition at line 92 of file move.c.

Referenced by engine_back_move(), engine_forw_move(), and engine_make_move().

void move_fwrite_nak ( char * str,
FILE * fout )
 

Writes "NAK " followed by arbitrary error message.

Definition at line 98 of file move.c.

Referenced by engine_back_move(), engine_forw_move(), engine_make_move(), and engine_who_won().

byte* move_read ( char * line )
 

Parses a string into a move.

Definition at line 107 of file move.c.

Referenced by engine_take_move(), move_fread(), and move_fread_ack().

byte* movlist_next ( byte * move )
 

Returns the next move in a movlist.

A movlist is also an array of bytes. It is a sequence of moves terminated by -2

Definition at line 56 of file move.c.

Referenced by ab_dfid(), ab_with_tt(), and ab_with_tt_incr().