本文整理汇总了C++中MoveList::IsLegal方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::IsLegal方法的具体用法?C++ MoveList::IsLegal怎么用?C++ MoveList::IsLegal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::IsLegal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PerformIntegrityCheck
void PerformIntegrityCheck (
LearnTree &tree,
INT32 baseOffset )
{
char temp [256];
assert (EditBoard != NULL);
assert (UnmoveTable != NULL);
int ply = EditBoard->GetCurrentPlyNumber();
assert ( ply == EditPly );
MoveList ml;
EditBoard->GenMoves (ml);
if ( ml.num == 0 || EditBoard->IsDefiniteDraw() )
return;
LearnBranch branch;
for ( INT32 offset = baseOffset; offset >= 0; offset = branch.sibling )
{
int ignoreNode = 0;
if ( !tree.read(offset,branch) )
{
lprintf ( "Error reading branch at offset %ld\n", long(offset) );
return;
}
++branch.reserved[0];
tree.write(offset,branch);
if ( !ml.IsLegal(branch.move) )
{
ignoreNode = 1;
if ( branch.move.source != 0 )
{
IllegalMoveFormat ( branch.move, temp );
lprintf ( "Illegal move=%s offset=%ld path=",
temp, long(offset) );
DumpMovePath();
lprintf ( "\n" );
}
}
if ( branch.child >= 0 && !ignoreNode )
{
MoveTable[EditPly] = branch.move;
EditBoard->MakeMove ( branch.move, UnmoveTable[EditPly] );
EditOffset[EditPly] = offset;
EditOffset[++EditPly] = branch.child;
PerformIntegrityCheck ( tree, branch.child );
--EditPly;
EditBoard->UnmakeMove ( branch.move, UnmoveTable[EditPly] );
}
}
EditOffset[EditPly] = baseOffset;
}
示例2: ListBranches
void ListBranches()
{
assert (EditBoard != NULL);
Edit_DrawBoard (*EditBoard);
MoveList ml;
EditBoard->GenMoves (ml);
if ( ml.num == 0 || EditBoard->IsDefiniteDraw() )
{
printf ( ">>> At end of game.\n" );
return;
}
LearnTree tree;
if ( !OpenForRead(tree) )
return;
LearnBranch branch;
int ordinal = 0;
for ( INT32 offset = EditOffset[EditPly]; offset >= 0; ++ordinal )
{
printf ( "%3d. ", ordinal );
if ( !tree.read(offset,branch) )
{
printf ( "<!!! error reading branch at offset=%ld !!!>\n", long(offset) );
break;
}
char temp [256];
if ( ml.IsLegal(branch.move) )
FormatChessMove ( *EditBoard, branch.move, temp );
else
IllegalMoveFormat ( branch.move, temp );
if ( branch.move.source == 0 )
{
printf ( "[deleted] %09ld\n", long(offset) );
}
else
{
printf ( "%c %-10s %09ld: s=%-6d t=%-5.1lf WL=%-5d e=%-8ld a=%-4ld\n",
(branch.child == -1) ? ' ' : '*',
temp,
long(offset),
int(branch.move.score),
double(branch.timeAnalyzed) / 100.0,
long(branch.winsAndLosses),
long(branch.nodesEvaluated),
long(branch.numAccesses) );
}
offset = branch.sibling;
}
}
示例3: DumpMovePath
void DumpMovePath()
{
MoveList ml;
ChessBoard board;
int outOfWhack = 0;
lprintf ( "\n{" );
int col = 1;
for ( int i=0; i < EditPly; ++i )
{
if ( !outOfWhack )
{
board.GenMoves (ml);
if ( !ml.IsLegal(MoveTable[i]) )
outOfWhack = 1;
}
if ( i > 0 )
col += lprintf ( "," );
if ( col > 50 )
{
lprintf ( "\n" );
col = 0;
}
char moveString [64];
if ( outOfWhack )
IllegalMoveFormat ( MoveTable[i], moveString );
else
FormatChessMove ( board, MoveTable[i], moveString );
col += lprintf ( " %s", moveString );
UnmoveInfo unmove;
board.MakeMove ( MoveTable[i], unmove );
}
lprintf ( " }\n" );
}
示例4: FindPathToOffset
int FindPathToOffset ( LearnTree &tree, INT32 current, INT32 target )
{
static char errorBuffer [128];
MoveList ml;
EditBoard->GenMoves(ml);
LearnBranch branch;
for ( INT32 offset = current; offset >= 0; offset = branch.sibling )
{
if ( offset == target )
return 1; // found it!
if ( !tree.read(offset,branch) )
{
sprintf ( errorBuffer, "Cannot read offset %ld", long(offset) );
throw errorBuffer;
}
if ( branch.child >= 0 && ml.IsLegal(branch.move) )
{
MoveTable[EditPly] = branch.move;
EditBoard->MakeMove ( branch.move, UnmoveTable[EditPly] );
EditOffset[++EditPly] = branch.child;
int found = FindPathToOffset ( tree, branch.child, target );
if ( found )
return 1;
--EditPly;
EditBoard->UnmakeMove ( branch.move, UnmoveTable[EditPly] );
}
}
return 0;
}
示例5: ETEC_move
int ETEC_move ( int argc, const char *argv[] )
{
assert (EditBoard != NULL);
assert (UnmoveTable != NULL);
int ply = EditBoard->GetCurrentPlyNumber();
assert ( ply == EditPly );
MoveList ml;
EditBoard->GenMoves (ml);
if ( ml.num == 0 || EditBoard->IsDefiniteDraw() )
{
printf ( ">>> At end of game.\n" );
return 0;
}
if ( argc != 2 )
{
fprintf ( stderr, "Use: move Ordinal\n" );
return 0;
}
int seekord = 0;
if ( sscanf(argv[1],"%d",&seekord) != 1 || seekord < 0 )
{
fprintf ( stderr, "Invalid integer argument '%s'\n", argv[1] );
return 0;
}
if ( EditOffset[EditPly] == -1 )
{
printf ( ">>> At leaf of experience tree.\n" );
return 0;
}
LearnTree tree;
if ( !OpenForRead(tree) )
return 1;
LearnBranch branch;
int ordinal = 0;
for ( INT32 offset = EditOffset[EditPly]; offset >= 0; ++ordinal )
{
if ( !tree.read(offset,branch) )
{
fprintf ( stderr, "!!! Error reading offset %ld !!!\n", long(offset) );
return 0;
}
if ( seekord == ordinal )
{
if ( ml.IsLegal(branch.move) )
{
MoveTable[EditPly] = branch.move;
EditBoard->MakeMove ( branch.move, UnmoveTable[EditPly] );
EditOffset[++EditPly] = branch.child;
ListBranches();
}
else
{
char temp [64];
IllegalMoveFormat ( branch.move, temp );
fprintf ( stderr, "!!! Error: illegal move %s at offset %ld\n",
temp,
long(offset) );
}
break;
}
offset = branch.sibling;
}
return 0;
}