public void SetGameInfo(int rows, int columns, int piecesToWin, int turn, int timeLimitSeconds) { _game = new Game() { Rows = rows, Columns = columns, PiecesToWin = piecesToWin, TimeLimitSeconds = timeLimitSeconds }; _game.Initialize(); Turn = turn; }
static void PlayGame(System.IO.StreamWriter writer) { Game g = new Game() { Rows = 6, Columns = 7, PiecesToWin = 4, TimeLimitSeconds = 30 }; g.Initialize(); Player p1 = new MinimaxPlayer(Players.Black, Players.Red, "MINIMAX (1)"); p1.SetGameInfo(g.Rows, g.Columns, g.PiecesToWin, 0, g.TimeLimitSeconds); Player p2 = new Player(Players.Red, Players.Black, "SIMPLE (2)"); p2.SetGameInfo(g.Rows, g.Columns, g.PiecesToWin, 1, g.TimeLimitSeconds); GameValueCalculator calc = new GameValueCalculator(g); GameResult result = GameResult.InProgress; while (result == GameResult.InProgress) { int move = p1.GetNextMove(); g.AcceptMove(p1.ID, move); result = calc.EvaluateGameState(); p2.NoteOpponentsMove(move); if (result == GameResult.WinBlack || result == GameResult.WinRed) break; move = p2.GetNextMove(); g.AcceptMove(p2.ID, move); result = calc.EvaluateGameState(); p1.NoteOpponentsMove(move); } Console.WriteLine(string.Format(" --- {0} --- ", result)); g.DisplayBoard(); writer.WriteLine(string.Format(" --- {0} --- ", result)); g.DisplayBoard(writer); }
static void DiagnoseFdUpMoves() { Game g = new Game() { Rows = 6, Columns = 7, PiecesToWin = 4, TimeLimitSeconds = 30000 }; g.Initialize(); g.AcceptMove(Players.Black, 3); g.AcceptMove(Players.Red, 4); g.AcceptMove(Players.Black, 3); g.AcceptMove(Players.Red, 3); MinimaxCs.Minimax m = new MinimaxCs.Minimax(Players.Black); int col = m.MINIMAX_DECISION(g); }
public Game Clone() { Game clone = new Game() { Rows = this.Rows, Columns = this.Columns, PiecesToWin = this.PiecesToWin, TimeLimitSeconds = this.TimeLimitSeconds }; clone.Initialize(); for (int r = 0; r < this.Rows; r++) { for (int c = 0; c < this.Columns; c++) { clone.Board[r, c] = this.Board[r, c]; } } return clone; }
public Game Clone() { Game clone = new Game() { Rows = this.Rows, Columns = this.Columns, PiecesToWin = this.PiecesToWin, TimeLimitSeconds = this.TimeLimitSeconds }; clone.Initialize(); for (int r = 0; r < this.Rows; r++) { for (int c = 0; c < this.Columns; c++) { clone.Board[r, c] = this.Board[r, c]; } } return(clone); }