private Game(Game other) : this(other.RowCount, other.ColumnCount, other.WinningPaths, other.ValidMoves) { foreach (Cell cell in Cells()) { this[cell] = other[cell]; } _currentPlayerIndex = other._currentPlayerIndex; }
public void Play(Game game) { if (game.IsBoardFull) { throw new InvalidOperationException("Board is full"); } GameDecisionNode decision = new GameDecisionNode(game); decision.BuildTree(maxDepth: 3); var move = decision.Children.OrderByDescending(c => c.CalculateValue(game.CurrentPlayer)).FirstOrDefault(); if (move != null) { //var value = move.Value; //move = decision.Children.Where(v => v.Value == value).Random(); game.Play(move.Cell); } else { PickRandomMove(game); } }
private void PickRandomMove(Game game) { var rnd = new Random(); var cell = game.Cells().Where(c => game[c] == BlockState.Empty).Random(); game.Play(cell); }
public IGame PlayInCopy(Cell cell) { Game result = new Game(this); result.Play(cell); return result; }
public virtual void Start(Game game) { if (OwnedGames.Contains(game)) { game.Start(); } }
public virtual void Join(Game game) { game.AddPlayer(this); }
public virtual Game CreateGame(string gameName) { var game = new Game(gameName, this); OwnedGames.Add(game); return game; }