Question
Now that we can make the grid, we need to set up the simulation itself! You'll need to update makeModel to set up several variables.
Now that we can make the grid, we need to set up the simulation itself! You'll need to update makeModel to set up several variables. These variables will be a part of data, so make sure to define them as data["name"] = value. First, store data about the board dimensions. You should store the number of rows, number of cols, board size, and cell size. You can start with 10 rows, 10 cols, and a 500px board size. You can then compute the cell size based on the board size and number of rows/cols. Next, store data about the board. You'll need to keep track of two boards- one for the computer, and one for the user. You should store the number of ships on the board (start with 5), then set both the computer board and the user board to be a new empty grid, by calling your emptyGrid() function. Finally, update your computer board by calling your addShips() function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started