Question: MACHINE BattleShipGame SETS Players = { Player 1 , Player 2 } ; Results = { Success , Failure } ; GameStates = { Deploying
MACHINE BattleShipGame
SETS
Players Player Player;
Results Success Failure;
GameStates Deploying Ongoing, PlayerWin, PlayerWin;
Reports Hit Miss, InvalidMove;
CONSTANTS
Grid
FleetSize
PROPERTIES
Grid & x grid
FleetSize Each player has ships
VARIABLES
playerShips, playerShips, Positions of Players and Players ships
playerShots, playerShots, Shots taken by Player and Player
currentPlayer, Whose turn it is
gameState Current state of the game
INVARIANT
playerShips : Grid &
playerShips : Grid &
cardplayerShips FleetSize &
cardplayerShips FleetSize &
playerShips playerShips & No overlapping ships
playerShots : Grid &
playerShots : Grid &
currentPlayer : Players &
gameState : GameStates
INITIALISATION
playerShips :
playerShips :
playerShots :
playerShots :
currentPlayer : Player
gameState : Deploying
OPERATIONS
Deploy Fleet Operation
report deployFleetplayer positions
PRE
player : Players &
positions : Grid &
cardpositions FleetSize &
player Player playerShips &
player Player playerShips &
player Player positions playerShips &
player Player positions playerShips
THEN
IF player Player THEN
playerShips : positions
ELSE
playerShips : positions
END
IF playerShips & playerShips THEN
gameState : Ongoing
END
report : Success
END;
Player Shoots Operation
report playerShootstarget
PRE
target : Grid &
gameState Ongoing
THEN
IF currentPlayer Player THEN
IF target : playerShips THEN
playerShips : playerShips target
report : Hit
IF cardplayerShips THEN
gameState : PlayerWin
ELSE
currentPlayer : Player
END
ELSE
report : Miss
currentPlayer : Player
END
playerShots : playerShots target
ELSE
IF target : playerShips THEN
playerShips : playerShips target
report : Hit
IF cardplayerShips THEN
gameState : PlayerWin
ELSE
currentPlayer : Player
END
ELSE
report : Miss
currentPlayer : Player
END
playerShots : playerShots target
END
END;
Enquiry Operation: shipLocations
shipsquares shipLocationsplayer
PRE
player : Players
THEN
IF player Player THEN
shipsquares : playerShips
ELSE
shipsquares : playerShips
END
END;
Enquiry Operation: shipsLeft
shipCounts shipsLeft
BEGIN
shipCounts :Player cardplayerShips Player cardplayerShips
END;
Enquiry Operation: shotsTaken
shotCount shotsTakenplayer
PRE
player : Players
THEN
IF player Player THEN
shotCount : cardplayerShots
ELSE
shotCount : cardplayerShots
END
END;
Enquiry Operation: gameStatus
report gameStatus
BEGIN
report : gameState
END;
END
when I try to run this code on Atelier B or Pro B an error is constantly appearing at line CONSTANTS stating;
Error occurred: parseerror
Reason: expecting: identifier literal
Expected values: SET name
unexpected token: CONCRETECONSTANTS
can I please get the corrected code that you have tested and can run the project
thank you.
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
