程序代写 Part Three: Technical Specification

Part Three: Technical Specification
Each part of this technical specification has been split in two:
MVP, technical elements relating to the Minimum Viable Product which the monolith implements;
Evolved, technical elements relating to Task 2 (Evolution of Requirements) which the monolith does not currently implement.

Copyright By PowCoder代写 加微信 powcoder

1. Dungeon Maps
Dungeon maps consist of JSON files which contain the following:
entities , an array of entities in the map when the game starts; and goal-condition , a specification of the goals for winning the dungeon.
There will be no other fields present in the JSON.
All maps are infinite in all directions. Moving left/right is a decrease/increase in the x co-ordinate of an entity respectively, moving up/down is a decrease/increase in the y co-ordinate of an entity respectively.
1.1 Input Specification – Entities (MVP)
Each entry in the entities JSON Array will be a JSON Object with the following fields:
x – the x-position of the entity in the dungeon when the game starts;
y – the y-position of the entity in the dungeon when the game starts; and type – the type of the entity.
The type field will be a string that starts with one of the following prefixes. For automarking purposes, all entities passed in will have a type in the following table.
Floor Switch
Zombie Toast Spawner
Zombie Toast
Invincibility Potion
Invisibility Potion
JSON Prefix
zombie_toast_spawner
zombie_toast
invincibility_potion
invisibility_potion
Creatable from Dungeon Map?

Bow Shield
1.1.1 Further Entities (Evolved)
Swamp Tile
Midnight Armour Time Turner
Time Travelling Portal Light Bulb (off)
Light Bulb (on) Wire
Switch Door Older Player
1.1.2 Extra Fields (MVP)
bow shield
JSON Prefix
swamp_tile
sceptre midnight_armour time_turner time_travelling_portal light_bulb_off light_bulb_on
wire switch_door older_player
No, since this entity must be built by the player. No, since this entity must be built by the player.
Creatable from Dungeon Map?
No, since this entity must be built by the player. No, since this entity must be built by the player. Yes
No, since light bulbs will always be created off.
No, since these will only appear when the player has time travelled.
Some entities will contain additional fields in their JSON entry, namely:
All entities of type portal will have a field colour . Two portals which have the same colour are linked (travelling through one portal takes you to the other). We will never provide a dungeon which has more than two portals of the same colour, and all portals will have a counterpart of the same colour in the dungeon.
All entities of type door and key will have a key field which, in the case of the key is the identifier of the key, and in the case of the
door the id of the key which fits that door. 1.1.3 Extra Fields (Evolved)
All logical entities will be created with the field logic which will be one of and , or , xor , or co_and . Milestone 2 entities (bombs, switches) that do not have a logic field cannot be activated by wires and act as they did in Milestone 2. Milestone 3 logical entities (light bulbs, switch doors) will always be created with a logic field. Regular doors will never be created with a logic field.
All swamp tiles will be created with a field movement_factor which will be the tile’s movement factor, an integer >= 0. 1.2 Input – Goals (MVP)
A basic goal is represented in the dungeon as:
Where is one of “boulders” , “treasure” or “exit” . A complex goal is represented in the dungeon as:
1 “goal-condition”: { 2 “goal”: 3}
“goal-condition”: {
“goal”: ,
“subgoals”: [
{“goal”: },
{“goal”: }

Where is one of, “boulders” , “treasure” , “exit” , or another nested goal conjunction/disjunction itself, and is one of “AND” or “OR” .
1.3 Input – Goals (Evolved)
In Task 2 a), “enemies” is also included in this list of goals. 2. Configuration Files
In config_template.json we have specified the template for a configuration file. This file is important as it specifies internal game mechanics which will affect the external behaviour of your application. Rather than hard coding these constants into your classes, you must instead read in these values from the specified file when the game is created.
During automarking, we will be providing our own configuration files with each test dungeon – this allows our tests to set parameters that should ensure behaviours are produced without ambiguity. For this reason, if you do not read in the values correctly, you will likely fail a large number of our autotests.
2.1 Configuration Fields (MVP)
JSON Format
ally_attack
ally_defence
bribe_radius
bribe_amount
bomb_radius
bow_durability
player_health
player_attack
enemy_goal invincibility_potion_duration invisibility_potion_duration mercenary_attack mercenary_health spider_attack
spider_health spider_spawn_interval
shield_durability shield_defence sword_attack sword_durability treasure_goal zombie_attack zombie_health zombie_spawn_interval
Description
Attack bonus each ally gives to the player.
Reduction in effect of enemy attack damage each ally gives to the player.
Radius in which a mercenary can be bribed.
Amount of gold required to bribe a mercenary.
Blast radius of bomb.
The number of battles that the bow lasts for.
Health of the character.
Attack damage of the character.
At least x enemies must be killed to complete the enemy goal
The effects of the potion only last for x ticks.
The effects of the potion only last for x ticks.
Attack damage of the mercenary.
Health of the mercenary.
Attack damage of the spider.
Health of the spider.
Spiders spawn every x ticks, starting from the x’th tick. Spawn rate of 0 means that spiders will never spawn in the game.
The number of battles that the shield lasts for.
The reduction in the effect of the attack damage of the enemy as a result of the shield. Amount of damage added to a players’ attack damage when they use a sword in battle. The number of battles that the sword lasts for.
At least x treasure must be collected to complete the treasure goal
Attack damage of the zombie toast.
Health of the zombie toast.
Zombies spawn every x ticks from each spawner, starting from the x’th tick. Spawn rate of 0 means that zombies will never spawn in the game.
2.2 Configuration Fields (Evolved)

assassin_attack assassin_bribe_amount assassin_bribe_fail_rate
assassin_health hydra_attack
hydra_health hydra_health_increase_rate
hydra_health_increase_amount mind_control_duration midnight_armour_attack midnight_armour_defence
Attack damage of the assassin.
The amount of gold required to perform an attampt to bribe an assassin.
The chance that the bribe on an assassin will fail. The value of this field should be always inclusively between 0 and 1.
Health of the assassin.
Attack damage of the hydra.
Health of the hydra.
The chance that the health of a Hydra increases when it gets attacked each round. The value of this field should be always inclusively between 0 and 1.
The increment on the health of a Hydra increases when it gets attacked. The amount of time mind controlling via a sceptre lasts for.
Attack bonus wearing midnight armour gives to the player.
Defence bonus wearing midnight armour gives to the player.
Description
A note about backwards compatibility:
All the regression tests we have provided to you in the starter code should remain passing without being changed.
All of the MVP configuration files (in the provided config files) do not currently contain the fields listed in Section 2.1. Rather than retroactively adding these fields to the existing configuration files, you will need
to design your implementation to accomodate for this and maintain backwards compatibility. All Version 2 configuration files in our autotests will contain all values from both Version 2 (Evolved) and Version 1 (MVP).
3. Interface
The layer of abstraction is at the level of the controller. In the starter code, we have provided a class DungeonManiaController . The controller methods interact with a HTTP layer in the form of a web server, which we have written for you.
3.1 Interface Data Types
We have provided the following interface data types for you inside response/models . Similarly as for the assignment, you will need to create objects of these types for the controller to return and communicate information to the server layer.
In case you are interested, The server layer then wraps these objects inside a GenericResponseWrapper , a generic type we have made for you, and converts these objects to JSON using a libary called gson to allow them to be communicated to the frontend via a HTTP response.
Description
Constructor Prototype
1 public DungeonResponse(String dungeonId,
2 String dungeonName,
3 List entities,
4 List inventory,
5 List battles,
6 List buildables,
7 String goals)
dungeonId is the unique identifier for the dungeon
dungeonName is the name of the dungeon map being used (i.e. maze , which corresponds to the file src/main/resources/dungeons/maze.json
entities is a list of all entities currently in the dungeon (all entities in the Player’s inventory aren’t
included); if a Player or enemy dies it is removed from this list inventory is the Player’s current inventory
buildables is a list of buildable item types that the player can build, given their current inventory and game state
battles is the list of battles that has occured in total in the game so far (see BattleResponse ), in the order that they occurred
goals is a string containing the goals yet to be completed. An empty string denotes the game has been won. Each goal in the string is preceded with a colon : and is one of the four basic goals listed
in Section 4.2. How you represent conjunctions (AND) and disjunuctions (OR) is up to you, as the frontend will simply render your string with the goals as images. We will only check for the goal strings in our tests (e.g. :exit ). An example of the goals string is “:exit AND (:treasure OR
:enemies)”
JSON Format

public BattleResponse(String enemy, List rounds,
double initialPlayerHealth, double initialEnemyHealth, List weaponryUsed)
enemy is the type of enemy (e.g. spider), rounds represent the rounds of the battle (see RoundResponse).
initialPlayerHealth is the initial health of the player before the battle initialEnemyHealth is the initial health of the enemy before the battle.
weaponryUsed is a list of all attack and defence items used in the battle, including potions.
1 public RoundResponse(double deltaPlayerHealth, 2 double deltaEnemyHealth)
deltaPlayerHealth is the change in health of the character in that round of the battle (e.g. -3 is a reduction of 3 in health)
deltaEnemyHealth is the corresponding change of health of the enemy in that round of the battle.
Note that each of these deltas can be positive and that the ‘sign’ of the health matters (e.g. positive deltas correlate to increase and negative deltas correlated to decrease in health).
1 public EntityResponse(String id,
2 String type,
3 Position position,
4 boolean isInteractable)
id is the unique identifier for the respective entity
type is the type of the entity (a prefix corresponding to the table in Section 4.1) position is the x, y, z (layer) position of the entity
isInteractable refers to if the entity can receive interaction updates from frontend, which only
pertains to mercenaries and zombie toast spawners. When mercenaries become allies, they are no longer interactable.
1 public ItemResponse(String id, String type)
id is the unique identifier for the item and type is the type of item (lowercase, see Section 3 for names).
1 public Position(int x, int y, int layer)
x , y are the co-ordinates of the cell (the top-left cell is 0,0)
layer is the Z-position of the entity on the screen (a higher layer is “in front” of a lower layer visually). The Z-position only matters for frontend rendering and is not something we will test.
public enum Direction { UP(0, -1),
DOWN(0, 1), LEFT(-1, 0), RIGHT(1, 0);
Direction of movement for the player.
3.2 Interface Methods (MVP)
Method Prototype
Description Exceptions
Return the dungeon response for the current state of the game N/A without any side effects on the game.
Ticks the game state when the player moves in the specified N/A direction one square. The player’s movement must be carried out
first, then enemy movement.
Creates a new game, where dungeonName is the name of the dungeon map (corresponding to a JSON file stored in the model) and configName is the name of the configuration file.
IllegalArgumentException:
If dungeonName is not a dungeon that exists
If configName is not a configuration that exists
1 public DungeonResponse newGame(String dungeonName, 2 String configName) 3 throws IllegalArgumentException
1 public DungeonResponse getDungeonResponseModel()
1 public DungeonResponse tick(String itemUsedId) throws 2 InvalidActionException
Ticks the game state when the player uses/attempts to use an item. The player’s action (attempts/using an item) must be carried out first, thenenemy movement. As soon as the item is used, it is removed from the inventory.
IllegalArgumentException:
If itemUsed is not a bomb, invincibility_potion, or an invisibility_potion
InvalidActionException:
If itemUsed is not in the player’s inventory
1 public DungeonResponse tick(Direction movementDirection
1 public DungeonResponse build(String buildable) 2 throws InvalidActionException
Builds the given entity, where buildable is one of bow , shield , (Evolved) sceptre , or midnight_armour .
IllegalArgumentException:
If buildable is not one of bow , shield , (Evolved) sceptre ,
or midnight_armour InvalidActionException:
If the player does not have sufficient items to craft the buildable,
or unbuildable for midnight_armour because there are zombies currently in the dungeon.

3.3 Interface Methods (Evolved) 3.3.1 Persistence
Method Prototype
1 public DungeonResponse saveGame(String gameName)
1 public DungeonResponse loadGame(String gameName)
1 public List allGames()
3.3.2 Time Travel
3.3.3 Dungeon Generation
3.4 Server Layer
Description
Saves the current game state with the given name so that if the application is terminated, the current game state can be reloaded and play can continue from where it left off.
Loads the game with the given name from the existing games saved.
Returns a list containing all the saved games that are currently stored.
Description
Description
Exceptions
IllegalArgumentException:
If gameName is not a valid game name
Exceptions
Exceptions
Method Prototype
1 public DungeonResponse rewind(int ticks)
Rewinds the game state a specified number of ticks.
IllegalArgumentException:
If ticks is <= 0; If the number of ticks have not occurred yet; Method Prototype 1 public DungeonResponse generateDungeon(int xStart, int 2 int xEnd, int yEnd, String configName) Generates a dungeon surrounded by walls in a rectangular grid from the start to the end position on the map, where the start position is the top left corner and the exit is the bottom right corner. An exit will need to be at (xEnd, yEnd) and the player¡¯s starting position will be at (xStart, yStart) . A surrounding wall needs to encompass the dungeon which goes from (xStart - 1, yStart - 1) to (xEnd + 1, yEnd + 1). IllegalArgumentException: If configName is not a configuration that exists If you are completing Time Travel and Dungeon Generation, you will need to add code to App.java which sets up a HTTP endpoint that receives a web request from the frontend to call this API method. The request will be of the following format: Route Name 1 /api/game/rewind/ HTTP Method Data Types Parameters: { ticks: int } Return Type: { DungeonResponse } Parameters: { xStart: int, yStart: int, xEnd: int, yEnd: int, configName: String } Return Type: { DungeonResponse } 1 /api/game/new/generate/ We have handled potential concurrency issues by synchronising all endpoints - you will simply need to need to wrap your function call in the endpoint you create using callUsingSessionAndArgument . The existing endpoints are a good place to start when writing this code. 1 public DungeonResponse interact(String entityId) 2 throws IllegalArgumentException Interacts with a mercenary (where the Player bribes/mind controls [Evolved] the mercenary) or a zombie spawner, where the Player destroys the spawner. IllegalArgumentException: If entityId is not a valid entity ID InvalidActionException If the player is not within specified bribing radius to the mercenary, when they are bribing If the player is not cardinally adjacent to the spawner, if they are destroying a spawner (Evolved) If the player does not have enough gold and does not have a sceptre and attempts to bribe/mind-control a mercenary If the player does not have a weapon and attempts to destroy a spawner 3.5 Interface Exceptions The only two exceptions throwable by the Controller are: IllegalArgumentException (an builtin unchecked exception) on the specified conditions; and InvalidActionException (a custom-defined checked exception inside src/main/java/dungeonmania/exceptions ). You can throw them in any order you like, we will not test any input that would fit multiple exceptions at the same time. 3.6 Other Interface Files DungeonManiaController.java DungeonResponse.java , EntityResponse.java , GenericResponseWrapper.java , and ItemResponse.java Scintilla.java and auxiliary files; Environment.java , PlatformUtils.java , and WebServer.java InvalidActionException.java src/main/java/dungeonmania/DungeonManiaCon troller.java src/main/java/App.java src/main/java/dungeonmania/response/models / src/main/java/scintilla src/main/java/dungeonmania/exceptions Description Contains one method for each command you need to implement. Runs a server for Dungeon Mania. See Section 3.1. Contains a small custom built wrapper around Spark-Java for running a web server. When run it automatically opens a web browser. A checked exception to throw when an invalid action is attempted (See Section 3.5). Should you need to modify this? Yes. Only if completing Time Travel/Dungeon Generation. No - do not modify this class as we will be relying on it during automarking. Position.java , Direction.java , and FileLoader.java src/main/java/dungeonmania/util/Position.j ava , src/main/java/dungeonmania/util/FileLoader .java , and src/main/java/dungeonmania/util/Direction. java See Section 3.1. No - do not modify these as we will rely on them being the same in automarking. 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com