Example #1
0
 public bool TileIsAdjacentTo(Tile.State up, Tile.State left, Tile.State down, Tile.State right)
 {
     return(Up == up &&
            Left == left &&
            Down == down &&
            Right == right);
 }
Example #2
0
 private void skipTurn(Tile.State turnState)
 {
     if (!movePossible(this, turnState))
     {
         switchTurn();
     }
 }
Example #3
0
    public int numberOfFlips(Tile tile, Tile.State turnState)
    {
        check(tile, turnState);
        int numberOfFlips = tileToFlip.Count;

        tileToFlip.Clear();
        return(numberOfFlips);
    }
Example #4
0
 public Board checkAndFlip(Tile tile, Tile.State turn)
 {
     if (check(tile, turn))
     {
         Board newBoard = this;
         newBoard.
     }
 }
Example #5
0
 public bool movePossible(Tile.State turnState)
 {
     foreach (Tile individualTile in squares)
     {
         if (numberOfFlips(individualTile, turnState) > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Example #6
0
 void switchTurn()
 {
     if (turn == Tile.State.BLACK)
     {
         turn = Tile.State.WHITE;
     }
     else if (turn == Tile.State.WHITE)
     {
         turn = Tile.State.BLACK;
     }
 }
Example #7
0
 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
     }
 }
Example #9
0
    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);
    }
Example #10
0
    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();
    }
Example #11
0
    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);
    }
Example #12
0
        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();
                }
            }
        }
Example #13
0
    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();
    }
Example #14
0
        public static string GetLabel(this Tile.State state)
        {
            var text = new[] { "", "○", "×", "△", "□", "●", "+", "▲", "■" };

            return(text[(int)state]);
        }
Example #15
0
 public Controller(Tile.State owner, Board board)
 {
     this.board = board;
     this.owner = owner;
 }
Example #16
0
        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);
        }
Example #17
0
 internal void SetTileState(int x, int y, Tile.State state)
 {
     Board.Single(t => t.X == x && t.Y == y).TileState = state;
 }
Example #18
0
 private bool isValidMove(Tile tile, Tile.State turnState)
 {
     // If number of flips > 0, return true
     return(numberOfFlips(tile, turnState) > 0 ? true:false);
 }
Example #19
0
 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));
 }