This is the doxygen documentation for gtkboard.

.
Main Page   Data Structures   File List   Data Fields   Globals  

chess.c File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "game.h"
#include "../pixmaps/chess.xpm"
#include "move.h"

Go to the source code of this file.

Data Structures

struct  Chess_state

Defines

#define CHESS_CELL_SIZE   54
#define CHESS_NUM_PIECES   12
#define CHESS_BOARD_WID   8
#define CHESS_BOARD_HEIT   8
#define CHESS_EMPTY   0
#define CHESS_WK   1
#define CHESS_WQ   2
#define CHESS_WR   3
#define CHESS_WB   4
#define CHESS_WN   5
#define CHESS_WP   6
#define CHESS_BK   7
#define CHESS_BQ   8
#define CHESS_BR   9
#define CHESS_BB   10
#define CHESS_BN   11
#define CHESS_BP   12
#define A_FILE   0
#define B_FILE   1
#define C_FILE   2
#define D_FILE   3
#define E_FILE   4
#define F_FILE   5
#define G_FILE   6
#define H_FILE   7
#define RANK_1   0
#define RANK_2   1
#define RANK_3   2
#define RANK_4   3
#define RANK_5   4
#define RANK_6   5
#define RANK_7   6
#define RANK_8   7
#define CHESS_ISWHITE(x)   (x >= 1 && x <= 6)
#define CHESS_ISBLACK(x)   (x >= 7 && x <= 12)
#define abs(x)   ((x) < 0 ? -(x) : (x))

Functions

void chess_init ()
int chess_getmove (Pos *, int, int, GtkboardEventType, Player, byte **, int **)
ResultType chess_who_won (Pos *, Player, char **)
byte* chess_movegen (Pos *)
ResultType chess_eval (Pos *, Player, float *)
void* chess_newstate (Pos *, byte *)
void chess_reset_uistate ()
int isfreeline (byte *pos, int oldx, int oldy, int newx, int newy)
int islegal (Pos *pos, int oldx, int oldy, int x, int y)
int oppcolor (byte *board, int oldx, int oldy, int x, int y)
gboolean is_in_check (Pos *pos, Player player)
gboolean leads_to_check (byte *board, byte *move, Player player)
 Would "player" be in check after making "move".

int hasmove (Pos *pos, int player)
int chess_movegen_square (byte *board, byte **movp, int player, int oldx, int oldy, int x, int y)
int chess_movegen_line (byte *pos, byte **movp, int player, int x, int y, int incx, int incy)
void chess_movegen_promote (byte *board, byte **movp, int player, int oldx, int oldy, int x, int y)
void chess_movegen_enpassant (Pos *pos, byte **movp, int player, int x, int y)
void chess_movegen_castle (Pos *pos, byte **movp, int player)
float getweight (byte val)

Variables

char chess_colors []
int chess_init_pos []
int chess_max_moves = 200
char** chess_pixmaps []
Game Chess
int oldx = -1
int oldy = -1
int oldval = -1
int prom = 0
int prom_x
int prom_oldx


Define Documentation

#define A_FILE   0
 

Definition at line 48 of file chess.c.

#define B_FILE   1
 

Definition at line 49 of file chess.c.

#define CHESS_BB   10
 

Definition at line 44 of file chess.c.

#define CHESS_BK   7
 

Definition at line 41 of file chess.c.

#define CHESS_BN   11
 

Definition at line 45 of file chess.c.

#define CHESS_BOARD_HEIT   8
 

Definition at line 32 of file chess.c.

#define CHESS_BOARD_WID   8
 

Definition at line 31 of file chess.c.

#define CHESS_BP   12
 

Definition at line 46 of file chess.c.

#define CHESS_BQ   8
 

Definition at line 42 of file chess.c.

#define CHESS_BR   9
 

Definition at line 43 of file chess.c.

#define CHESS_CELL_SIZE   54
 

Definition at line 28 of file chess.c.

#define CHESS_EMPTY   0
 

Definition at line 34 of file chess.c.

#define CHESS_ISBLACK( x )   (x >= 7 && x <= 12)
 

Definition at line 67 of file chess.c.

Referenced by chess_getmove(), chess_movegen(), chess_movegen_square(), hasmove(), is_in_check(), and oppcolor().

#define CHESS_ISWHITE( x )   (x >= 1 && x <= 6)
 

Definition at line 66 of file chess.c.

Referenced by chess_getmove(), chess_movegen(), chess_movegen_square(), hasmove(), is_in_check(), and oppcolor().

#define CHESS_NUM_PIECES   12
 

Definition at line 29 of file chess.c.

#define CHESS_WB   4
 

Definition at line 38 of file chess.c.

#define CHESS_WK   1
 

Definition at line 35 of file chess.c.

#define CHESS_WN   5
 

Definition at line 39 of file chess.c.

#define CHESS_WP   6
 

Definition at line 40 of file chess.c.

#define CHESS_WQ   2
 

Definition at line 36 of file chess.c.

#define CHESS_WR   3
 

Definition at line 37 of file chess.c.

#define C_FILE   2
 

Definition at line 50 of file chess.c.

#define D_FILE   3
 

Definition at line 51 of file chess.c.

#define E_FILE   4
 

Definition at line 52 of file chess.c.

#define F_FILE   5
 

Definition at line 53 of file chess.c.

#define G_FILE   6
 

Definition at line 54 of file chess.c.

#define H_FILE   7
 

Definition at line 55 of file chess.c.

#define RANK_1   0
 

Definition at line 57 of file chess.c.

#define RANK_2   1
 

Definition at line 58 of file chess.c.

#define RANK_3   2
 

Definition at line 59 of file chess.c.

#define RANK_4   3
 

Definition at line 60 of file chess.c.

#define RANK_5   4
 

Definition at line 61 of file chess.c.

#define RANK_6   5
 

Definition at line 62 of file chess.c.

#define RANK_7   6
 

Definition at line 63 of file chess.c.

#define RANK_8   7
 

Definition at line 64 of file chess.c.

#define abs( x )   ((x) < 0 ? -(x) : (x))
 

Definition at line 70 of file chess.c.


Function Documentation

ResultType chess_eval ( Pos * pos,
Player player,
float * eval )
 

Definition at line 888 of file chess.c.

int chess_getmove ( Pos * pos,
int x,
int y,
GtkboardEventType type,
Player player,
byte ** movep,
int ** rmovep )
 

Definition at line 349 of file chess.c.

void chess_init ( )
 

Definition at line 134 of file chess.c.

byte* chess_movegen ( Pos * pos )
 

Definition at line 723 of file chess.c.

Referenced by chess_who_won().

void chess_movegen_castle ( Pos * pos,
byte ** movp,
int player ) [static]
 

Definition at line 620 of file chess.c.

Referenced by chess_movegen().

void chess_movegen_enpassant ( Pos * pos,
byte ** movp,
int player,
int x,
int y ) [static]
 

Definition at line 589 of file chess.c.

Referenced by chess_movegen().

int chess_movegen_line ( byte * pos,
byte ** movp,
int player,
int x,
int y,
int incx,
int incy )
 

Definition at line 547 of file chess.c.

Referenced by chess_movegen().

void chess_movegen_promote ( byte * board,
byte ** movp,
int player,
int oldx,
int oldy,
int x,
int y ) [static]
 

Definition at line 563 of file chess.c.

Referenced by chess_movegen().

int chess_movegen_square ( byte * board,
byte ** movp,
int player,
int oldx,
int oldy,
int x,
int y )
 

Definition at line 523 of file chess.c.

Referenced by chess_movegen(), and chess_movegen_line().

void* chess_newstate ( Pos * pos,
byte * move )
 

Definition at line 154 of file chess.c.

void chess_reset_uistate ( )
 

Definition at line 343 of file chess.c.

ResultType chess_who_won ( Pos * pos,
Player player,
char ** commp )
 

Definition at line 492 of file chess.c.

float getweight ( byte val )
 

Definition at line 866 of file chess.c.

Referenced by chess_eval().

int hasmove ( Pos * pos,
int player ) [static]
 

Definition at line 476 of file chess.c.

gboolean is_in_check ( Pos * pos,
Player player ) [static]
 

Definition at line 299 of file chess.c.

Referenced by chess_movegen_castle(), chess_who_won(), and leads_to_check().

int isfreeline ( byte * pos,
int oldx,
int oldy,
int newx,
int newy ) [static]
 

Definition at line 187 of file chess.c.

Referenced by islegal().

int islegal ( Pos * pos,
int oldx,
int oldy,
int x,
int y ) [static]
 

Definition at line 200 of file chess.c.

Referenced by antichess_getmove(), can_capture(), chess_getmove(), hasmove(), and is_in_check().

gboolean leads_to_check ( byte * board,
byte * move,
Player player ) [static]
 

Would "player" be in check after making "move".

Definition at line 328 of file chess.c.

Referenced by chess_getmove(), chess_movegen_castle(), chess_movegen_enpassant(), chess_movegen_promote(), and chess_movegen_square().

int oppcolor ( byte * board,
int oldx,
int oldy,
int x,
int y ) [static]
 

Definition at line 290 of file chess.c.

Referenced by antichess_movegen(), antichess_movegen_line(), and chess_movegen_line().


Variable Documentation

Game Chess
 

Initial value:

 
        { CHESS_CELL_SIZE, CHESS_BOARD_WID, CHESS_BOARD_HEIT, 
        CHESS_NUM_PIECES,
        chess_colors, chess_init_pos, chess_pixmaps, "Chess",
        chess_init}

Definition at line 117 of file chess.c.

char chess_colors[]
 

Initial value:

 
        {200, 200, 130, 
        0, 140, 0}

Definition at line 73 of file chess.c.

int chess_init_pos[]
 

Initial value:

 
{
         9 , 11, 10, 8 , 7 , 10, 11, 9  ,
         12, 12, 12, 12, 12, 12, 12, 12 ,
         0 , 0 , 0 , 0 , 0 , 0 , 0 , 0  ,
         0 , 0 , 0 , 0 , 0 , 0 , 0 , 0  ,
         0 , 0 , 0 , 0 , 0 , 0 , 0 , 0  ,
         0 , 0 , 0 , 0 , 0 , 0 , 0 , 0  ,
         6 , 6 , 6 , 6 , 6 , 6 , 6 , 6  ,
         3 , 5 , 4 , 2 , 1 , 4 , 5 , 3  ,
}

Definition at line 77 of file chess.c.

int chess_max_moves = 200 [static]
 

Definition at line 88 of file chess.c.

char** chess_pixmaps[]
 

Initial value:


{
        chess_wk_54_xpm, 
        chess_wq_54_xpm, 
        chess_wr_54_xpm, 
        chess_wb_54_xpm, 
        chess_wn_54_xpm, 
        chess_wp_54_xpm, 
        chess_bk_54_xpm, 
        chess_bq_54_xpm, 
        chess_br_54_xpm, 
        chess_bb_54_xpm, 
        chess_bn_54_xpm, 
        chess_bp_54_xpm,
}

Definition at line 90 of file chess.c.

int oldval = -1 [static]
 

Definition at line 340 of file chess.c.

int oldx = -1 [static]
 

Definition at line 340 of file chess.c.

int oldy = -1 [static]
 

Definition at line 340 of file chess.c.

int prom = 0 [static]
 

Definition at line 341 of file chess.c.

int prom_oldx [static]
 

Definition at line 341 of file chess.c.

int prom_x [static]
 

Definition at line 341 of file chess.c.