/// <summary> /// returns if the '<paramref name="player"/>' has occupied cells in the corners. /// </summary> /// <param name="gl">The <seealso cref="GameLogic"/> of the game the ai playing. </param> /// <param name="player"></param> /// <param name="corners">returns the specified corners which are occupied.</param> /// <returns></returns> private bool HasInCorner(GameLogic gl, CellE player, out Stack <Position> corners) { GameLogic ex = new GameLogic(gl); corners = new Stack <Position>(); //if (ex.board.board[0, 1].player == player || ex.board.board[1, 2].player == player || ex.board.board[2, 1].player == player || ex.board.board[01, 0].player == player) // return true; if (ex.board.board[0, 0].player == player) { corners.Push(new Position(0, 0)); } if (ex.board.board[2, 2].player == player) { corners.Push(new Position(2, 2)); } if (ex.board.board[2, 0].player == player) { corners.Push(new Position(2, 0)); } if (ex.board.board[0, 2].player == player) { corners.Push(new Position(0, 2)); } if (corners.Count != 0) { return(true); } return(false); }
/// <summary> /// Change the player type that occupies the cell /// </summary> /// <param name="p">type of player to fill with</param> /// <returns>true if cell was empty and succed t change the player type, otherwise return false</returns> public bool ChangePlayer(CellE p) { if (player != CellE.empty) { return(false); } player = p; return(true); }
public AI(Difficulity d, CellE AI = CellE.o, CellE opponent = CellE.x) { difficulity = d; me = AI; him = opponent; if (me == him) { throw new ArgumentException("The AI and the opponent cant be the same sign."); } }
/// <summary> /// returns true if the '<paramref name="player"/>' has occupid cells in the side of the /// board. /// </summary> /// <param name="gl">The <seealso cref="GameLogic"/> of the game the ai playing.</param> /// <param name="player"></param> /// <param name="sides">returns the specified sides which are occupied.</param> /// <returns></returns> private bool HasInSides(GameLogic gl, CellE player, out Stack <Position> sides) { sides = new Stack <Position>(); if (gl.board.board[0, 1].player == player) { sides.Push(new Position(0, 1));// } if (gl.board.board[01, 0].player == player) { sides.Push(new Position(01, 0));// } if (gl.board.board[1, 2].player == player) { sides.Push(new Position(1, 2));// } if (gl.board.board[02, 1].player == player) { sides.Push(new Position(02, 1));// } return(sides.Count != 0); }
/// <summary> /// Create an new cell with the same arritbutes. /// </summary> /// <param name="c">the cell to copy</param> public Cell(Cell c) { position = new Position(c.position); player = c.player; }
public Cell(Position p) { position = p; player = CellE.empty; }
private Position BruteForce(GameLogic gl, CellE me) { return(new Position(-1, -1)); }