Esempio n. 1
0
        private static NeighborStatus GetNeighborStatus(Board board, Hex hex, Position pos)
        {
            Hex   tr_hex = Neighborhood.GetNeighborHex(hex, pos);
            Piece tr_piece;

            if (board.TryGetPieceAtHex(tr_hex, out tr_piece))
            {
                if (tr_piece.color == PieceColor.Black)
                {
                    return(NeighborStatus.Black);
                }
                else if (tr_piece.color == PieceColor.White)
                {
                    return(NeighborStatus.White);
                }
                else
                {
                    throw new Exception(string.Format("Bad color status at {0},{1}", hex.column, hex.row));
                }
            }
            else
            {
                return(NeighborStatus.Empty);
            }
        }
Esempio n. 2
0
 private static bool IsDirectionBlocked(Position directionToCheck, Position counterClockwiseDirection, Position clockwiseDirection, NeighborStatus[] neighborStatus)
 {
     if (neighborStatus[(int)directionToCheck] != NeighborStatus.Empty)
     {
         return(true);
     }
     else if (neighborStatus[(int)counterClockwiseDirection] != NeighborStatus.Empty &&
              neighborStatus[(int)clockwiseDirection] != NeighborStatus.Empty)
     {
         // gate
         return(true);
     }
     else
     {
         return(false);
     }
 }