Пример #1
0
        public GoGame(GoGameInfo info)
        {
            GameInfo   = info;
            Clock      = new GoClock(GameInfo.TimeSettings);
            Tree       = new GoGameTree();
            Board      = new GoBoard(GameInfo.Size, GameInfo.Handicap);
            Turns      = new List <GoTurn>();
            KoPoint    = null;
            IsGameOver = false;
            GameRule   = RulesType.normal;
            NumberOfStonesToCapture = 5;

            m_currentTurn = 0;
            m_colorToMove = GameInfo.Handicap < 2 ? GoColor.BLACK : GoColor.WHITE;
        }
Пример #2
0
        public GoGame(GoGameInfo info)
        {
            GameInfo = info;
            Clock = new GoClock(GameInfo.TimeSettings);
            Tree = new GoGameTree();
            Board = new GoBoard(GameInfo.Size, GameInfo.Handicap);
            Turns = new List<GoTurn>();
            KoPoint = null;
            IsGameOver = false;
            GameRule = RulesType.normal;
            NumberOfStonesToCapture = 5;

            m_currentTurn = 0;
            m_colorToMove = GameInfo.Handicap < 2 ? GoColor.BLACK : GoColor.WHITE;
        }
Пример #3
0
        public void ClearBoard(int handicap, int minutes, bool isTwoHumanPlayers, int boardSize)
        {
            // set the game settings
            m_gameInfo = new GoGameInfo();
            m_gameInfo.Size = boardSize;
            m_gameInfo.Komi = 0.0f;
            m_gameInfo.Handicap = handicap;
            m_gameInfo.TimeSettings.MainTime = new TimeSpan(0, minutes, 0);
            m_gameInfo.TimeSettings.Byoyomi = new TimeSpan(0, 0, 5);
            m_gameInfo.TimeSettings.NumberOfMovesPerByoyomi = 1;

            m_game = new GoGame(m_gameInfo);
            m_game.GameIsOver += m_game_GameIsOver;

            StartPachi();

            if (m_gtpEngine != null)
            {
                if (!isTwoHumanPlayers)
                {
                    m_gtpEngine.SetGameInfo(m_gameInfo);
                }
            }
        }
Пример #4
0
        public void SetGameInfo(GoGameInfo gameInfo)
        {
            SendCommand(String.Format("boardsize {0}", gameInfo.Size));
            SendCommand("clear_board");
            SendCommand(String.Format("komi {0}", gameInfo.Komi));
            SendCommand(String.Format("time_settings {0} {1} {2}"
                , gameInfo.TimeSettings.MainTime.TotalSeconds
                , gameInfo.TimeSettings.Byoyomi.TotalSeconds
                , gameInfo.TimeSettings.NumberOfMovesPerByoyomi));

            if (gameInfo.Handicap > 0)
            {
                //private static String[] HandicapPoint = { "C3", "G7", "C7", "G3", "E5", "C5", "G5", "E3", "E7" };
                String handicapCommand = "set_free_handicap ";
                if (gameInfo.Size == 9)
                {
                    switch (gameInfo.Handicap)
                    {
                        case 2: handicapCommand += "C3 G7"; break;
                        case 3: handicapCommand += "C3 G7 G3"; break;
                        case 4: handicapCommand += "C3 G7 G3 C7"; break;
                        case 5: handicapCommand += "C3 G7 G3 C7 E5"; break;
                        case 6: handicapCommand += "C3 G7 G3 C7 C5 G5"; break;
                        case 7: handicapCommand += "C3 G7 G3 C7 E5 C5 G5"; break;
                        case 8: handicapCommand += "C3 G7 G3 C7 C5 G5 E3 E7"; break;
                        case 9: handicapCommand += "C3 G7 G3 C7 E5 C5 G5 E3 E7"; break;
                        default:
                            // unhandle case
                            handicapCommand = String.Empty;
                            break;
                    }
                }
                else if (gameInfo.Size == 13)
                {
                    switch (gameInfo.Handicap)
                    {
                        case 2: handicapCommand += "D4 K10"; break;
                        case 3: handicapCommand += "D4 K10 K4"; break;
                        case 4: handicapCommand += "D4 K10 K4 D10"; break;
                        case 5: handicapCommand += "D4 K10 K4 D10 G7"; break;
                        case 6: handicapCommand += "D4 K10 K4 D10 D7 K7"; break;
                        case 7: handicapCommand += "D4 K10 K4 D10 G7 D7 K7"; break;
                        case 8: handicapCommand += "D4 K10 K4 D10 D7 K7 G4 G10"; break;
                        case 9: handicapCommand += "D4 K10 K4 D10 G7 D7 K7 G4 G10"; break;
                        default:
                            // unhandle case
                            handicapCommand = String.Empty;
                            break;
                    }
                }

                SendCommand(handicapCommand);
            }
        }
Пример #5
0
        public void SetGameInfo(GoGameInfo gameInfo)
        {
            SendCommand(String.Format("boardsize {0}", gameInfo.Size));
            SendCommand("clear_board");
            SendCommand(String.Format("komi {0}", gameInfo.Komi));
            SendCommand(String.Format("time_settings {0} {1} {2}"
                                      , gameInfo.TimeSettings.MainTime.TotalSeconds
                                      , gameInfo.TimeSettings.Byoyomi.TotalSeconds
                                      , gameInfo.TimeSettings.NumberOfMovesPerByoyomi));

            if (gameInfo.Handicap > 0)
            {
                //private static String[] HandicapPoint = { "C3", "G7", "C7", "G3", "E5", "C5", "G5", "E3", "E7" };
                String handicapCommand = "set_free_handicap ";
                if (gameInfo.Size == 9)
                {
                    switch (gameInfo.Handicap)
                    {
                    case 2: handicapCommand += "C3 G7"; break;

                    case 3: handicapCommand += "C3 G7 G3"; break;

                    case 4: handicapCommand += "C3 G7 G3 C7"; break;

                    case 5: handicapCommand += "C3 G7 G3 C7 E5"; break;

                    case 6: handicapCommand += "C3 G7 G3 C7 C5 G5"; break;

                    case 7: handicapCommand += "C3 G7 G3 C7 E5 C5 G5"; break;

                    case 8: handicapCommand += "C3 G7 G3 C7 C5 G5 E3 E7"; break;

                    case 9: handicapCommand += "C3 G7 G3 C7 E5 C5 G5 E3 E7"; break;

                    default:
                        // unhandle case
                        handicapCommand = String.Empty;
                        break;
                    }
                }
                else if (gameInfo.Size == 13)
                {
                    switch (gameInfo.Handicap)
                    {
                    case 2: handicapCommand += "D4 K10"; break;

                    case 3: handicapCommand += "D4 K10 K4"; break;

                    case 4: handicapCommand += "D4 K10 K4 D10"; break;

                    case 5: handicapCommand += "D4 K10 K4 D10 G7"; break;

                    case 6: handicapCommand += "D4 K10 K4 D10 D7 K7"; break;

                    case 7: handicapCommand += "D4 K10 K4 D10 G7 D7 K7"; break;

                    case 8: handicapCommand += "D4 K10 K4 D10 D7 K7 G4 G10"; break;

                    case 9: handicapCommand += "D4 K10 K4 D10 G7 D7 K7 G4 G10"; break;

                    default:
                        // unhandle case
                        handicapCommand = String.Empty;
                        break;
                    }
                }

                SendCommand(handicapCommand);
            }
        }