Esempio n. 1
0
 // Metoda pro ohodnocení možného tahu
 public void EvaluateMove(int row, int col, int newRow, int newCol, GameBoard board, out int moveResult)
 {
     if (board.Position(newRow, newCol) == (int)GameConstants.States.empty)
     {
         /*
          * Console.WriteLine("Moved");
          * board[newRow, newCol] = board[row, col];
          * Empty(row, col);
          */
         board.Move(row, col, newRow, newCol);
         moveResult = (int)GameConstants.MoveResult.Moved;
     }
     else if (board.Occupied(newRow, newCol) && board.Enemy(row, col, newRow, newCol))
     {
         /*
          * Console.WriteLine("Freezed");
          * Freeze(newRow, newCol);
          * Empty(row, col);
          */
         board.Freeze(row, col, newRow, newCol);
         moveResult = (int)GameConstants.MoveResult.Frozen;
     }
     else
     {
         moveResult = (int)GameConstants.MoveResult.Fail;
     }
 }
Esempio n. 2
0
        public int CheckKingSiege(GameBoard board, int row, int col)
        {
            int sieged = 0;
            List <List <int> > adjacted = GameRules.Adjacted(row, col, board);

            foreach (List <int> position in adjacted)
            {
                if (board.Enemy(row, col, position[0], position[1]) && !board.IsKing(position[0], position[1]))
                {
                    sieged = 20;
                }
            }
            return(sieged);
        }
Esempio n. 3
0
        public int KingHunting(GameBoard board, int row, int col)
        {
            int hunt = 0;
            List <List <int> > adjacted = GameRules.Adjacted(row, col, board);

            foreach (List <int> position in adjacted)
            {
                if (board.Enemy(row, col, position[0], position[1]) && board.IsKing(position[0], position[1]))
                {
                    hunt += 2;
                }
            }
            return(hunt);
        }
Esempio n. 4
0
 // Metoda pro rozhodnutí zda-li je tah v souladu s pravidly
 public bool ValidMove(int row, int col, int newRow, int newCol, GameBoard board)
 {
     if (ValidPosition(row, col) && ValidPosition(newRow, newCol))
     {
         //Console.WriteLine("Valid position, Valid new position");
         if (ValidDistance(row, col, newRow, newCol))
         {
             if (board.Occupied(row, col) && !board.Frozen(row, col) && !board.Frozen(newRow, newCol))
             {
                 if (board.IsKing(row, col) && board.Occupied(newRow, newCol))
                 {
                     return(false);
                 }
                 else if (board.Occupied(newRow, newCol) && !board.Enemy(row, col, newRow, newCol))
                 {
                     return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
             else
             {
                 return(false); //Console.WriteLine("Empty or frozen field.");
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false); //Console.WriteLine("Not valid position.");
     }
 }