diff --git a/README.md b/README.md index e845dba0d61751ba69a9901b675eb4ee0f4eaa76..98df084775924383ad86f88a69c8b498cefbfec3 100644 --- a/README.md +++ b/README.md @@ -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`. +## 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 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 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). diff --git a/tc-maker/format.py b/tc-maker/format.py index 63356532d34fdc3b92b12e2bd20c2922a0810c2b..11c5ace22b72c846947cd4755aaa7244a6dc4600 100644 --- a/tc-maker/format.py +++ b/tc-maker/format.py @@ -1,18 +1,21 @@ -def process_console_output(input_file, output_file): - with open(input_file, 'r') as infile, open(output_file, 'w') as outfile: +def process_console_output(input_file, output_file, console_input_file): + with open(input_file, 'r') as infile, open(output_file, 'w') as outfile, open(console_input_file, 'w') as con_infile: outfile.write("> \n") lines = infile.readlines()[2:-2] for line in lines: # add "> " at the beginning of every line if line does not start with "> " - if line.startswith(">") : + if line.startswith(">"): # replace "> " with "? > \n< " + con_infile.write(line[2:]) line = line.replace(">", "? > \n<") else: line = "> " + line outfile.write(line) + if __name__ == "__main__": input_path = 'output.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) diff --git a/tc-maker/input.txt b/tc-maker/input.txt new file mode 100644 index 0000000000000000000000000000000000000000..59a09cdcbb7229c891a66fc3b19df84bcc7a2c06 --- /dev/null +++ b/tc-maker/input.txt @@ -0,0 +1,56 @@ +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 diff --git a/testcases/tests/24/input.txt b/testcases/tests/24/input.txt new file mode 100644 index 0000000000000000000000000000000000000000..4c996bfc54a6c590250f432762ec4a752107a0bb --- /dev/null +++ b/testcases/tests/24/input.txt @@ -0,0 +1,56 @@ +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