Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit a28dcc2

Browse files
committed
finished!
1 parent 9eecc0f commit a28dcc2

File tree

4 files changed

+142
-268
lines changed

4 files changed

+142
-268
lines changed

BattleShip/manuals/manual.md

Lines changed: 86 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -1,297 +1,169 @@
11
# Manual
22

3-
This is the user manual of Conway Game of Life simulator.
3+
This is the user manual of BattleShip Game.
44
You may find detail program usage and error message explanation here.
55

6-
# CLI
7-
8-
## Examples Args
9-
10-
Please replace `...` with commands corresponed to your OS specify in `readme.md`.
11-
12-
```bash
13-
... tests/example1.txt tests/result/example1 21
14-
... tests/example2.txt tests/result/example2 5
15-
... tests/example3.txt tests/result/example3 50
16-
```
17-
18-
### Linux Example
19-
20-
Here is how linux system should run the args, an example.
21-
22-
```bash
23-
sh scripts/run.sh
24-
sh scripts/run.sh tests/example1.txt tests/result/example1 21
25-
sh scripts/run.sh tests/example2.txt tests/result/example2 5
26-
sh scripts/run.sh tests/example3.txt tests/result/example3 50
27-
sh scripts/run.sh tests/invalid1.txt tests/result/example1 1
28-
sh scripts/run.sh tests/invalid2.txt tests/result/example1 1
29-
sh scripts/run.sh tests/invalid3.txt tests/result/example1 1
30-
sh scripts/run.sh tests/invalid4.txt tests/result/example1 1
31-
sh scripts/run.sh tests/invalid5.txt tests/result/example1 1
32-
sh scripts/run.sh tests/invalid5.txt tests/result/example1 -1
33-
```
34-
35-
### Bad Examples
36-
37-
```bash
38-
... tests/invalid1.txt tests/result/example1 1
39-
Err: [seedFile] Invalid row/col, must be positive integer larger than 2
40-
... tests/invalid2.txt tests/result/example1 1
41-
Err: [seedFile] Invalid row/col, must be positive integer larger than 2
42-
... tests/invalid3.txt tests/result/example1 1
43-
Err: [seedFile] Unexpected cell type 2
44-
... tests/invalid4.txt tests/result/example1 1
45-
Err: [seedFile] Unexpected col length at row index 1
46-
... tests/invalid5.txt tests/result/example1 1
47-
Cannot invoke "String.split(String)" because "<local1>" is null
48-
... tests/example3.txt tests/result/example1 -1
49-
Err: [input] step -1 is invalid
50-
```
51-
52-
## Screenshot
53-
54-
Here is an example screenshot of how it looks like when program runs, we will talk about each arguments in the following sections.
55-
56-
![](./screenshot.png)
57-
58-
### Basic Usage
59-
60-
If incorrect/missing arguments given, the following message will occur.
61-
62-
```bash
63-
$ sh scripts/run/sh
64-
Args: <input> <output> <step>
65-
```
66-
67-
## Inputs
68-
69-
In this section, program usage will be presented, as well as input file format.
70-
71-
### Command line
72-
73-
Please refer to `readme.md`, looking for commands for your OS. Here each argument will be explained in details.
74-
75-
#### `<input>`
76-
77-
The path to the seed file. The file format is defined below.
78-
79-
##### Input File format
80-
81-
- The first line contains, in order, the number of rows, and the number of columns in the grid, separated by a comma and a space. E.g., 5, 7 means that there are 5 rows and 7 columns in the grid. There are no spaces after the number of columns.
82-
- All lines starting from the second one contain the state of one row in the grid, starting with row #0. The state of each cell is designated with either 0 (cell is dead) or 1 (cell is alive). The states of individual cells are separated by a comma followed by a space (there is no comma and/or space after the last 0 or 1 in the line). For example, if the third line of the file (the second line of the grid part of the file) is 0, 0, 0, 1, 0, 0, 0 it corresponds to the following cell states in row[1]: row[1][0], row[1][1], row[1][2], row[1][4], row[1][5], and row[1][6] are dead, and row[1][3] is alive.
83-
- All lines end with the new line character.
84-
85-
###### Example
86-
87-
```
88-
5, 7
89-
0, 0, 0, 0, 0, 0, 0
90-
0, 0, 0, 1, 0, 0, 0
91-
0, 0, 0, 1, 1, 1, 1
92-
1, 0, 0, 0, 1, 1, 1
93-
1, 1, 1, 1, 1, 1, 1
94-
```
95-
96-
You may find more examples under `tests/` folder.
97-
98-
#### `<output>`
99-
100-
The path to the directory where results should be stored. If the directory does not exist, program will generate all necessary parent directories. Each file inside the directory will follow the following format:
101-
102-
```
103-
<seedFilename>.<currentStep>.txt
104-
```
105-
106-
The `currentStep` will be started from `0`, the origin seed file, and will end in given `<step>` parameter.
107-
108-
##### Output File Format
109-
110-
111-
The output file example may be found at `tests/result/`. The format of the file is the same as the input file.
112-
113-
114-
#### `<step>`
115-
116-
The number of step the simulation should run. This should be a positive integer.
117-
118-
## Errors
119-
120-
Here we have listed some possible errors when using the program and what could you do when you have encountered them.
121-
We have also provided some good and bad examples in next section.
122-
123-
### `Err: [io] Output path must be a directory`
124-
125-
The specified `<output>` exists and is not a directory. Please specify another available location.
126-
127-
### `Err: [io] Failed to create output directory`
128-
129-
The specified `<output>` does not exist, but program failed to create corresponded parents directories. Sometimes it may be system error, but please ensure the path enter is valid for your current OS.
130-
131-
### `Err: [input] step x is invalid`
132-
133-
This happened when step is less than 0. Please specify a number equal to or larger than 0.
134-
135-
### `An error occur while processing files: `
136-
137-
An `IOException` occurs. Possibly due to non-existence of a specified file, or other system issue. Please read stack for more info.
138-
139-
### `Err: [input] unable to parse "x" as integer`
140-
141-
Either seed file row/col or step is not a valid integer representation. Please double check your input.
142-
143-
### `Err: [seedFile] unable to identify row/col of the map`
144-
145-
The first line of the seed file doesn't follow the `row, col` format and can't be parsed.
146-
147-
### `Err: [seedFile] Invalid row/col, must be positive integer larger than 2`
148-
149-
Row or column integer representation in the seedFile is invalid.
150-
151-
### `Err: [seedFile] Unexpected col length at row index x`
152-
153-
When reading seed file, a row is missing some cell representation. Please check if your file is corrupted.
154-
155-
### `Err: [seedFile] Unexpected cell type x`
156-
157-
When reading a specific cell in the seed file, program cannot recognize its status. Please refer to file format section for the correct types.
158-
159-
### `Cannot invoke "String.split(String)" because "<local1>" is null`
160-
161-
Seed file is possibly empty. Please check if correct seed file is given.
162-
1636
# GUI
1647

1658
## Starting GUI
1669

167-
To start GUI, follow the command in `README.md` and when you see console appears: `Starting GUI...`. The application has now started. It may take a while for the application window to show.
10+
To start GUI, follow the command in `README.md`. It may take a while for the application window to show.
16811

169-
## Basic Usage
12+
## Basic Steps
17013

171-
The appearance of the Application may varies on different platforms. For example, on Linux, it may look like this:
14+
### Set up a Server
15+
16+
In order to start a game, first a server needed to be set up.
17217

17318
![](./gui/manual/1.png)
17419

175-
On Windows:
20+
Choose server mode and enter all necessary information. Then the server side will notice await client connection.
17621

177-
![](./gui/manual/2.png)
22+
Then, open up another program with Client mode. Here is an example of information will be asked when starting program as client
17823

179-
The functionality should be the same, however.
24+
![](./gui/manual/2.png)
18025

181-
### Simulation status
26+
#### Player name limitation
18227

183-
The bottom line of the application indicate whether the simulation is in progress. For example, on the graph above, the simulation is `Ready to Start`, once you have tried to go to other stage (by clicking `<<` or `>>` on the top, type number on the box between the buttons), the status will changed into `simulation in progress...`. The cell status will update in real time you switch to different stage/map
28+
Player name can now only use character in a-zA-Z0-9 with length 1-20. Program will repeatedly ask for info if standard not met.
18429

185-
### Change cell status
30+
Right now, the server and the client may have the same player name. **It is recommended that different name used during game play**
18631

187-
There are two ways to change map status:
32+
#### Network Issue
18833

189-
- Load file using File menu on the top
190-
- Manually click the map
34+
However, if you enter wrong network information (address/port). The program will fail and exit
19135

192-
Each of the block is clickable, and you may toggle the cell status (live or dead). However, this action can only be done before the simutaion has started. You will see a warning if you tried to change the stage when simulation is in progress.
36+
### Main Frame
19337

194-
**Notice: You may find cell survival time > current tick index, that's because App counts initial LIVE cell with 1 tick survival time**
38+
When client and server finished syncing, the main frame will be shown as following.
19539

19640
![](./gui/manual/3.png)
19741

198-
#### Set as Begin
42+
The left board will be self player board, where ship will be set using it. The right board will represent enemy's board and self player will hit target using that board.
19943

200-
However, if you still want to edit the map, you may use the button `Set as Begin` on the toolbar located on the left side of the map. This function will set the current map as a new round of simulation so that you can edit the map and run the simulation from that point.
44+
#### Set Ship
20145

202-
**Notice: this action will clear all survival times, previous maps, etc. and only keeps the cell statuses.**
46+
In order to get started, both player needs to set up the ships on their board first. To set ship, click on any cell where you would like the ship to have. The cell you clicked will be the head of the ship.
20347

48+
There will be two follow-up dialogs allows you to:
20449

205-
#### Reset
50+
- choose which ship to add
51+
- choose ship direction
20652

207-
If you want to reset the map but keeps the map row/col, click the button and a blank map will be set
53+
![](./gui/manual/5.png)
20854

209-
#### New Map
55+
After setting a ship, board will show the corresponded cell using 'X' sign. In order to remove a ship from the location, click the cell with 'X' sign, and it will remove the ship at that location. The cell does not necessary to be the head of the ship.
21056

211-
If you want to manually set the map, click the button and enter the row and col you want accordingly. It will create an empty map with given size for you. Please note that all existing cell/map data will be destroyed.
57+
![](./gui/manual/6.png)
21258

213-
### Load&Save
59+
When all ships are set, any further clicks will bring to the following:
21460

215-
You may also load and save the result for future usage. You may find these actions under `File` Menu.
61+
![](./gui/manual/7.png)
21662

217-
The file format could be found above #CLI Input section
63+
#### Start the turn
21864

219-
#### Load file
65+
Once you are ready, click on the ready button on the left. Once both side are ready, the following notice will appear:
22066

221-
When you click `Open file...`, a dialog will appear and ask for the file you want to load. If the file you choose cannot be loaded, an error message will appear
67+
![](./gui/manual/8.png)
22268

223-
![](./gui/manual/4.png)
69+
Now the game has officially started. The turn and time will be shown on the status board below
22470

71+
![](./gui/manual/9.png)
22572

226-
You may consult #CLI Error section for more info
73+
When it is your turn, click on the enemy board that haven't been discovered, and if there is a ship, an 'X' will show on the cell.
22774

228-
#### Save file
75+
![](./gui/manual/11.png)
22976

230-
When you click `Save Current map as...`, a dialog will ask for name and location to save the file.
77+
And on the enemy point of view, they will see the block discovered like the following:
23178

232-
`Save range of maps as...`, however, will prompt a sub panel, asking for more information. Please type the start range and end range accordingly.
79+
![](./gui/manual/10.png)
23380

234-
![](./gui/manual/5.png)
81+
The win condition will be:
23582

236-
##### Filename format
83+
- The first player revealed all enemy's ship
84+
- The enemy didn't make a move during given time frame
23785

238-
Since there may be multiple files generated at this point, to avoid overwriting result, string `%1d` in the filename format will be replaced with map index.
86+
Once one of the conditions is met, a result page will show and both players can decide whether to move to next game or not. The first player click the next game will be prompted the following:
23987

240-
Click save button and choose a directory. Please be sure the directory **does not** contain other files with names that has the same output pattern, or it might be overwritten.
88+
![](./gui/manual/12.png)
24189

242-
You may change the range save multiple different range. Once you have done, simply close the window by clicking the X on the top right.
90+
Once the enemy decided next game, click on OK to move start the new game.
24391

92+
### Configuration
24493

245-
### Configuration
94+
![](./gui/manual/4.png)
24695

24796
You may change the UI of the application by editing configuration. To open configuration panel, you may use the `Settings` button on the toolbar, or the `Configuration` button under `Actions` menu.
24897

249-
![](./gui/manual/6.png)
98+
Please do not edit settings during game turn.
99+
100+
Notice:
250101

102+
- **`Grid Size` and `Time Limit` will be sync from the server if program started with client mode.**
103+
- All changes will take effective after program restart
251104

252105
#### Colors
253106

254-
You may change the color of based on cell status, and the text color over it. Simply click the color blocks on the right column, and a color chooser will appear.
107+
You may change the color of based on cell status, and the text/mark color over it. Simply click the color blocks on the right column, and a color chooser will appear.
255108

256109
Once you have decided a color, click ok, and you may find the map appear changed at the same time.
257110

258-
#### Survival Time
111+
Notice: **All color configuration won't be sync with the client**
259112

260-
Click the checkbox to toggle number on the cell. You may find there is an update delay when there are many cells.
113+
#### Time limit per round
261114

262-
#### Shade Level
115+
Time (in second) each move needs to be done. Min second allowed is 5.
263116

264-
If a cell is surviving a long time, its color will get darker and darker. However, to avoid color being too dark and hard to distinguish, the Shade level here will categorize cells' survival time, and the total ticks passed. If the cell has survived most of the ticks, it will be X times darker than the new cells, where X is the setting value. The less the lighter (E.g. X - 1 times, but stop at 1). This value only defines the maximum it can reach.
117+
#### Grid Size
265118

266-
When the value is 1, no shade will apply. This number must be a positive number, or a warning will appear.
119+
The size of the grid. When clicked, a dialog will prompt current settings, and you may change at this point. Row and col must be larger than 0, and the total number of cell must be at least 17 so that all ships can fit in the grid.
267120

268121
---
269122

270123
Once you have finished set up, you may close the configuration by clicking X on the top right. **Your changes will be saved immediately after you have changed the value. For text field, please press ENTER to confirm your decision.**
271124

272125
### Typing and number
273126

274-
For shade level and ticks to go to, the input box accept a number. **Please press enter to confirm** and if the input given cannot be parsed as a valid number, a warning will be given. Please double check your input and try again.
127+
For input box accept a number. **Please press enter to confirm** and if the input given cannot be parsed as a valid number, a warning will be given. Please double check your input and try again.
275128

129+
## Error Messages
276130

277-
## Extra Tips
131+
Here are some examples of the error messages
278132

279-
### Toolbar can be dragged away from the main panel
133+
- Ship overlapped
134+
- When set the ship, there are another ships already block the way. Please double check your input
135+
- Please wait for your turn
136+
- When you click the enemy board when it is not your turn, this warning will be given
137+
- Invalid Coordinate
138+
- Some part of the ship will be out of the map range, please double check your input
280139

281-
By holding the gray bar on the left side panel, you may drag the panel to another desire location and expand your working space.
282140

283-
![](./gui/manual/7.png)
141+
### Limitations
284142

285-
If you want to restore the layout, simply click the X you the right top, and it will go back to the main frame.
143+
Currently, there are some limitation/inconsistency you may find during game play
286144

287-
### Survival time emitted
145+
#### Unstable network
288146

289-
Sometimes you may find that the cells' survival time cannot fit the UI and won't show correctly. In this case, you may hover your mouse to the cell and its exact number will appear.
147+
This game currently does not tolerate any network issue including latency larger than 2 seconds. You may find game behave abnormally if using under bad network condition
290148

291-
![](./gui/manual/8.png)
149+
#### Client/Server Exit
150+
151+
If either Client/Server exited during game play, the other side won't be notified, and their game will freeze.
152+
153+
#### Starting game
154+
155+
The starting notice mentioned above **may postponed for around 3 seconds after both side are ready due to be some final data synchronization and time frame adjustment.**
156+
157+
#### Notification
158+
159+
Please dismiss any Dialog as quick as possible, as it may block the game process. Failed to do so may lead the game out of sync.
160+
161+
#### Time count
162+
163+
Currently, time limits are counted by the players themselves. There may be around 1-2 seconds display delay, but the real time count should still be correct.
292164

293-
### Slow initialization time
165+
### Long initialization time
294166

295-
When the program is generating maps (new map, loading file), it might be slow to response. Please be patient.
167+
When the program is generating maps (new map), it might be slow to response. Please be patient.
296168

297-
After initialization, it is expected to have faster response time. The suggested size of the map is no larger than (200x200)
169+
The suggested size of the map is no larger than (30x30)

BattleShip/manuals/manual.pdf

461 KB
Binary file not shown.

0 commit comments

Comments
 (0)