Example #1
0
        private void constructWorld(string worldPath)
        {
            //Reading Board Properties
            StreamReader f = new StreamReader(worldPath);

            string[] boardProps = f.ReadLine().Split(' ');
            int      numRows    = Convert.ToInt32(boardProps[0]);
            int      numCols    = Convert.ToInt32(boardProps[1]);
            int      cellSize   = cellSize = BOARD_SIZE / (numCols > numRows ? numCols : numRows);

            //Reading Karel Properties
            string[] karelParams = f.ReadLine().Split(' ');
            int      row         = Convert.ToInt32(karelParams[0]);
            int      col         = Convert.ToInt32(karelParams[1]);
            int      beeperBag   = Convert.ToInt32(karelParams[2]);

            if (beeperBag == -1)
            {
                beeperBag = int.MaxValue;
            }

            //Instantiating Karel and the Board.
            karel      = new ExtendedKarel(row, col, beeperBag, cellSize);
            this.board = new KarelBoard(numRows, numCols, BOARD_SIZE, cellSize, karel, worldPath);
            karel.setBoard(board);
            this.Controls.Add(board);
        }
Example #2
0
 public KarelBoard(int numRows, int numCols, int boardSize, int cellSize, ExtendedKarel karel, string worldFile)
 {
     BOARD_SIZE   = boardSize;
     this.walls   = new Dictionary <Position, Position>();
     this.beepers = new Beeper[numRows, numCols];
     this.karel   = karel;
     this.numRows = numRows;
     this.numCols = numCols;
     initBoard(worldFile);
     visualiseBoard(cellSize);
 }