Commit c5660c7
Add MazeGenerator exercise and related tests (#2355)
* Add MazeGenerator exercise and related tests
This commit introduces a new MazeGenerator class along with related Units Tests. It also adds the `Dimensions` record to represent the size of the maze. Both MazeGenerator and Dimensions classes are incorporated into the build.gradle file. For testing purposes, MazeGeneratorTest along with its configuration file and a test reference were incorporated.
This change allows generating perfect mazes of a specified size with a single correct path, ideal for maze navigation tasks. Can produce random mazes or reproducible ones when provided with a seed. The mazes are represented using box-drawing characters and the entrances/exits are denoted by an arrow symbol(⇨).
* Update exercises/practice/mazy-mice/src/main/java/MazeGenerator.java
Co-authored-by: Sander Ploegsma <[email protected]>
* Update exercises/practice/mazy-mice/src/main/java/MazeGenerator.java
Co-authored-by: Sander Ploegsma <[email protected]>
* Update mazy-mice exercise metadata configuration
The config.json file for the mazy-mice exercise has been improved to include the new 'invalidator' field. This field references the build.gradle file which is used for the construction and testing of the 'MazeGenerator' example. With this addition, users are now able to work with the MazeGenerator class and its related unit tests in their local environment with ease.
* Improve grammar in mazy-mice exercise instructions
Minor grammatical correction has been made in the mazy-mice exercise documentation. Prior sentences were changed from "The small square maze" and "The rectangular maze" to "A small square maze" and "A rectangular maze" respectively, to improve sentence flow and clarity for users.
* Update placeholder in hints.md
The placeholder comment in the 'hints.md' file for the mazy-mice exercise has been replaced with the 'Hints' header. This change is essential for creating a more meaningful start to the document and improving the clarity for users trying to understand maze generation.
* Refactor test method name for clarity
The test method name 'the_dimensions_are_correct' in MazeGeneratorTest has been refactored to 'theDimensionsAreCorrect'. This is in line with Java's camelCase naming convention, improving readability and maintaining a consistent code style.
* Update test method name to reflect logical assertion
Updated the name of the test method in MazeGeneratorTest from 'twoMazesShouldNotBeEqual' to 'aMazeIsDifferentEachTimeItIsGenerated'. The new name better indicates the purpose of the test, which is to check that every maze generated is unique.
* Add 'mazy-mice' to settings.gradle
Included 'practice:mazy-mice' in the settings.gradle to extend the diversity of exercises. This step is necessary for building and running the 'mazy-mice' exercise.
* Add new "mazy-mice" exercise to config.json
A new exercise named "mazy-mice" has been added to config.json. This exercise, which involves character arrays and string handling with for-loops, is intended to diversify the exercise list and give users more exercise choices. The difficulty of this exercise has been set to 8.
* Refactor maze generation and test methods for readability
The methods for maze generation have been refactored to directly accept individual parameters for 'rows' and 'columns' instead of a 'Dimensions' object. This change simplifies the method calls and enhances code readability. Also, updated the corresponding test cases to adhere to the new method signature. Additionally, added enumeration for directions at the end of the test class to improve code organization and readability.
* Add descriptions to auto-generated test cases
An auto-generated 'tests.toml' file is introduced. The descriptions added provide information for each test key about the attributes and functionality that is being tested. These include correct dimensions, valid characters, proper locations of entrances and exits, and generation of mazes with or without a seed parameter. These descriptions help developers understand the purpose of the tests and correct functioning of the maze.
Also, change method names and orders to make the test easier to follow. This allows the clearer reading of the tests, thus increasing productivity. It helps maintainers to spot and understand the new changes faster and easier. Minor changes, such as capitalisation corrections, are also made for improved readability.
* Change access modifier for test methods in MazeGeneratorTest
This commit changes the access modifier of all test methods in the `MazeGeneratorTest` class from default to public.
This necessary change, switching to public, allows JUnit to access the test methods. Previously, due to default access level it could cause issues with the test runner and result in no tests being executed. Access modifiers were also applied to the `setup` method to ensure it properly annotated before each test run. Making these methods public improves test functionality and ensures they are recognized as legitimate JUnit tests.
* Add additional hints for exercise in hints.md
This commit adds important hints in the hints.md file for the 'mazy-mice' exercise. It introduces useful general information regarding the generation of random numbers in Java 17 including links to valuable resources. This could help participants to understand better how to deal with random numbers and thus can improve the exercise's learning objectives.
* Add a new test for seeded maze generator
This commit added a new test case to the MazeGeneratorTest file. The added test, "theMazeIsPerfectWithSeed", simulates a perfect maze generation with a predefined seed. This test aims to help to ensure that the maze generator can correctly use seed to produce the expected unique maze structure. This also enhances the test coverage and further ensures the robustness of the maze generating code.
* Add tests for maze size validation
In this commit, 4 new tests have been added to the MazeGeneratorTest in order to check the validity of size parameters passed to the 'generatePerfectMaze' function. These tests ensure that both rows and columns parameters are within acceptable range (5-100) by throwing an IllegalArgumentException if they are not.
* Add maze dimensions validation to the MazeGenerator class
Dimension validation methods have been included in the maze generation methods of the MazeGenerator class. This is to ensure that the rows and columns of the maze are within an acceptable range (5-100). If these values fall out of the given range, an IllegalArgumentException is thrown. This was introduced to prevent the generation of mazes that would be too small or too big, which could lead to performance issues or unplayable mazes.
* Revise header formatting in instructions.md
The heading formatting in the instructions.md document within the mazy-mice exercise directory has been revised. The markdown format was adjusted from using "##" to make it a sub-heading, to "#" to make it a top level heading. This change has been implemented for clarity and readability, making it easier for users to understand the structure of the document.
* Remove redundant .meta/tests.toml file
* delete version file
* Remove Dimensions.java as its functionality is redundant
The file Dimensions.java was deleted because its purpose - to represent the dimensions of a maze - is already covered by another class in our program. Its functionality including width and height calculations, which were previously done in cells, are now handled elsewhere, making this file unnecessary.
* Update exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Co-authored-by: Sander Ploegsma <[email protected]>
* Update exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Co-authored-by: Sander Ploegsma <[email protected]>
* Update config.json to include new practices
Added "strings" and "for-loops" to the "practices" array in the config.json file. This change is necessary to ensure all necessary learning concepts are being covered within the curriculum.
* Add new game "Mazy Mice" in config.json
The new game "Mazy Mice" with corresponding uuid, practices, prerequisites, and difficulty level was added to the config.json. This is essential for including a new game in the curriculum that emphasizes the application of "strings" and "for-loops" practices.
* Add Dimensions.java to Mazy Mice example files
Included "Dimensions.java" in the example files array for the "Mazy Mice" problem in config.json, as it is needed for the correct generation of the maze. Not including this could lead to errors or incomplete solutions.
* Remove redundant mazeNotNull test in MazeGeneratorTest class
The mazeIsNotNull test in MazeGeneratorTest class was removed as it was deemed unnecessary and redundant. The null check is already implicitly covered in the subsequent dimensions and valid characters tests.
* Refactor MazeGeneratorTest for better test organization
Moved `Direction` enum to the top of the MazeGeneratorTest class to improve code organization and readability. Adjusted dimensions test to use Arrays.stream for enhanced test flow and comprehension. Removed redundant mazeNotNull test.
* Add status field to config.json
---------
Co-authored-by: Sander Ploegsma <[email protected]>1 parent 8425a9c commit c5660c7
File tree
11 files changed
+612
-0
lines changed- exercises
- practice/mazy-mice
- .docs
- .meta
- src/reference/java
- src
- main/java
- test/java
11 files changed
+612
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
1986 | 2003 | | |
1987 | 2004 | | |
1988 | 2005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
Lines changed: 185 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments