Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoGtpCommandUtil.h

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


17 Jun 2010 Doxygen 1.4.7