Back to index

gcompris  8.2.2
chess_position.h
Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
00002 /* engine.h
00003  *
00004  * Copyright (C) 1999  Robert Wilhelm
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public
00017  * License along with this program; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  *
00021  * Authors: Robert Wilhelm
00022  *          JP Rosevear
00023  */
00024 
00025 #ifndef _POSITION_H_
00026 #define _POSITION_H_
00027 
00028 #include <gtk/gtk.h>
00029 #include "chess_makros.h"
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #pragma }
00034 #endif /* __cplusplus */
00035 
00036 #define TYPE_POSITION              (position_get_type ())
00037 #define POSITION(obj)          GTK_CHECK_CAST (obj, TYPE_POSITION, Position)
00038 #define POSITION_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, TYPE_POSITION, PositionClass)
00039 #define IS_POSITION(obj)       GTK_CHECK_TYPE (obj, TYPE_POSITION)
00040 
00041 typedef struct _Position        Position;
00042 typedef struct _PositionClass   PositionClass;
00043 typedef struct _PositionPrivate PositionPrivate;
00044 
00045 struct _PositionClass {
00046        GtkObjectClass parent_class;
00047 };
00048 
00049 struct _Position {
00050        GtkObject        object;
00051 
00052        /* 10x10 board - extra for move generation */
00053        Piece            square[120]; 
00054 
00055        PositionPrivate *priv;
00056 };
00057 
00058 GtkType    position_get_type             (void);    
00059 GtkObject *position_new                   (void);
00060 GtkObject *position_new_initial           (void);
00061 Position  *position_copy                 (Position *pos);
00062 void       position_set_initial          (Position *pos);
00063 void       position_set_initial_partyend (Position *pos, int level);
00064 void       position_set_initial_movelearn(Position *pos, int level);
00065 void       position_move                 (Position *pos, Square from, Square to);
00066 Square     position_move_normalize       (Position *pos, Square from, Square to);
00067 void       position_move_reverse_white   (Position *pos, Square from, Square to);
00068 void       position_move_reverse_black   (Position *pos, Square from, Square to);
00069 void       position_move_reverse         (Position *pos, Square from, Square to);
00070 gint       position_move_generator        (Position *pos, Square **index0, gshort *anz_s, gshort *anz_n);
00071 gboolean   position_white_king_attack    (Position *pos);
00072 gboolean   position_black_king_attack    (Position *pos);
00073 gshort     position_legal_move           (Position *pos, Square **zl, gshort *as, gshort *an);
00074 
00075 /* Misc. accessors */
00076 void       position_set_white_king       (Position *pos, Square square);
00077 void       position_set_black_king       (Position *pos, Square square);
00078 void       position_set_color_to_move    (Position *pos, short color);
00079 short      position_get_color_to_move    (Position *pos);
00080 short      position_last_piece_captured  (Position *pos);
00081 
00082 void      position_display          (Position *pos);
00083 
00084 #ifdef __cplusplus
00085 }
00086 #endif /* __cplusplus */
00087 
00088 #endif /* _POSITION_H_ */