/// <summary> /// Initializes a new game phase. The phase contains controls the simulation and subsequently logs the data gathered. /// </summary> /// <param name="BoardSize">Integer representing the board width and height. The integer squared will be the board size.</param> /// <param name="Straight">Amount of straight type labyrinth pieces.</param> /// <param name="Corner">Amount of corner type labyrinth pieces.</param> /// <param name="TSplit">Amount of T-Split type labyrinth pieces.</param> /// <param name="Reserves">Amount of reserve blocks.</param> /// <param name="PlayerColors">An array of player colours. The length should be between 1 and 4.</param> /// <param name="Chance">Percentage chance that a player will answer the question correctly.</param> /// <param name="Runs">Amount of games the simulator will run.</param> /// <param name="TurnTime">The amount of time a turn would take given in seconds.</param> internal PhaseController(Commands coms, int[] BoardData, Color[] PlayerColors, string[] Colors, string[] PlayerNames, int[] PlayerChances, int Runs, int VisualRuns, int TurnTime, int TimeOut ) { // Set all constants DoneSimulating = new ManualResetEvent(false); this.GameData = BoardData; this.PlayerData = PlayerColors; this.PlayerChances = PlayerChances; this.GameRuns = Runs; this.VisualRuns = VisualRuns; this.TurnTime = TurnTime; this.Coms = coms; this.PlayerNameHistory = PlayerNames; this.TimeOut = TimeOut; // Setup logger and template Logger = new CsvLogger(DateTime.Now.ToString("dd-MM-yyyy, HH;mm;ss")); Logger.CreateTemplate(BoardData, GameRuns, VisualRuns, TurnTime, Colors, PlayerNames,PlayerChances, DoneSimulating); // If visual simulation is enabled, initialize queues. if(VisualRuns > 0) { TurnCountHistory = new Queue<int>(); BoardHistory = new Queue<LabyrinthBlock[,]>(); ReserveHistory = new Queue<LabyrinthBlock[]>(); PlayerHistory = Colors; MoveHistory = new Queue<List<Tuple<string, string, string>>>(); } }
public CommandHandler(Commands DelegateClass) { this.Coms = DelegateClass; AvailableCommands = new Dictionary<string, Action<string[]>>(StringComparer.OrdinalIgnoreCase) { { "?", ShowCommands }, { "Resize", Resize }, { "Scale", Scale }, { "AnimationSpeed", AnimationSpeed }, { "Interval", Interval }, { "SkipSimulation", SkipSimulation }, { "Pause", Pause }, { "UnPause", UnPause }, { "Background", BackgroundColor } }; CommandSynonyms = new Dictionary<string, Action<string[]>>(StringComparer.OrdinalIgnoreCase) { { "simulationspeed", AnimationSpeed }, { "skip", SkipSimulation } }; }
// Console Color Guide : // Green : Controller related output. // Yellow : Game back end related output. // Magenta : Variable information ( Non critical ) // Red : Errors ( Critical ) && Critical information internal static void Main(string[] args) { Console.Title = "A-Maze-ing simulator"; HandleInput.PrintColor("Controller started", ConsoleColor.Green); // Create new commands object to control the visual simulator if applicable. Commands Coms = new Commands(); // Create all data for the simulation. var BoardData = GameCreation.CreateBoardData(); var PlayerData = GameCreation.CreatePlayerData(); var SimulationData = GameCreation.CreateSimulationData(); // Create a simulation phase var Phase = new PhaseController(Coms, BoardData, PlayerData.Item1, PlayerData.Item2, PlayerData.Item3, PlayerData.Item4, SimulationData[0], SimulationData[1], SimulationData[2], SimulationData[3]); // Run simulation Phase.RunSimulation(); Console.ReadLine(); }