コード例 #1
0
ファイル: BotRecord.cs プロジェクト: NaitCTClub/RoboChess
        public static void AddRecord(this BotController bot, GameStat results)
        {
            bot.Record.BotBrain = bot;

            if (results.Result == GameResult.BoardFlipped)
            {
                return; //Game ended prematurely
            }
            if (results.Result == GameResult.Draw || results.Winner is null)
            {
                bot.Record.Draws++; // Draw
            }
            else if (results.Winner.BotBrain is null)
            {
                bot.Record.Losses++;                                          // Winner is a Human
            }
            else if (results.Winner.BotBrain.GetType().Equals(bot.GetType())) // I am the Winner!!
            {
                if (results.Result == GameResult.CheckMate)
                {
                    bot.Record.CheckMates++;
                }
                else if (results.Result == GameResult.StaleMate)
                {
                    bot.Record.StaleMates++;
                }
            }
            else
            {
                bot.Record.Losses++; // Loser...
            }

            bot.Record.MovesAvg = (bot.Record.MovesAvg + (results.BoardArchive.Moves_Index / 2)) / 2;
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: NaitCTClub/RoboChess
        //==============================================================================
        //                                  The End
        //==============================================================================
        public void Fin()
        {
            Player winner = LiveBoard.PlayerOne == WhosTurn ? LiveBoard.PlayerTwo : LiveBoard.PlayerOne;
            Player loser  = LiveBoard.PlayerOne == WhosTurn? LiveBoard.PlayerOne : LiveBoard.PlayerTwo;
            string result;

            if (LiveBoard.Result == GameResult.BoardFlipped)
            {
                result = $"{LiveBoard.Result}! We will never Know..";
            }
            else if (LiveBoard.Result == GameResult.Draw)
            {
                result = $"Draw. No end game here.";
            }
            else
            {
                result = $"{LiveBoard.Result}! {winner} Wins! {LiveBoard.MoveArchive.Count / 2} moves";
            }

            GUI.RenameHeader(result);
            GUI.lbMoves.Items.Insert(0, $"Game Complete - {result}");
            GUI.lbMoves.Items.Insert(0, "");
            GUI._lbErrors.Items.Insert(0, $"Game Complete - {result}");

            if (!nGamesOn)
            {
                GUI.SetWindow_NoGameInProgress();
            }
            if (ViewBotsEnd)
            {
                LiveBoard.UpdateBoardGUI();
            }

            GameStat newGameStat = new GameStat(LiveBoard);

            GameStats.Add(newGameStat);

            if (winner.isBot)
            {
                winner.BotBrain.AddRecord(newGameStat);
            }
            if (loser.isBot)
            {
                loser.BotBrain.AddRecord(newGameStat);
            }

            //Bind the DataGrid to the Bot Records
            GUI.DG1.DataContext = BotController.GetBotRecords();

            if (nGamesOn)
            {
                GUI._txtNGames.Text = (int.Parse(GUI._txtNGames.Text) - 1).ToString();
            }

            GameOnView = false;
        }