00001
00002
00003 #ifndef ENDGAME_KINGPIECETABLE_H
00004 #define ENDGAME_KINGPIECETABLE_H
00005
00006 #include "osl/piece.h"
00007 #include "osl/misc/carray2d.h"
00008
00009 namespace osl
00010 {
00011 namespace state
00012 {
00013 class SimpleState;
00014 }
00015 namespace container
00016 {
00017 class PieceValues;
00018 }
00019 namespace eval
00020 {
00021 namespace endgame
00022 {
00026 class KingPieceTable
00027 {
00028 protected:
00029 CArray2d<int,Position::SIZE*2,Position::SIZE*PTYPE_SIZE> data;
00030 KingPieceTable() {}
00031 public:
00032 static int otherIndex(Position other, Ptype ptype)
00033 {
00034 return other.index()*PTYPE_SIZE + ptype;
00035 }
00036 static int kingIndex(Position king, Player defense)
00037 {
00038 return king.index()*2+playerToIndex(defense);
00039 }
00040 int& valueOf(Position king, Player defense, Position other, Ptype ptype)
00041 {
00042 return data[kingIndex(king,defense)][otherIndex(other,ptype)];
00043 }
00044 int valueOf(Position king, Player defense, Position other, Ptype ptype) const
00045 {
00046 return data[kingIndex(king,defense)][otherIndex(other, ptype)];
00047 }
00048 };
00049 }
00050 }
00051 }
00052
00053
00054 #endif
00055
00056
00057
00058