This is the doxygen documentation for gtkboard.

.
Main Page   Data Structures   File List   Data Fields   Globals  

move.c File Reference

#include "move.h"
#include "game.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

Go to the source code of this file.

Functions

int movcpy (byte *dest, byte *src)
 Makes the move src to the move dest. 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.

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

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

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

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

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

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

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

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

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

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

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


Variables

int board_wid
int board_heit
byte linebuf [4096]


Function Documentation

char * line_read ( FILE * fin )
 

Reads a line from the stream.

Definition at line 153 of file move.c.

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.

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.

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.

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.

void move_apply ( byte * board,
byte * move )
 

Applies the move to the board.

Definition at line 63 of file move.c.

byte * move_fread ( FILE * fin )
 

Reads a move from the pipe.

Definition at line 138 of file move.c.

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.

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.

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.

void move_fwrite_nak ( char * str,
FILE * fout )
 

Writes "NAK " followed by arbitrary error message.

Definition at line 98 of file move.c.

byte * move_read ( char * line )
 

Parses a string into a move.

Definition at line 107 of file move.c.

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.


Variable Documentation

int board_heit
 

Definition at line 28 of file move.c.

int board_wid
 

Definition at line 28 of file move.c.

byte linebuf[4096] [static]
 

Definition at line 136 of file move.c.