blob: 9e1fc817466155ae523f5859ad1e0d3a6fdda5b3 (
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
|
/***************************************************************************
logic.h - description
-------------------
begin : Sat Sep 29 2001
copyright : (C) 2003 by Troy Corbin Jr.
email : tcorbin@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef LOGIC_H
#define LOGIC_H
#include <tqstring.h>
#include "definitions.h"
#include "resource.h"
#include "match_param.h"
/**
*@author Troy Corbin Jr.
*/
const char CF_King = 0x01;
const char CF_RookQ = 0x02;
const char CF_RookK = 0x04;
class logic
{
public:
char OnMove;
Position current[64];
Chessman chessman[64];
ChessMove chessMove;
/* This is used for the 50 move rule */
char MoveCounter;
logic( resource *Rsrc=0, match_param *param=0 );
~logic();
void Init( const int Var=Type_Standard );
void setBoard( const TQString &board=TQString(), const short ppf=-2 );
void setBoardFromFen( const TQString &fen );
TQString board( void );
bool isChessman( const char ChessmanPtr );
bool isCheck( const bool Army );
bool isLegal( const bool Army );
bool isDraw( const bool Army );
bool Move( void );
void HashLegal( const char Man, const bool Recursion=FALSE );
int Pointer( const char File, const char Rank );
bool parseCAN( const bool Army );
bool parseSAN( void );
void writeCAN( void );
void writeSAN( void );
protected:
int CalcPointer( const char File, const char Rank );
void _HashLegal( const bool Recursion=FALSE );
void clearBoard( void );
int getKing( const bool Army );
void Init_Standard( void );
inline void copyPositions( Position *Src, Position *Dst )
{ memcpy( Dst, Src, sizeof(Position) << 6 ); }
inline void copyChessmen( Chessman *Src, Chessman *Dst )
{ memcpy( Dst, Src, sizeof(Chessman) << 6 ); }
private:
resource *Resource;
match_param *Param;
int GameType;
Position hash[64];
Position hashBackup[64];
Chessman chessmanBackup[64];
char CastleFlag[2];
char enPassant[2];
char ManPtr;
};
#endif
|