public bool TileIsAdjacentTo(Tile.State up, Tile.State left, Tile.State down, Tile.State right) { return(Up == up && Left == left && Down == down && Right == right); }
private void skipTurn(Tile.State turnState) { if (!movePossible(this, turnState)) { switchTurn(); } }
public int numberOfFlips(Tile tile, Tile.State turnState) { check(tile, turnState); int numberOfFlips = tileToFlip.Count; tileToFlip.Clear(); return(numberOfFlips); }
public Board checkAndFlip(Tile tile, Tile.State turn) { if (check(tile, turn)) { Board newBoard = this; newBoard. } }
public bool movePossible(Tile.State turnState) { foreach (Tile individualTile in squares) { if (numberOfFlips(individualTile, turnState) > 0) { return(true); } } return(false); }
void switchTurn() { if (turn == Tile.State.BLACK) { turn = Tile.State.WHITE; } else if (turn == Tile.State.WHITE) { turn = Tile.State.BLACK; } }
public Tile.State Next() { if ((int)Current == Player) { Current = Tile.State.Maru; } else { Current++; } return(Current); }
public int miniMax(Node node, int depth, Tile.State turn) { if (depth == 0 || !node.board.movePossible(turn)) { return(evaluate(node.board)); } if (turn == Tile.State.BLACK) { // MAX int bestValue = -10000000; } else if (turn == Tile.State.WHITE) { // MIN } }
bool tilesToBeFlippedDiagonalUpLeft(int xStart, int yStart, Tile.State turnState) { bool validMove = false; // Returns a list of Tiles to be flipped; empty list if move is not valid. if (!isOnBoard(xStart, yStart)) { return(validMove); } // Check if any tiles to flip going right int x = xStart - 1; int y = yStart - 1; if (isOnBoard(x, y)) { Tile tileUp = squares[x, y]; if (tileUp.CurrentState != turnState && tileUp.CurrentState != Tile.State.FREE) { // There is a piece of opposite color above ours while (tileUp.CurrentState != turnState && tileUp.CurrentState != Tile.State.FREE && validMove == false) { x--; y--; if (isOnBoard(x, y)) { tileUp = squares[x, y]; if (tileUp.CurrentState == turnState) { validMove = true; x++; y++; } } } if (validMove == true) { while (x < xStart && y < yStart) { tileToFlip.Add(squares[x, y]); x++; y++; } } } } return(validMove); }
public BoardProspector(Tile.State owner) { this.owner = owner; //script.LoadFile(Application.dataPath + "/"); /*script.DoString(@" function foo() unity.print('goodie') end ");*/ //script.DoFile(Application.dataPath + "/Resources/MoonSharp/Scripts/BasicAI"); //RegisterEvents(); }
public int CountTile(Tile.State state) { int count = 0; for (int j = 0; j < cols; j++) { for (int i = 0; i < rows; i++) { if (Grid[j, i].CurrentState == state) { count++; } } } return(count); }
public TileManager(int width, int height, int player) { Width = width; Height = height; Player = player; Current = Tile.State.Maru; Tiles = new Tile[height][]; for (var i = 0; i < Height; i++) { Tiles[i] = new Tile[Width]; for (var j = 0; j < Width; j++) { Tiles[i][j] = new Tile(); } } }
void Start() { tilesPlusNeighbours = new Dictionary <Tile, List <Tile> >(); tileToFlip = new List <Tile>(); turn = Tile.State.BLACK; board = this; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { squares[j, i] = Instantiate(prefab).GetComponent <Tile>(); squares [j, i].transform.parent = this.transform; squares[j, i].x = j; squares[j, i].y = i; } } collectNeighbours(squares); Reset(); }
public static string GetLabel(this Tile.State state) { var text = new[] { "", "○", "×", "△", "□", "●", "+", "▲", "■" }; return(text[(int)state]); }
public Controller(Tile.State owner, Board board) { this.board = board; this.owner = owner; }
public int GetMaxLine(Tile.State state) { var maxCount = 0; var count = 0; for (var i = 0; i < Height; i++) { count = 0; for (var j = 0; j < Width; j++) { if (GetTileState(j, i) == state) { count++; } else { maxCount = Math.Max(count, maxCount); count = 0; } } maxCount = Math.Max(count, maxCount); } for (var j = 0; j < Width; j++) { count = 0; for (var i = 0; i < Height; i++) { if (GetTileState(j, i) == state) { count++; } else { maxCount = Math.Max(count, maxCount); count = 0; } } maxCount = Math.Max(count, maxCount); } for (var i = -Height; i < Width + Height; i++) { count = 0; for (var j = -Width; j < Width + Height; j++) { if (GetTileState(j, i + j) == state) { count++; } else { maxCount = Math.Max(count, maxCount); count = 0; } } maxCount = Math.Max(count, maxCount); count = 0; for (var j = -Width; j < Width + Height; j++) { if (GetTileState(j, i - j) == state) { count++; } else { maxCount = Math.Max(count, maxCount); count = 0; } } maxCount = Math.Max(count, maxCount); } return(maxCount); }
internal void SetTileState(int x, int y, Tile.State state) { Board.Single(t => t.X == x && t.Y == y).TileState = state; }
private bool isValidMove(Tile tile, Tile.State turnState) { // If number of flips > 0, return true return(numberOfFlips(tile, turnState) > 0 ? true:false); }
public bool check(Tile tile, Tile.State turn) { return(tilesToBeFlippedUp(tile.x, tile.y, turn) | tilesToBeFlippedDown(tile.x, tile.y, turn) | tilesToBeFlippedLeft(tile.x, tile.y, turn) | tilesToBeFlippedRight(tile.x, tile.y, turn) | tilesToBeFlippedDiagonalUpRight(tile.x, tile.y, turn) | tilesToBeFlippedDiagonalDownRight(tile.x, tile.y, turn) | tilesToBeFlippedDiagonalDownLeft(tile.x, tile.y, turn) | tilesToBeFlippedDiagonalUpLeft(tile.x, tile.y, turn)); }