Ejemplo n.º 1
0
 private bool addToUniqueStorage(HorseBoard board)
 {
     var key = board.GetKey();
     if (_uniqueBoards.Contains(key))
     {
         return false;
     }
     _uniqueBoards.Add(key);
     return true;
 }
Ejemplo n.º 2
0
 private List<HorseBoard> findAllPossibleMoves(HorseBoard board)
 {
     var boards = new List<HorseBoard>();
     for(var i=0;i<board.Horses.Length;i++)
     {
         var horse = board.Horses[i];
         foreach (var horseMove in horse.GetAllPossibleMoves(board.Size))
         {
             var newBoard = board.Clone();
             if (newBoard.MoveHorse(i, horseMove))
             {
                 boards.Add(newBoard);
             }
         }
     }
     return boards;
 }
Ejemplo n.º 3
0
 public HorseBoardState(HorseBoard board)
 {
     Board = board;
 }
Ejemplo n.º 4
0
 public HorseBoardState(HorseBoard board, HorseBoardState state)
 {
     Board = board;
     History.AddRange(state.History);
     History.Add(state.Board);
 }
Ejemplo n.º 5
0
 private void print(HorseBoard board)
 {
     var coord = new Coordinate();
     for (coord.Y = 0; coord.Y < board.Size.Height; coord.Y++)
     {
         for (coord.X = 0; coord.X < board.Size.Width; coord.X++)
         {
             var horse = board.Horses.FirstOrDefault(x => x.Coord == coord);
             var sign = "_";
             if (horse.Color == HorseColor.White)
             {
                 sign = "W";
                 Console.ForegroundColor = ConsoleColor.White;
             }
             else if (horse.Color == HorseColor.Black)
             {
                 sign = "R";
                 Console.ForegroundColor = ConsoleColor.Red;
             }
             Console.Write(sign + " ");
             Console.ForegroundColor = ConsoleColor.Gray;
         }
         Console.WriteLine();
     }
     Console.WriteLine();
 }