Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "SgSystem.h"
00007 #include "SpLadderPlayer.h"
00008
00009 #include "GoLadder.h"
00010 #include "GoMoveExecutor.h"
00011 #include "GoModBoard.h"
00012 #include "SgConnCompIterator.h"
00013 #include "SgEvaluatedMoves.h"
00014
00015 using GoLadderUtil::LadderStatus;
00016
00017
00018
00019 int SpLadderMoveGenerator::Score(SgPoint p)
00020 {
00021 SG_UNUSED(p);
00022
00023
00024 SG_ASSERT(false);
00025 return INT_MIN;
00026 }
00027
00028 void SpLadderMoveGenerator::GenerateMoves(SgEvaluatedMoves& eval,
00029 SgBlackWhite toPlay)
00030 {
00031 GoModBoard modBoard(m_board);
00032 GoBoard& bd = modBoard.Board();
00033
00034 GoRestoreToPlay restoreToPlay(bd);
00035 bd.SetToPlay(toPlay);
00036 GoRestoreSuicide restoreSuicide(bd, false);
00037 for (SgBlackWhite color = SG_BLACK; color <= SG_WHITE; ++color)
00038 {
00039 for (SgConnCompIterator it(bd.All(color), bd.Size());
00040 it; ++it)
00041 {
00042 SgPointSet block(*it);
00043 SgPoint p = block.PointOf(), toCapture, toEscape;
00044 GoLadderStatus st = LadderStatus(bd, p, false, &toCapture,
00045 &toEscape);
00046 if (st == GO_LADDER_UNSETTLED)
00047 {
00048 SgPoint move =
00049 color == bd.ToPlay() ? toEscape : toCapture;
00050 int size = 1000 * block.Size();
00051 eval.AddMove(move, size);
00052 if ((color == bd.ToPlay()) && (move == SG_PASS))
00053 {
00054
00055 for (GoBoard::LibertyIterator it(bd, p); it; ++it)
00056 {
00057 SgPoint lib = *it;
00058 GoMoveExecutor m(bd, lib, color);
00059 if (m.IsLegal() && bd.Occupied(p))
00060 {
00061 SgPoint toCapture2, toEscape2;
00062 GoLadderStatus st2 =
00063 LadderStatus(bd, p, false, &toCapture2,
00064 &toEscape2);
00065 if (st2 == GO_LADDER_ESCAPED)
00066 eval.AddMove(lib, size);
00067 }
00068 }
00069 }
00070 }
00071 }
00072 }
00073 }
00074
00075
00076