Ejemplo n.º 1
0
        public Solver CreateSolver()
        {
            Solver solver = new Solver();
            foreach (Tile tile in Tiles)
            {
                solver.Fish[tile.Row][tile.Column] = tile.Fish;
            }

            solver.Blue = Tiles.Where(tile => tile.Penguin == 1).Select(tile => new Position(tile.Row, tile.Column)).ToArray();
            solver.Red = Tiles.Where(tile => tile.Penguin == 2).Select(tile => new Position(tile.Row, tile.Column)).ToArray();

            foreach (Position penguin in solver.Blue.Concat(solver.Red))
            {
                solver.Fish[penguin.Row][penguin.Column] = 0;
            }

            return solver;
        }
Ejemplo n.º 2
0
 private Solver ParseBoard(string p)
 {
     p = p.Trim().Replace(" ", "");
     Solver board = new Solver();
     int row = 0;
     List<Position> blue = new List<Position>();
     List<Position> red = new List<Position>();
     foreach (string rowString in p.Split('\n'))
     {
         int column = 0;
         foreach (char c in rowString)
         {
             if (c >= '1' && c <= '3')
             {
                 board.Fish[row][column] = c - '0';
             }
             else if (c == 'B')
             {
                 blue.Add(new Position(row, column));
             }
             else if (c == 'R')
             {
                 red.Add(new Position(row, column));
             }
             column++;
         }
         row++;
     }
     board.Blue = blue.ToArray();
     board.Red = red.ToArray();
     return board;
 }