Exemple #1
0
        public void PrintBoard(Board board)
        {
            Clear();
            Square[,] boardToPrint = board.ocean;
            Square       s          = new Square(11, 11);
            string       water      = s.GetCharacter().ToString();
            ConsoleColor waterColor = s.GetColore();

            Console.WriteLine("    A B C D E F G H I J ");
            for (int i = 0; i < boardToPrint.GetLength(0); i++)
            {
                if (i >= board.Size - 1)
                {
                    Console.Write($" {i + 1} ");
                }
                else
                {
                    Console.Write($"  {i + 1} ");
                }

                for (int j = 0; j < boardToPrint.GetLength(1); j++)
                {
                    if (boardToPrint[j, i].Status == Square.SquareStatus.ship)
                    {
                        Print($"{water} ", waterColor);
                    }
                    else
                    {
                        Print($"{boardToPrint[j, i].GetCharacter()} ", boardToPrint[j, i].GetColore());
                    }
                }
                Console.WriteLine();
            }
        }
    private static Square[,] FindWastlends(Square[,] squareMatrix, int houseCount)
    {
        int counter = 0;

        for (int i = 0; i < squareMatrix.GetLength(0); i++)
        {
            for (int j = 0; j < squareMatrix.GetLength(1); j++)
            {
                if (i != 0 && j != 0 && squareMatrix[i, j].CurentPrefab == Prefab.Wasteland)
                {
                    if (CheckAround(squareMatrix, i, j))
                    {
                        squareMatrix [i, j] = new Square(0, Prefab.House, Direction.None);
                        counter++;
                    }
                }

                if (counter == houseCount)
                {
                    return(squareMatrix);
                }
            }
        }

        return(squareMatrix);
    }
Exemple #3
0
 public void AddAllNeighbors()
 {
     for (int x = 0; x < squareArray.GetLength(0); x++)
     {
         for (int z = 0; z < squareArray.GetLength(1); z++)
         {
             if (x != 0)
             {
                 squareArray[x, z].leftNeighbor = squareArray[x - 1, z];
             }
             if (z != 0)
             {
                 squareArray[x, z].bottomNeighbor = squareArray[x, z - 1];
             }
             if (x != squareArray.GetLength(0) - 1)
             {
                 squareArray[x, z].rightNeighbor = squareArray[x + 1, z];
             }
             if (z != squareArray.GetLength(1) - 1)
             {
                 squareArray[x, z].topNeighbor = squareArray[x, z + 1];
             }
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Updates the blocked pieces of the game.
        /// </summary>
        private void UpdateBlockedPieces()
        {
            for (int x = 0; x < gameGrid.GetLength(0); x++)
            {
                for (int y = 0; y < gameGrid.GetLength(1); y++)
                {
                    if (gameGrid[x, y].HasPiece())
                    {
                        bool value = false;

                        foreach (Directions d in
                                 gameGrid[x, y].PossibleMovements)
                        {
                            value = CheckPos(gameGrid[x, y].Piece, d);

                            if (!value)
                            {
                                break;
                            }
                        }

                        gameGrid[x, y].Piece.IsBlocked = value;
                    }
                }
            }
        }
Exemple #5
0
        // Konstruktor som initaliserar en ny spelplan.
        public Board(string[] args)
        {
            board     = new Square[10, 10];
            flagCount = 0;
            gameOver  = false;
            playerWon = false;


            Helper.Initialize(args);

            for (int row = 0; row < board.GetLength(0); row++)
            {
                for (int col = 0; col < board.GetLength(1); col++)
                {
                    board[row, col] = new Square(Helper.BoobyTrapped(row, col));
                }
            }
            for (int row = 0; row < board.GetLength(0); row++)
            {
                for (int col = 0; col < board.GetLength(1); col++)
                {
                    int nearbyMine = CalculateNearbyMines(row, col);

                    for (int i = 0; i < nearbyMine; i++)
                    {
                        board[row, col].IncrementCloseMineCount();
                    }
                }
            }
        }
        // Visual bits
        public void DrawPlayField(Square[,] playField)
        {
            for (int i = 0; i < playField.GetLength(0); i++)
            {
                for (int j = 0; j < playField.GetLength(1); j++)
                {
                    Square square = playField[i, j];

                    Canvas.SetLeft(square, 0 + (square.squareWidth * i));
                    Canvas.SetTop(square, square.squareHeight * j);
                    //      Square width is set in the Square class constructor - it's a property of its parent Button class.

                    //      Reveal everything on game start:
                    //if (!square.isMined && square.isUncovered)
                    //{
                    //    square.Background = Brushes.Blue;
                    //}

                    //if (square.isMined)
                    //    square.Background = Brushes.Red;
                    //else
                    //    square.Background = Brushes.Gainsboro;

                    mainCanvas.Children.Add(square);
                }
                ;
            }

            unflaggedMinesCounter.Text = Convert.ToString(gameManager.unflaggedMinesSupposed);

            Application.Current.MainWindow.Width  = playField[0, 0].squareWidth * (playField.GetLength(0) + 1);
            Application.Current.MainWindow.Height = playField[0, 0].squareHeight * (playField.GetLength(1) + 1) + topBar.Height + 40; // 40 - Don't know where some of the height is coming from yet. Let's fudge it.
        }
Exemple #7
0
        public void DrowBoard(eBoardSign[,] i_GameMatrix, bool[,] i_ValidMovesMatrix)
        {
            for (int i = 0; i < m_SquaresBoard.GetLength(0); i++)
            {
                for (int j = 0; j < m_SquaresBoard.GetLength(1); j++)
                {
                    if (i_GameMatrix[i, j] == eBoardSign.Empty)
                    {
                        if (i_ValidMovesMatrix[i, j] == true)
                        {
                            m_SquaresBoard[i, j].SetSquareValues(null, true);
                        }
                        else
                        {
                            m_SquaresBoard[i, j].SetSquareValues(null, false);
                        }
                    }
                    else
                    {
                        if (i_GameMatrix[i, j] == eBoardSign.O)
                        {
                            m_SquaresBoard[i, j].SetSquareValues(Ex05_UIOthelo.Properties.Resources.CoinBlack, false);
                        }
                        else
                        {
                            m_SquaresBoard[i, j].SetSquareValues(Ex05_UIOthelo.Properties.Resources.CoinWhite, false);
                        }
                    }
                }
            }

            this.Refresh();
        }
Exemple #8
0
        static int[,] TargetPosition(Square[,] levels)
        {
            List <int> coordRow = new List <int>();
            List <int> coordCol = new List <int>();

            for (int i = 0; i < levels.GetLength(0); i++)
            {
                for (int j = 0; j < levels.GetLength(1); j++)
                {
                    if (levels[i, j].state == SquareState.Rock)
                    {
                        coordRow.Add(i);
                        coordCol.Add(j);
                    }
                }
            }
            int[,] matrix = new int[2, coordRow.Count];

            for (int k = 0; k < matrix.GetLength(1); k++)
            {
                matrix[0, k] = coordCol[k];
                matrix[1, k] = coordRow[k];
            }
            return(matrix);
        }
Exemple #9
0
    public void Loop_through_all_squares()
    {
        #region Initialize
        Verts_    = new List <Vector3>();
        Tri_index = new List <int>();
        Outlines  = new List <List <int> >();

        triangle_Dictionary = new Dictionary <int, List <Triangle> >();
        checked_vertex      = new HashSet <int>();
        #endregion

        Square[,] squares = square_Grid.squares;
        int x_s = squares.GetLength(0);
        int y_s = squares.GetLength(1);

        #region foreach_ sq
        for (int y = 0; y < y_s; y += 1)
        {
            for (int x = 0; x < x_s; x += 1)
            {
                Square sq = squares[x, y];
                In_a_square(sq);//
            }
        }
        #endregion
        //
        Create_Outlines();
    }
Exemple #10
0
 public Square[,] GetBoard()
 {
     for (int i = 0; i < checkerBoard.GetLength(0); i++)
     {
         for (int j = 0; j < checkerBoard.GetLength(1); j++)
         {
             if ((i + j) % 2 == 0)
             {
                 checkerBoard[i, j] = new Square(SquareColor.white, CheckerColor.none);
             }
             else
             {
                 if (i <= 3)
                 {
                     checkerBoard[i, j] = new Square(SquareColor.black, CheckerColor.black);
                 }
                 else if (i >= 6)
                 {
                     checkerBoard[i, j] = new Square(SquareColor.black, CheckerColor.white);
                 }
                 else
                 {
                     checkerBoard[i, j] = new Square(SquareColor.black, CheckerColor.none);
                 }
             }
         }
     }
     return(checkerBoard);
 }
Exemple #11
0
        public static void Board(Square[,] matrix, bool myBoard = true)
        {
            for (int x = 0; x < matrix.GetLength(1) - 1; x++)
            {
                Console.Write(x + " ");
            }
            Console.WriteLine();

            for (int x = 1; x < matrix.GetLength(0) - 1; x++) //raws
            {
                Console.Write(x + " ");

                for (int y = 1; y < matrix.GetLength(1) - 1; y++) //columns
                {
                    if (!myBoard)                                 //EnemyBoard
                    {
                        if (matrix[x, y].IsHitted)
                        {
                            if (matrix[x, y].IsSubmarine)
                            {
                                Console.Write("*");
                            }
                            else
                            {
                                Console.Write("/");
                            }
                        }
                        else
                        {
                            Console.Write("O");
                        }

                        Console.Write(" ");
                    }
                    else
                    {
                        if (!matrix[x, y].IsAccessiable)
                        {
                            if (matrix[x, y].IsSubmarine)
                            {
                                Console.Write("*");
                            }
                            else
                            {
                                Console.Write("/");
                            }
                        }
                        else
                        {
                            Console.Write("O");
                        }
                    }
                    Console.Write(" ");
                }

                Console.WriteLine("");
            }
            Console.WriteLine("\nO - sea water" +
                              "\n* - Submarine point ");
        }
Exemple #12
0
        public Player CheckWinner()
        {
            Square[,] field = game.GetField();
            Player currPlayer;
            Player lastPlayer = null;

            for (int i = 0, len = field.GetLength(0); i < len; i++)
            {
                lastPlayer = null;
                int successCounter = 1;
                for (int j = 0, len2 = field.GetLength(0); j < len2; j++)
                {
                    currPlayer = field[j, i].GetPlayer();
                    if (currPlayer == lastPlayer && (currPlayer != null && lastPlayer != null))
                    {
                        successCounter++;
                        if (successCounter == game.strSize || successCounter == len2)
                        {
                            return(currPlayer);
                        }
                    }
                    lastPlayer = currPlayer;
                }
            }
            return(null);
        }
        public IEnumerable <Square> GetSafeSquares()
        {
            var safeSquares = new List <Square>();

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                for (int v = 0; v < grid.GetLength(1); v++)
                {
                    Square currentSquare = grid[i, v];
                    if (currentSquare.Type == SquareType.Number)
                    {
                        // Get the total number of flags in squares adjacent to current square
                        int flagCount = GetFlagCount(currentSquare.AdjacentUnclicked);

                        // Get list of safe squares
                        if (currentSquare.Number <= flagCount && currentSquare.AdjacentUnclicked.Count > flagCount)
                        {
                            foreach (var square in currentSquare.AdjacentUnclicked)
                            {
                                if (square.Threat == ThreatType.Unknown)
                                {
                                    safeSquares.Add(square);
                                }
                            }
                        }
                    }
                }
            }
            return(safeSquares);
        }
 /// <summary>
 /// Mark all flags on the game grid
 /// </summary>
 /// <param name="grid"></param>
 private void SetFlags(Square[,] grid)
 {
     for (int i = 0; i < grid.GetLength(0); i++)
     {
         for (int v = 0; v < grid.GetLength(1); v++)
         {
             if (grid[i, v].Type == SquareType.Number)
             {
                 if (grid[i, v].AdjacentUnclicked.Count <= grid[i, v].Number)
                 {
                     foreach (var square in grid[i, v].AdjacentUnclicked)
                     {
                         if (square.Threat != ThreatType.Flag)
                         {
                             square.Threat = ThreatType.Flag;
                             MouseOperations.PerformFlagClick(
                                 gameBoard.WindowRect.left + Solver.GRID_OFFSET_X + (square.PosX * Square.PIXEL_WIDTH) + 8,
                                 gameBoard.WindowRect.top + Solver.GRID_OFFSET_Y + (square.PosY * Square.PIXEL_HEIGHT) + 8);
                         }
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// Mark all crux squares on the game grid
 /// </summary>
 /// <param name="grid"></param>
 private void SetCruxes(Square[,] grid)
 {
     for (int i = 0; i < grid.GetLength(0); i++)
     {
         for (int v = 0; v < grid.GetLength(1); v++)
         {
             var currentSquare = grid[i, v];
             if (currentSquare.Type == SquareType.Number)
             {
                 var adjacentUnknown = currentSquare.AdjacentUnclicked.Where(_ => _.Threat != ThreatType.Flag);
                 var adjacentFlags   = currentSquare.AdjacentUnclicked.Where(_ => _.Threat == ThreatType.Flag);
                 if (adjacentUnknown.Count() > currentSquare.Number - adjacentFlags.Count())
                 {
                     foreach (var square in adjacentUnknown)
                     {
                         if (square.Threat != ThreatType.Crux)
                         {
                             square.Threat = ThreatType.Crux;
                             MouseOperations.PerformQuestionClick(
                                 gameBoard.WindowRect.left + Solver.GRID_OFFSET_X + (square.PosX * Square.PIXEL_WIDTH) + 8,
                                 gameBoard.WindowRect.top + Solver.GRID_OFFSET_Y + (square.PosY * Square.PIXEL_HEIGHT) + 8);
                         }
                     }
                 }
             }
         }
     }
 }
    public static void BuildMesh(Environment environment)
    {
        //Remove old mesh if exists
        GameObject.Destroy(environment.GetComponent <MeshFilter> ().sharedMesh);

        InitializeSquares(environment.values);

        vertices  = new List <Vector3> ();
        triangles = new List <int> ();
        uvs       = new List <Vector2> ();

        for (int x = 0; x < squares.GetLength(0); x++)
        {
            for (int z = 0; z < squares.GetLength(1); z++)
            {
                TriangulateSquare(squares [x, z]);
                AssignTextureToSquare(squares [x, z].value);
            }
        }

        Mesh mesh = new Mesh();

        mesh.vertices  = vertices.ToArray();
        mesh.uv        = uvs.ToArray();
        mesh.triangles = triangles.ToArray();
        mesh.RecalculateNormals();

        environment.GetComponent <MeshFilter> ().sharedMesh   = mesh;
        environment.GetComponent <MeshCollider> ().sharedMesh = mesh;
    }
    private bool CheckIfItsPossibleToGenerateStreat(ref Square[,] squareMatrix, int index, Direction direction)
    {
        int  row   = 0;
        int  col   = 0;
        bool isEnd = false;

        for (int i = 0; i < squareMatrix.GetLength(0); i++)
        {
            for (int j = 0; j < squareMatrix.GetLength(1); j++)
            {
                if (squareMatrix[i, j].StreatIndex == index)
                {
                    row = i;
                    col = j;

                    CenterForCurrentDirection(ref row, ref col, squareMatrix[row, col].CurrentDirection, direction);
                    if (!CheckNextSquares(squareMatrix, direction, col, row))
                    {
                        isEnd = true;
                    }
                    else
                    {
                        squareMatrix = FillCells(squareMatrix, col, row, 3, Prefab.Streat, direction);
                    }

                    if (isEnd)
                    {
                        return(false);
                    }
                }
            }
        }
        return(true);
    }
Exemple #18
0
        public Player CheckWinner()
        {
            Square[,] field = game.GetField();
            Player currPlayer;
            Player lastPlayer     = null;
            int    successCounter = 1;

            for (int i = 0; i < field.GetLength(0); i++)
            {
                currPlayer = field[i, i].GetPlayer();
                if (currPlayer != null)
                {
                    if (lastPlayer == currPlayer)
                    {
                        successCounter++;
                        if (successCounter == game.strSize || successCounter == field.GetLength(0))
                        {
                            return(currPlayer);
                        }
                    }
                }
                lastPlayer = currPlayer;
            }
            return(null);
        }
Exemple #19
0
        public void MakeLevel()
        {
            int i;
            int len   = 4;
            int count = 0;
            Func <string, int> GetInt = inp => (int.TryParse(inp, out int val)) ? val : 0;

            for (i = 0; i < 15; i += 5)
            {
                // 1: minotaur, 2: theseus, 3: exit.
                // row.
                string theSubstring;
                theSubstring = Data.Substring(i, len / 2);
                int posY = GetInt(theSubstring);
                // column.
                theSubstring = Data.Substring(i + len / 2, len / 2);
                int posX = GetInt(theSubstring);
                switch (count)
                {
                case 0:
                    // remove findTME 3 new lines (can be removed)
                    // 0 = y, 1 = x.
                    MinotaurPosition = new Position(posY, posX);
                    break;

                case 1:
                    TheseusPosition = new Position(posY, posX);
                    break;

                case 2:
                    ExitPosition = new Position(posY, posX);
                    break;
                }
                count++;
            }
            int y = 0;
            int x = 0;

            for (int n = i; n < Data.Length; n += 5)
            {
                bool Top        = Convert.ToBoolean(GetInt(Data.Substring(n, 1)));
                bool Right      = Convert.ToBoolean(GetInt(Data.Substring(n + 1, 1)));
                bool Bottom     = Convert.ToBoolean(GetInt(Data.Substring(n + 2, 1)));
                bool Left       = Convert.ToBoolean(GetInt(Data.Substring(n + 3, 1)));
                bool isMinotaur = (y == MinotaurPosition.Y && x == MinotaurPosition.X) ? true : false;
                bool isTheseus  = (y == TheseusPosition.Y && x == TheseusPosition.X) ? true : false;
                bool isExit     = (y == ExitPosition.Y && x == ExitPosition.X) ? true : false;
                Squares[y, x] = new Square(Top, Left, Bottom, Right, isMinotaur, isTheseus, isExit);
                if (x == Squares.GetLength(1) - 1 && y < Squares.GetLength(0) - 1)
                {
                    y++;
                    x = 0;
                    continue;
                }
                if (x < Squares.GetLength(1) - 1)
                {
                    x++;
                }
            }
        }
Exemple #20
0
        public Square[,] CalculateNeighboringMineCount(Square[,] _playField)
        {
            // For each square in the field...
            for (int i = 0; i < _playField.GetLength(0); i++)
            {
                for (int j = 0; j < _playField.GetLength(1); j++)
                {
                    int neighboringMines = 0;

                    // ...search the 8 surrounding squares for mines.
                    for (int x = i - 1; x <= i + 1; x++)
                    {
                        for (int y = j - 1; y <= j + 1; y++)
                        {
                            if (x < 0 || x >= _playField.GetLength(0) || y < 0 || y >= _playField.GetLength(1))
                            {
                                continue;
                            }

                            if (_playField[x, y].isMined)
                            {
                                neighboringMines++;
                            }
                        }
                    }

                    _playField[i, j].neighboringMines = neighboringMines;
                }
            }

            return(_playField);
        }
        static int GetDistance(Point2D startPoint, Point2D endPoint)
        {
            movementGrid.Clear();

            Queue <Point2D> pendingPoints = new Queue <Point2D>();

            pendingPoints.Enqueue(startPoint);
            movementGrid.Add(startPoint, 0);

            while (pendingPoints.Count > 0)
            {
                Point2D next = pendingPoints.Dequeue();

                if (next == endPoint)
                {
                    break;
                }

                int distance = movementGrid[next] + 1;

                foreach (Point2D adj in next.GetAdjacent())
                {
                    if (adj.x < 0 || adj.y < 0 || adj.x >= grid.GetLength(0) || adj.y >= grid.GetLength(1))
                    {
                        continue;
                    }

                    Square value = grid[adj.x, adj.y];
                    if (value == Square.Open)
                    {
                        //Can enter
                        if (movementGrid.GetValueOrDefault(adj, int.MaxValue) > distance)
                        {
                            //Update
                            movementGrid[adj] = distance;
                            if (!pendingPoints.Contains(adj))
                            {
                                pendingPoints.Enqueue(adj);
                            }
                        }
                    }
                    else if (value == Square.PortalOuter || value == Square.PortalInner)
                    {
                        Point2D exit = portalDict[adj];
                        //Can enter
                        if (movementGrid.GetValueOrDefault(exit, int.MaxValue) > distance + 1)
                        {
                            //Update
                            movementGrid[exit] = distance + 1;
                            if (!pendingPoints.Contains(exit))
                            {
                                pendingPoints.Enqueue(exit);
                            }
                        }
                    }
                }
            }

            return(movementGrid[endPoint]);
        }
    private void Start()
    {
        for (int x = 0; x < squares.GetLength(0); x++)
        {
            for (int y = 0; y < squares.GetLength(1); y++)
            {
                Square square = squares[x, y];
                if (x > 0)
                {
                    square.westNeighbor = squares[x - 1, y];
                }
                if (y > 0)
                {
                    square.southNeighbor = squares[x, y - 1];
                }
                if (x < width - 1)
                {
                    square.eastNeighbor = squares[x + 1, y];
                }
                if (y < height - 1)
                {
                    square.northNeighbor = squares[x, y + 1];
                }
            }
        }

        if (scriptScale)
        {
            ChangeScaleIfNeeded();
        }
    }
Exemple #23
0
        /**
         *  онструктор
         *
         */
        public Game(int sizeArray)
        {
            strSize     = sizeArray > 5 ? 5 : sizeArray;
            field       = new Square[sizeArray, sizeArray];
            squareCount = 0;
            // заполнение пол¤
            for (int i = 0; i < field.GetLength(0); i++)
            {
                for (int j = 0; j < field.GetLength(1); j++)
                {
                    field[i, j] = new Square();
                    squareCount++;
                }
            }
            winnerCheckers    = new IWinnerChecker[4];
            winnerCheckers[0] = new WinnerCheckerHorizontal(this);
            winnerCheckers[1] = new WinnerCheckerVertical(this);
            winnerCheckers[2] = new WinnerCheckerDiagonalLeft(this);
            winnerCheckers[3] = new WinnerCheckerDiagonalRight(this);
            players           = new Player[2];
            started           = false;
            activePlayer      = null;
            filled            = 0;

            Log.Info(TAG, "new AndroLogic");
            androLogic    = new IAndroidLogic[4];
            androLogic[0] = new WinnerCheckerVertical(this);
            androLogic[1] = new WinnerCheckerHorizontal(this);
            androLogic[2] = new WinnerCheckerDiagonalLeft(this);
            androLogic[3] = new WinnerCheckerDiagonalRight(this);
            Log.Info(TAG, "---------------------");
        }
Exemple #24
0
 public Grid(int top, int left, Square[,] cells)
 {
     this.top   = top;
     this.left  = left;
     this.cells = cells;
     rows       = cells.GetLength(0);
     columns    = cells.GetLength(1);
 }
Exemple #25
0
 public void OwnStart()
 {
     squares     = lg.squares;
     maxX        = squares.GetLength(0);
     maxY        = squares.GetLength(1);
     bombsAmount = lg.bombsAmount;
     Bomber.instance.bombsAmount = bombsAmount;
 }
Exemple #26
0
 public PathFinding(int depth, int verticalMove, Square[,] mapRepresentation, Square firstSquare)
 {
     this.depth             = depth;
     this.verticalMove      = verticalMove;
     this.mapRepresentation = mapRepresentation;
     this.result            = new Node[mapRepresentation.GetLength(0), mapRepresentation.GetLength(1)];
     this.origin            = firstSquare;
 }
Exemple #27
0
        public void CalculateCellsValue()
        {
            int countX           = 0;
            int totalValueX_up   = 0;
            int totalValueX_down = 0;
            int countO           = 0;
            int totalValueO_up   = 0;
            int totalValueO_down = 0;

            Square[,] field = game.GetField();
            Log.Info(TAG, "FindDiagRight");

            for (int i = 0; i < field.GetLength(0); i++)
            {
                countX = 0;
                countO = 0;
                int b = i;
                for (int j = field.GetLength(0) - 1; j >= 0; j--)
                {
                    if (b > (field.GetLength(0) - 1))
                    {
                        continue;
                    }
                    totalValueX_up   = 0;
                    totalValueO_up   = 0;
                    totalValueX_down = 0;
                    totalValueO_down = 0;
                    if (!field[b, j].IsFilled())
                    {
                        for (int a = 0; a < game.strSize; a++)
                        {
                            countX          = findLineSize(b - a, j + a, "X");
                            totalValueX_up += getValue(countX);

                            countO          = findLineSize(b - a, j + a, "O");
                            totalValueO_up += getValue(countO);
                        }
                    }
                    if (!field[b - i, j - i].IsFilled() & i > 0)
                    {
                        for (int a = 0; a < game.strSize; a++)
                        {
                            countX            = findLineSize(b - i - a, j - i + a, "X");
                            totalValueX_down += getValue(countX);

                            countO            = findLineSize(b - i - a, j - i + a, "O");
                            totalValueO_down += getValue(countO);
                        }
                    }
                    field[b, j].addValueO(totalValueO_up);
                    field[b, j].addValueX(totalValueX_up);
                    field[b - i, j - i].addValueO(totalValueO_down);
                    field[b - i, j - i].addValueX(totalValueX_down);
                    Log.Info(TAG, "totalValueO=" + totalValueO_up + " totalValueX=" + totalValueX_up + " b=" + b + " j=" + j);
                    b++;
                }
            }
        }
Exemple #28
0
 public Square GetSquare(int x, int z)
 {
     //returns null if is of the edge, otherwise returns the square
     if (x < 0 || z < 0 || x >= _grid.GetLength(0) || z >= _grid.GetLength(1))
     {
         return(null);
     }
     return(_grid[x, z]);
 }
Exemple #29
0
 public Square GetSquare(int x, int z)
 {
     //check if goes out of bounds of the grid
     if (x >= grid.GetLength(0) || z >= grid.GetLength(1) || x < 0 || z < 0)
     {
         return(null);
     }
     return(grid[x, z]);
 }
        public static void PrintOceanForPlacementPhase(Square[,] ocean)
        {
            var rows = ocean.GetLength(0);
            var cols = ocean.GetLength(1);

            char[] alphabet = InitAlphabet(rows);
            PrintHeaders(cols);
            PrintGameRowsForPlacement(ocean, rows, cols, alphabet);
        }