Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions