Beispiel #1
0
        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;
        }
Beispiel #2
0
 public Player(Player livePlayer) // Virtual Player
 {
     isVirtual = true;
     isBot     = true;
     BotBrain  = livePlayer.BotBrain;
     TeamColor = livePlayer.TeamColor;
     Name      = livePlayer.Name;
 }
Beispiel #3
0
        //==============================================================================
        //                                  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;
        }
Beispiel #4
0
        public bool BotThePlayer(string botName, Board liveBoard)
        {
            if (botName is null || liveBoard is null)
            {
                return(false);
            }

            BotBrain = BotController.MatchBotBrain(botName);
            isBot    = true;

            return(true);
        }
Beispiel #5
0
 public Controller(MainWindow gui)
 {
     BotRecords = BotController.GetBotRecords();
     GUI        = gui;
 }