Improved (?) pluto heuristic.
[rattatechess.git] / move.h
blobba60e5bfa261e17242e0ac264b6b1c748d1142a3
1 /***************************************************************************
2 move.h - Move related definitions
3 -------------------
4 begin : Sun Sep 28 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef __MOVE_H__
19 #define __MOVE_H__
21 #include "utils.h"
22 #include "hash.h"
24 // store all the possible moves of a knight.
25 class PACKED KnightMove
27 public:
28 uint8_t jump[8];
29 uint8_t numm;
33 /* PACKED, use a small structure even if unaligned.
34 if i can quote Alan Cox, "Cache is king" :) */
35 class PACKED Move
37 public:
38 union
40 struct
42 uint8_t from; /* square we are moving from */
43 uint8_t to; /* square we are moving to */
44 uint8_t capture;
45 uint8_t flags;
47 uint32_t as_int;
49 int16_t val;
50 uint8_t cost;
51 uint8_t extend;
53 bool operator==(const Move& m) const { return (as_int == m.as_int); }
54 bool operator!=(const Move& m) const { return (as_int != m.as_int); }
55 bool operator<(const Move& m) const { return (as_int < m.as_int); }
57 bool valid() const { return as_int<0xff000000; }
59 static Move FromInt(int i)
61 Move m;
62 m.as_int = i;
63 return m;
65 static Move None() { return FromInt(0xffffffff); }
66 static Move Illegal() { return FromInt(0xfffffffe); }
67 static Move Ambiguous() { return FromInt(0xfffffffd); }
71 class PACKED SaveBuf
73 public:
74 HashKey hash_key;
75 uint8_t castle_passing_mask;
76 uint8_t fifty;
80 typedef Buf<char, 64> MoveStr;
82 #endif //__MOVE_H__