User Stories - OSU-CS361-W17/group20_project1 GitHub Wiki
User Story 1 - Getting the coordinates for firing
Card: As a user, I want the AI and myself to be able to pick out coordinates to fire at, so that I can shoot at a specific square on the board.
Conversation:
- When the user chooses where to fire coordinates will be received from the form on the web page, so that the user can pick where they want to fire.
- The AI can't think about where to fire at, but will instead pick random coordinates.
- The coordinates should be between 1-10 in order to function, so this should be incorporated and tested.
Confirmation:
This user story will be confirmed by the following method in MainTest.java:
- testFireAt()
The user story is finished when the function will place values between 1 and 10 into the variables "row" and "col". If the function itself succeeds in communicating with the web page, then the variable assignment has succeeded.
testFireAt() is shared between this user story and user story two. This is because both user stories cover different parts of the firing feature, but exist in the same function.
User Story 2 - Using firing coordinates to record hit or miss
Card: As a user, I want to know when hits or misses occur, so that I can see the results of my firing and know when the game has been won.
Conversation:
- A check will be made to determine if the coordinates chosen (by the AI or user) will hit or miss a ship on the board.
- Data will be stored in arrays for hits and misses so that they are monitored for the user.
- Results of hits and misses will be sent to and shown on the board via different coloratiins for the user to see.
- The user will know when they have won when all the opponent ships are red.
Confirmation:
This user story will be confirmed by the following method in MainTest.java:
- testFireAt()
testFireAt() is shared between this user story and user story two. This is because both user stories cover different parts of the firing feature, but exist in the same function.
User Story 3 - User places ships on the board
Card: As a user, I want to be able to place my ships on the board, so that I can choose my ship placement strategy each time I play.
Conversation:
- If a ship is already placed on the board, it should not be able to be placed again.
- The ship placements cannot overlap.
- The ship should not be placed off of the board.
Confirmation:
To test that this user story works, it will be confirmed with a test in MainTest.java with:
- testPlaceShip()
A test response request will be sent to the placeShip() function with the name of the ship, row and col placement, and whether it is vertical or horizontal. The function will then run its course, and we will then also visually verify that what is returned from the function matches our expected output.
User Story 4 - Random placement of AI ships
Card: As a user, I want the AI to place its ships randomly on the board for each game, so that the game is new and challenging each time I play.
Conversation:
- If the computer doesn't randomize its ships, the user will get bored very quickly because they will learn where the ships are after only a few playthroughs. So, randomizing the AI's board supports replayability.
- This doesn't have to be "true random" - so we can randomize based on the system clock, as is usual in programs.
- We'll need to make sure that the ships are actually hittable by the user (i.e. that they don't get placed halfway off the board or something), because if they can't be hit, the user will likely get frustrated.
- If we don't take care in placing the ships, the game could potentially be unwinnable for the user.
- In the same vein, ships shouldn't be allowed to overlap.
- One idea (if there is time) is to implement something to make sure all the ships aren't scrunched into a corner or all next to each other. On the other hand, we might not - it would be more "random" if we didn't.
- The user shouldn't have to do anything to make the AI randomize - it should just do it (at the appropriate point) when the game starts.
- This functionality will probably never be seen or considered explicitly by the user, but it will support the user's experience in such a way that it is valuable and interesting to them.
- The user will benefit from this by getting a novel experience each time they play.
Confirmation:
This user story will be confirmed by the following method in MainTest.java:
- testGetModel()
This is an appropriate location for the test since the AI's ships are generated when the model is created.
Since the placement is random, we can't exactly test against a "known" value for a ship's coordinates. Instead, we created a test to check that the ship placement's randomization component is functional and able to take on values that cover the entire board.
The test sends a GET request to the server asking for a model 500 times (i.e. we generate 500 different models with 500 different AI ship placements). We store the largest and smallest values of a ship's coordinates from these 500 models in variables. Then, we assert that the largest value a coordinate took was equal to 10, and that the smallest was equal to 1 - essentially ensuring that the ships were placed in various places on the board, from the first to last possible coordinate. If these asserts pass, we know that the AI function does indeed place the ships randomly.
There is a very small chance that this test fails if the randomization function doesn't output 1 or 10 at any point, which is certainly possible. However, with a sample size of 500 tests, this is very unlikely. We could run the test on a larger sample size, but it would take a longer amount of time to run the test.