Skip to content
Snippets Groups Projects
Commit c3684acf authored by Kier, Kilian's avatar Kier, Kilian
Browse files

input.txt maker

parent 3b31087f
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,10 @@ To run these testcases, copy the content of the [testcases](testcases) folder in ...@@ -10,6 +10,10 @@ To run these testcases, copy the content of the [testcases](testcases) folder in
The new testcases will appear in the Testreport when you run `make test`. The new testcases will appear in the Testreport when you run `make test`.
## Debugging
To debug these testcases you can run your program with the right configs and then you can just copy the whole content of input.txt of the corresponding testcase into your console.
### Debugging random number generation ### Debugging random number generation
To test random numbers better, some testcases include prints of how random numbers are generated, like this: To test random numbers better, some testcases include prints of how random numbers are generated, like this:
...@@ -42,6 +46,6 @@ script -c "clear && ./a2 configs/dungeon_config.txt configs/story_config.txt" ou ...@@ -42,6 +46,6 @@ script -c "clear && ./a2 configs/dungeon_config.txt configs/story_config.txt" ou
NOTE: This command should be executed in the tc-maker directory. Also, you may NEVER press backspace (löschen) as it messes the output up. NOTE: This command should be executed in the tc-maker directory. Also, you may NEVER press backspace (löschen) as it messes the output up.
This will then create a file called `output.txt` with the output of your program. After that, we need to bring the output into the correct format. For that, I created a python script [format.py](tc-maker/format.py). You can run it with `python3 format.py` in the tc-maker directory. This will create a new file `io.txt` with the correct format. There are example files for `output.txt` and `io.txt` to get an idea of what it should look like. This will then create a file called `output.txt` with the output of your program. After that, we need to bring the output into the correct format. For that, I created a python script [format.py](tc-maker/format.py). You can run it with `python3 format.py` in the tc-maker directory. This will create 2 new files `io.txt` and `input.txt` with the correct format. There are example files for `output.txt`, `io.txt` and `input.txt` to get an idea of what it should look like.
Now you can move the `io.txt` file into the correct folder (e.g. `testcases/tests/19/`) and add the testcase to the `test.toml` file (just copy and paste an existing testcase and change the number+description). Now you can move the `io.txt` and `input.txt` files into the correct folder (e.g. `testcases/tests/19/`) and add the testcase to the `test.toml` file (just copy and paste an existing testcase and change the number+description).
def process_console_output(input_file, output_file): def process_console_output(input_file, output_file, console_input_file):
with open(input_file, 'r') as infile, open(output_file, 'w') as outfile: with open(input_file, 'r') as infile, open(output_file, 'w') as outfile, open(console_input_file, 'w') as con_infile:
outfile.write("> \n") outfile.write("> \n")
lines = infile.readlines()[2:-2] lines = infile.readlines()[2:-2]
for line in lines: for line in lines:
# add "> " at the beginning of every line if line does not start with "> " # add "> " at the beginning of every line if line does not start with "> "
if line.startswith(">"): if line.startswith(">"):
# replace "> " with "? > \n< " # replace "> " with "? > \n< "
con_infile.write(line[2:])
line = line.replace(">", "? > \n<") line = line.replace(">", "? > \n<")
else: else:
line = "> " + line line = "> " + line
outfile.write(line) outfile.write(line)
if __name__ == "__main__": if __name__ == "__main__":
input_path = 'output.txt' input_path = 'output.txt'
output_path = 'io.txt' output_path = 'io.txt'
process_console_output(input_path, output_path) console_input_path = 'input.txt'
process_console_output(input_path, output_path, console_input_path)
2
Player1
W
Player2
B
move w 2,1
move w 2,2
move 2 w,  2,3
move 2,  w 2,4
player W
move w 2,5
attack w 1,5
player w
player b
attack w 1,5
inventory w
move w 1,4
move w 1,3
attack w 4,2
attack w 4,2
attack w 4,2
move w 5,2
move w 4,2
loot w 4,2
inventory 2 w
player w
move b 5,5
move b 4,5
move b 3,5
move b 4,4
move b 3,4
move b 2,4
attack b 1,3
attack b 1,3
loot b 1,3
inventory b
player b
move b 3,2
move b 2,3
move b 2,2
move b 2,1
move b 3,1
loot b 2,1
loot b 1,1
loot b 0,1
loot b 3,1
inventory b
move w 6,3   5,2
move w 6,3
move w 1,5
loot w 1,5
inventory w
move b 3,3
move b 4,2
move b 4,2 1
quit
2
Player1
W
Player2
B
move w 2,1
move w 2,2
move w 2,3
move w 2,4
player W
move w 2,5
attack w 1,5
player w
player b
attack w 1,5
inventory w
move w 1,4
move w 1,3
attack w 4,2
attack w 4,2
attack w 4,2
move w 5,2
move w 4,2
loot w 4,2
inventory w
player w
move b 5,5
move b 4,5
move b 3,5
move b 4,4
move b 3,4
move b 2,4
attack b 1,3
attack b 1,3
loot b 1,3
inventory b
player b
move b 3,2
move b 2,3
move b 2,2
move b 2,1
move b 3,1
loot b 2,1
loot b 1,1
loot b 0,1
loot b 3,1
inventory b
move w 5,2
move w 6,3
move w 1,5
loot w 1,5
inventory w
move b 3,3
move b 4,2
move b 4,1
quit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment