Question: use ATELIER B . . . GIVE THE WHOLE CODE WITHOUT MISTAKES PLZZZ code shud compulsorily have these code lines, report - - deployFleet (
use ATELIER BGIVE THE WHOLE CODE WITHOUT MISTAKES PLZZZ
code shud compulsorily have these code lines,
report deployFleetplayer positions
report playerShootstarget
shipsquares shipLocationsplayer
shipCounts shipsLeft
shotCount shotsTakenplayer
report gameStatus
plz attach the whole workable code no need explanations
This coursework requires you to develop a B specification of a version of the Battleships board game. This system is to be developed using the B tools Atelier B and ProB. Battleships is a strategy type guessing game for two players. It is played using two x grids, one for each player. The game starts by each player placing the warships of their fleet on squares in their own grid. The locations of the fleets are concealed from the other player. Players take alternate turns "shooting" at the other player's ships in an attempt to sink them. The aim of the game is to win by destroying your opponent's fleet of ships before they destroy yours.
The Battleships Game Constraints and Requirements
For the purposes of this coursework, the Battleships game used is a simplified version of the normal game:
A grid size of x squares, with the grid square representing the square at column & row
Each player has warships in their fleet.
Each warship occupies a single grid square on the grid.
The warships must be on different grid squares, ie at most warship per square.
Playing the Battleships Game
The Battleships game is played as follows:
The game starts by each player placing their ships on their own grid, each player's ships in different grid squares.
Player has the first turn.
Player shoots at Player s ships, by selecting a target square on Player s grid. If there is a ship in the target square it is a hit and the ship is deleted from Player s fleet, otherwise it is a miss and there is no change to Player s fleet.
It is then Player s turn.
Player shoots at Player s ships, by selecting a target square on Player s grid. Registering a hit or miss, as above.
The players continue to take turns until all of one player's ships have been sunk, at this point the other player is the winner.
The Battleships Game B Specification
Specification Components
Your B specification should include the following elements.
a Sets and Constants
Any sets and constants that are required to define the data and state of the Battleships game system, and their properties. Includes at least the set of players, dimensions of their grids, and number of battleships.
b System State
The state variables required to represent the data for the Battleships game system. Including the state invariant and initialisation. Includes at least both players grids, the current game state for example, it could be ongoing, won by either player, or one or both players may still need to deploy their fleet and whose turn it is Check the operations to figure out what other information is needed.
c Operations
The Battleships game operations are:
report deployFleetplayer positions
The specified player places their ships at the given positions on their own grid. If the ships are all placed in valid grid positions, then the operation reports success, otherwise it reports an error message indicating what the error was.
report playerShootstarget
The player whose turn it is shoots at the target square on the other player's grid. If it contains a ship, then this ship is deleted, and the operation reports a hit. If this was their last ship the game is over, and the current player wins the game; otherwise, it is the other players turn. If there is no ship in the target square the operation reports a miss. If the target square is not in the grid, it reports an error message.
For each operation make sure to use suitable preconditions eg players should not start shooting before both fleets have been deployed
d Enquiry Operations
You must also specify the following enquiry operations, that all output information about the state of the game:
shipsquares shipLocationsplayer
Outputs the location of all the ships left in the player's fleet.
shipCounts shipsLeft
Outputs the numbers of ships left in both players fleets.
shotCount shotsTakenplayer
Outputs the number of shots taken by the player.
report gameStatus
Gives information about the games state eg ongoing, player win, both players still need to deploy, etc
General Requirements
The B specification should use the appropriate features to define the data & operations in any machines that you define. The overall structure of the B specification should be
A single B machine that contains all the state information and operations, etc.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
