00001 //---------------------------------------------------------------------------- 00002 /** @file GoGtpCommandUtil.h 00003 Utils for Go GTP commands */ 00004 //---------------------------------------------------------------------------- 00005 00006 #ifndef GO_GTPCOMMANDUTIL_H 00007 #define GO_GTPCOMMANDUTIL_H 00008 00009 #include <cstddef> 00010 #include "SgBlackWhite.h" 00011 #include "SgBoardColor.h" 00012 #include "SgPoint.h" 00013 #include "SgVector.h" 00014 00015 class GtpCommand; 00016 class GoBoard; 00017 template<typename T> class SgPointArray; 00018 00019 //---------------------------------------------------------------------------- 00020 00021 namespace GoGtpCommandUtil 00022 { 00023 00024 SgEmptyBlackWhite EmptyBlackWhiteArg(const GtpCommand& cmd, 00025 std::size_t number); 00026 00027 SgBlackWhite BlackWhiteArg(const GtpCommand& cmd, std::size_t number); 00028 00029 SgPoint EmptyPointArg(const GtpCommand& cmd, std::size_t number, 00030 const GoBoard& board); 00031 00032 /** Return the handicap stone locations as defined by the GTP standard. 00033 See GTP version 2 specification, section 4.1.1 Fixed Handicap 00034 Placement. 00035 @param size Size of the board. 00036 @param n Number of handicap stones (0, 2, 3, 4, 5, 6, 7, 8, 9). 00037 @returns Location of the handicap stones. 00038 @throws GtpFailure If handicap locations are not defined for this 00039 number and board size. */ 00040 SgVector<SgPoint> GetHandicapStones(int size, int n); 00041 00042 SgMove MoveArg(const GtpCommand& cmd, std::size_t number, 00043 const GoBoard& board); 00044 00045 /** Parse argument list consisting of toPlay followed by list of stones. 00046 All stones are of the same 'defender' color. */ 00047 void ParseMultiStoneArgument(GtpCommand& cmd, 00048 const GoBoard& board, 00049 SgBlackWhite& toPlay, 00050 SgBlackWhite& defender, 00051 SgVector<SgPoint>& crucial); 00052 00053 SgPoint PointArg(const GtpCommand& cmd, const GoBoard& board); 00054 00055 SgPoint PointArg(const GtpCommand& cmd, std::size_t number, 00056 const GoBoard& board); 00057 00058 /** Return point list argument starting a given argument number to the 00059 end of arguments. */ 00060 SgVector<SgPoint> PointListArg(const GtpCommand& cmd, std::size_t number, 00061 const GoBoard& board); 00062 00063 /** Return point list argument using all arguments. */ 00064 SgVector<SgPoint> PointListArg(const GtpCommand& cmd, 00065 const GoBoard& board); 00066 00067 void RespondNumberArray(GtpCommand& cmd, const SgPointArray<int>& array, 00068 int scale, const GoBoard& board); 00069 00070 /** Sort response to gogui-analyze_commands alphabetically by label. 00071 Useful if the response to gogui-analyze_commands was concatenated 00072 from different components and should be displayed alphabetically. 00073 @param response Old response in the format expected by 00074 gogui-analyze_commands 00075 @return New response, lines sorted by analyze label */ 00076 std::string SortResponseAnalyzeCommands(const std::string& response); 00077 00078 SgPoint StoneArg(const GtpCommand& cmd, std::size_t number, 00079 const GoBoard& board); 00080 } 00081 00082 inline SgVector<SgPoint> GoGtpCommandUtil::PointListArg(const GtpCommand& cmd, 00083 const GoBoard& board) 00084 { 00085 return PointListArg(cmd, 0, board); 00086 } 00087 00088 //---------------------------------------------------------------------------- 00089 00090 #endif // GO_GTPCOMMANDUTIL_H 00091