コード例 #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);
 }
コード例 #2
0
 private void skipTurn(Tile.State turnState)
 {
     if (!movePossible(this, turnState))
     {
         switchTurn();
     }
 }
コード例 #3
0
    public int numberOfFlips(Tile tile, Tile.State turnState)
    {
        check(tile, turnState);
        int numberOfFlips = tileToFlip.Count;

        tileToFlip.Clear();
        return(numberOfFlips);
    }
コード例 #4
0
 public Board checkAndFlip(Tile tile, Tile.State turn)
 {
     if (check(tile, turn))
     {
         Board newBoard = this;
         newBoard.
     }
 }
コード例 #5
0
 public bool movePossible(Tile.State turnState)
 {
     foreach (Tile individualTile in squares)
     {
         if (numberOfFlips(individualTile, turnState) > 0)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
 void switchTurn()
 {
     if (turn == Tile.State.BLACK)
     {
         turn = Tile.State.WHITE;
     }
     else if (turn == Tile.State.WHITE)
     {
         turn = Tile.State.BLACK;
     }
 }
コード例 #7
0
ファイル: TileManager.cs プロジェクト: eyeq/marubatu
 public Tile.State Next()
 {
     if ((int)Current == Player)
     {
         Current = Tile.State.Maru;
     }
     else
     {
         Current++;
     }
     return(Current);
 }
コード例 #8
0
 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
     }
 }
コード例 #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);
    }
コード例 #10
0
ファイル: BoardProspector.cs プロジェクト: Ryxali/Othello
    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();
    }
コード例 #11
0
ファイル: Board.cs プロジェクト: bruceoutdoors/reversi
    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);
    }
コード例 #12
0
ファイル: TileManager.cs プロジェクト: eyeq/marubatu
        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();
                }
            }
        }
コード例 #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();
    }
コード例 #14
0
ファイル: Tile.cs プロジェクト: eyeq/marubatu
        public static string GetLabel(this Tile.State state)
        {
            var text = new[] { "", "○", "×", "△", "□", "●", "+", "▲", "■" };

            return(text[(int)state]);
        }
コード例 #15
0
ファイル: Controller.cs プロジェクト: Ryxali/Othello
 public Controller(Tile.State owner, Board board)
 {
     this.board = board;
     this.owner = owner;
 }
コード例 #16
0
ファイル: TileManager.cs プロジェクト: eyeq/marubatu
        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);
        }
コード例 #17
0
 internal void SetTileState(int x, int y, Tile.State state)
 {
     Board.Single(t => t.X == x && t.Y == y).TileState = state;
 }
コード例 #18
0
 private bool isValidMove(Tile tile, Tile.State turnState)
 {
     // If number of flips > 0, return true
     return(numberOfFlips(tile, turnState) > 0 ? true:false);
 }
コード例 #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));
 }