| 1 |
/* dominanceTableTestCommons.h |
| 2 |
*/ |
| 3 |
#ifndef _DOMINANCETABLETESTCOMMONS_H |
| 4 |
#define _DOMINANCETABLETESTCOMMONS_H |
| 5 |
|
| 6 |
#include "osl/checkmate/checkHashRecord.h" |
| 7 |
#include "osl/state/hashEffectState.h" |
| 8 |
#include "osl/record/csaString.h" |
| 9 |
|
| 10 |
#include <cppunit/TestCase.h> |
| 11 |
#include <cppunit/extensions/HelperMacros.h> |
| 12 |
|
| 13 |
using namespace osl; |
| 14 |
using namespace osl::checkmate; |
| 15 |
|
| 16 |
template <class Table> |
| 17 |
struct DominanceTableTestCommons |
| 18 |
{ |
| 19 |
void testAllocateBlack(); |
| 20 |
void testAllocateWhite(); |
| 21 |
}; |
| 22 |
|
| 23 |
/** 先手番 */ |
| 24 |
template <class Table> |
| 25 |
void DominanceTableTestCommons<Table>::testAllocateBlack() |
| 26 |
{ |
| 27 |
HashEffectState state(CsaString( |
| 28 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 29 |
"P2 * * * * * -GI-KI * *\n" |
| 30 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 31 |
"P4 * * +FU-FU * * * * *\n" |
| 32 |
"P5 * * -KE * +FU * * +FU *\n" |
| 33 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 34 |
"P7 * * -UM * * * * * *\n" |
| 35 |
"P8 * * * * * * * * * \n" |
| 36 |
"P9 * +OU * -GI * * * * -NG\n" |
| 37 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU00FU\n" |
| 38 |
"P-00KI00KY00FU00FU\n" |
| 39 |
"P-00AL\n" |
| 40 |
"+\n").getInitialState()); |
| 41 |
Table table(BLACK); |
| 42 |
const PathEncoding path_black(BLACK); |
| 43 |
const PieceStand white_stand(WHITE, state); |
| 44 |
CheckHashRecord *record = table.allocate(state.getHash(), white_stand, |
| 45 |
path_black); |
| 46 |
CPPUNIT_ASSERT(record); |
| 47 |
CPPUNIT_ASSERT_EQUAL(1u, record->proofDisproof().proof()); |
| 48 |
CPPUNIT_ASSERT_EQUAL(1u, record->proofDisproof().disproof()); |
| 49 |
record->setProofDisproof(3,5); |
| 50 |
|
| 51 |
HashEffectState state2(CsaString( // 先手の歩が1枚少ない |
| 52 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 53 |
"P2 * * * * * -GI-KI * *\n" |
| 54 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 55 |
"P4 * * +FU-FU * * * * *\n" |
| 56 |
"P5 * * -KE * +FU * * +FU *\n" |
| 57 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 58 |
"P7 * * -UM * * * * * *\n" |
| 59 |
"P8 * * * * * * * * * \n" |
| 60 |
"P9 * +OU * -GI * * * * -NG\n" |
| 61 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU\n" |
| 62 |
"P-00KI00KY00FU00FU00FU\n" |
| 63 |
"P-00AL\n" |
| 64 |
"+\n").getInitialState()); |
| 65 |
const PieceStand white_stand2(WHITE, state2); |
| 66 |
CheckHashRecord *record2 = table.allocate(state2.getHash(), white_stand2, |
| 67 |
path_black); |
| 68 |
CPPUNIT_ASSERT(record2); |
| 69 |
CPPUNIT_ASSERT(record2 != record); |
| 70 |
CPPUNIT_ASSERT_EQUAL(3u, record2->proofDisproof().proof()); |
| 71 |
CPPUNIT_ASSERT_EQUAL(1u, record2->proofDisproof().disproof()); |
| 72 |
|
| 73 |
HashEffectState state3(CsaString( // 後手の歩が1枚少ない |
| 74 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 75 |
"P2 * * * * * -GI-KI * *\n" |
| 76 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 77 |
"P4 * * +FU-FU * * * * *\n" |
| 78 |
"P5 * * -KE * +FU * * +FU *\n" |
| 79 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 80 |
"P7 * * -UM * * * * * *\n" |
| 81 |
"P8 * * * * * * * * * \n" |
| 82 |
"P9 * +OU * -GI * * * * -NG\n" |
| 83 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU00FU00FU\n" |
| 84 |
"P-00KI00KY00FU\n" |
| 85 |
"P-00AL\n" |
| 86 |
"+\n").getInitialState()); |
| 87 |
const PieceStand white_stand3(WHITE, state3); |
| 88 |
CheckHashRecord *record3 = table.allocate(state3.getHash(), white_stand3, |
| 89 |
path_black); |
| 90 |
CPPUNIT_ASSERT(record3); |
| 91 |
CPPUNIT_ASSERT(record3 != record); |
| 92 |
CPPUNIT_ASSERT_EQUAL(1u, record3->proofDisproof().proof()); |
| 93 |
CPPUNIT_ASSERT_EQUAL(5u, record3->proofDisproof().disproof()); |
| 94 |
} |
| 95 |
|
| 96 |
/** 後手番 */ |
| 97 |
template <class Table> |
| 98 |
void DominanceTableTestCommons<Table>::testAllocateWhite() |
| 99 |
{ |
| 100 |
HashEffectState state(CsaString( |
| 101 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 102 |
"P2 * * * * * -GI-KI * *\n" |
| 103 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 104 |
"P4 * * +FU-FU * * * * *\n" |
| 105 |
"P5 * * -KE * +FU * * +FU *\n" |
| 106 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 107 |
"P7 * * -UM * * * * * *\n" |
| 108 |
"P8 * * * * * * * * * \n" |
| 109 |
"P9 * +OU * -GI * * * * -NG\n" |
| 110 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU00FU\n" |
| 111 |
"P-00KI00KY00FU00FU\n" |
| 112 |
"P-00AL\n" |
| 113 |
"-\n").getInitialState()); |
| 114 |
const PathEncoding path_white(WHITE); |
| 115 |
const PieceStand white_stand(WHITE, state); |
| 116 |
Table table(WHITE); |
| 117 |
CheckHashRecord *record = table.allocate(state.getHash(), white_stand, |
| 118 |
path_white); |
| 119 |
CPPUNIT_ASSERT(record); |
| 120 |
CPPUNIT_ASSERT_EQUAL(1u, record->proofDisproof().proof()); |
| 121 |
CPPUNIT_ASSERT_EQUAL(1u, record->proofDisproof().disproof()); |
| 122 |
record->setProofDisproof(3,5); |
| 123 |
|
| 124 |
HashEffectState state2(CsaString( // 先手の歩が1枚少ない |
| 125 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 126 |
"P2 * * * * * -GI-KI * *\n" |
| 127 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 128 |
"P4 * * +FU-FU * * * * *\n" |
| 129 |
"P5 * * -KE * +FU * * +FU *\n" |
| 130 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 131 |
"P7 * * -UM * * * * * *\n" |
| 132 |
"P8 * * * * * * * * * \n" |
| 133 |
"P9 * +OU * -GI * * * * -NG\n" |
| 134 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU\n" |
| 135 |
"P-00KI00KY00FU00FU00FU\n" |
| 136 |
"P-00AL\n" |
| 137 |
"-\n").getInitialState()); |
| 138 |
const PieceStand white_stand2(WHITE, state2); |
| 139 |
CheckHashRecord *record2 = table.allocate(state2.getHash(), white_stand2, |
| 140 |
path_white); |
| 141 |
CPPUNIT_ASSERT(record2); |
| 142 |
CPPUNIT_ASSERT(record2 != record); |
| 143 |
CPPUNIT_ASSERT_EQUAL(1u, record2->proofDisproof().proof()); |
| 144 |
CPPUNIT_ASSERT_EQUAL(5u, record2->proofDisproof().disproof()); |
| 145 |
|
| 146 |
HashEffectState state3(CsaString( // 後手の歩が1枚少ない |
| 147 |
"P1+NY+TO * * * * -OU-KE-KY\n" |
| 148 |
"P2 * * * * * -GI-KI * *\n" |
| 149 |
"P3 * +RY * * +UM * -KI-FU-FU\n" |
| 150 |
"P4 * * +FU-FU * * * * *\n" |
| 151 |
"P5 * * -KE * +FU * * +FU *\n" |
| 152 |
"P6-KE * * +FU+GI-FU * * +FU\n" |
| 153 |
"P7 * * -UM * * * * * *\n" |
| 154 |
"P8 * * * * * * * * * \n" |
| 155 |
"P9 * +OU * -GI * * * * -NG\n" |
| 156 |
"P+00HI00KI00KE00KY00FU00FU00FU00FU00FU00FU00FU\n" |
| 157 |
"P-00KI00KY00FU\n" |
| 158 |
"P-00AL\n" |
| 159 |
"-\n").getInitialState()); |
| 160 |
const PieceStand white_stand3(WHITE, state3); |
| 161 |
CheckHashRecord *record3 = table.allocate(state3.getHash(), white_stand3, |
| 162 |
path_white); |
| 163 |
CPPUNIT_ASSERT(record3); |
| 164 |
CPPUNIT_ASSERT(record3 != record); |
| 165 |
CPPUNIT_ASSERT_EQUAL(3u, record3->proofDisproof().proof()); |
| 166 |
CPPUNIT_ASSERT_EQUAL(1u, record3->proofDisproof().disproof()); |
| 167 |
} |
| 168 |
|
| 169 |
#endif /* _DOMINANCETABLETESTCOMMONS_H */ |
| 170 |
// ;;; Local Variables: |
| 171 |
// ;;; mode:c++ |
| 172 |
// ;;; c-basic-offset:2 |
| 173 |
// ;;; End: |