Exemplo n.º 1
0
 public DebugInfosForEachTurn(DebugInfosForEachTurn debugInfosForEachTurn)
 {
     Nash    = debugInfosForEachTurn.Nash;
     Humans  = debugInfosForEachTurn.Humans;
     Zombies = debugInfosForEachTurn.Zombies;
     Points  = debugInfosForEachTurn.Points;
     Move    = debugInfosForEachTurn.Move;
     NumTurn = debugInfosForEachTurn.NumTurn;
 }
Exemplo n.º 2
0
        public static void WriteSimulTurnInfos(DebugInfosForEachTurn turnInfos, int debugLevel)
        {
            var strings = new string[]
            {
                $"turnInfos.NumTurn [{turnInfos.NumTurn}] ",
                $"turnInfos.Humans.Count [{turnInfos.Humans.Count}] ",
                $"turnInfos.Zombies.Count [{turnInfos.Zombies.Count}] ",
                $"turnInfos.Points [{turnInfos.Points}] ",
                $"turnInfos.Move [{turnInfos.Move}] "
            };

            WriteDebugMessage("WriteSimulTurnInfos", strings, debugLevel);
        }
Exemplo n.º 3
0
        private SimulationResult SimulateGame(GameTurnInfos infosTurn, GameInfosForDebug gameInfosDebug)
        {
            var rand           = new Random();
            var sr             = new SimulationResult();
            var simInfos       = new SimulationInfos();
            var moves          = new List <Tuple <int, int> >();
            var gameDebug      = new GameInfosForDebug();
            var turnInfosDebug = new DebugInfosForEachTurn();

            simInfos.SimStartingRandomMovesNum = rand.Next(GameInfos.MAX_SIMULATION_RANDOM_STARTING_MOVES + 1);

            ComputePlayerTarget(infosTurn, simInfos);

            while (!simInfos.SimZombieAllDead && !simInfos.SimFailure && simInfos.SimMovesCount < GameInfos.MAX_MOVES)
            {
                // Simulate a turn of the game.
                simInfos.Moves.Add(Turn(infosTurn, sr, simInfos));

    #if DEBUG_MODE
                turnInfosDebug.Nash = infosTurn.Nash;
                turnInfosDebug.SetHumansOrZombies(infosTurn.Humans);
                turnInfosDebug.SetHumansOrZombies(infosTurn.Zombies);
                turnInfosDebug.Points  = sr.Points;
                turnInfosDebug.Move    = simInfos.Moves.Last();
                turnInfosDebug.NumTurn = simInfos.SimMovesCount;
                gameDebug.DebugInfosForTurn.Add(new DebugInfosForEachTurn(turnInfosDebug));
    #endif

                simInfos.SimMovesCount++;
            }

            if (simInfos.SimZombieAllDead &&
                !simInfos.SimFailure &&
                ((sr.Points + ActualScore) > BestSimulation.SimPoints ||
                 (sr.Points + ActualScore) == BestSimulation.SimPoints && (simInfos.SimMovesCount < (BestSimulation.SimMovesCount - NumTurn))))
            {
                simInfos.SimPoints = sr.Points + ActualScore;
                BestSimulation     = simInfos;
                NewBest            = true;
    #if DEBUG_MODE
                gameInfosDebug.SetDebugInfosForTurn(gameDebug.DebugInfosForTurn);
    #endif
            }

            return(sr);
        }