Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/boards/chess_position.h
blob: 9f7e2b759987a29b3e7ca6a05184da246b3314cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* engine.h
 *
 * Copyright (C) 1999  Robert Wilhelm
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Authors: Robert Wilhelm
 *          JP Rosevear
 */

#ifndef _POSITION_H_
#define _POSITION_H_

#include <gtk/gtk.h>
#include "chess_makros.h"

#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */

#define TYPE_POSITION	       (position_get_type ())
#define POSITION(obj)          GTK_CHECK_CAST (obj, TYPE_POSITION, Position)
#define POSITION_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, TYPE_POSITION, PositionClass)
#define IS_POSITION(obj)       GTK_CHECK_TYPE (obj, TYPE_POSITION)

typedef struct _Position        Position;
typedef struct _PositionClass   PositionClass;
typedef struct _PositionPrivate PositionPrivate;

struct _PositionClass {
	GtkObjectClass parent_class;
};

struct _Position {
	GtkObject        object;

	/* 10x10 board - extra for move generation */
	Piece            square[120]; 

	PositionPrivate *priv;
};

GtkType    position_get_type             (void);    
GtkObject *position_new                   (void);
GtkObject *position_new_initial           (void);
Position  *position_copy                 (Position *pos);
void       position_set_initial          (Position *pos);
void       position_set_initial_partyend (Position *pos, int level);
void       position_set_initial_movelearn(Position *pos, int level);
void       position_move                 (Position *pos, Square from, Square to);
Square     position_move_normalize       (Position *pos, Square from, Square to);
void       position_move_reverse_white   (Position *pos, Square from, Square to);
void       position_move_reverse_black   (Position *pos, Square from, Square to);
void       position_move_reverse         (Position *pos, Square from, Square to);
gint       position_move_generator        (Position *pos, Square **index0, gshort *anz_s, gshort *anz_n);
gboolean   position_white_king_attack    (Position *pos);
gboolean   position_black_king_attack    (Position *pos);
gshort     position_legal_move           (Position *pos, Square **zl, gshort *as, gshort *an);

/* Misc. accessors */
void       position_set_white_king       (Position *pos, Square square);
void       position_set_black_king       (Position *pos, Square square);
void       position_set_color_to_move    (Position *pos, short color);
short      position_get_color_to_move    (Position *pos);
short      position_last_piece_captured  (Position *pos);

void	   position_display		 (Position *pos);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _POSITION_H_ */