-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MazeGenerator exercise and related tests #2355
Conversation
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(⇨).
I just realized that the latest pull request contains a new version of the JUnit library. Should I use JUnit 5 for the new exercise? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! This sounds like a fun and challenging exercise.
I left some inline comments for you to look at. Apart from those, these points should be addressed before this can be merged:
- The exercise should be added to the
config.json
at the root of this repository. This is where the exercises are sourced from on exercism.org, so it won't be available to anyone unless it's in there. - The exercise's Gradle project should be added to
exercises/settings.gradle
. This will include it in the CI build as well. - Depending on whether Add Mazy Mice Exercise to the Repository problem-specifications#2312 is merged before this, I suggest adding
.meta/tests.toml
as described in the documentation: https://exercism.org/docs/building/configlet/sync#h-tests
exercises/practice/mazy-mice/.meta/src/reference/java/Dimensions.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
Support for JUnit 5 is being added in exercism/java-test-runner#61. It will support both JUnit 4 and 5 so for now I would suggest to keep using JUnit 4 like the other practice exercises. |
Co-authored-by: Sander Ploegsma <[email protected]>
Co-authored-by: Sander Ploegsma <[email protected]>
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.
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.
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.
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.
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.
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.
done |
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.
done |
@rabestro are you still actively working on this? |
Yes. I'm on vocation now and I will continue in November. |
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.
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.
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.
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.
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.
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.
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.
Thanks for taking care of everything! I will need a moment to review it, I hope to get to it in the coming week. Just know that it’s on my to-do list! 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for processing the comments! I have found some more things to address though, could you have a look at them?
exercises/practice/mazy-mice/.meta/src/reference/java/Dimensions.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
exercises/practice/mazy-mice/src/test/java/MazeGeneratorTest.java
Outdated
Show resolved
Hide resolved
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.
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.
Co-authored-by: Sander Ploegsma <[email protected]>
Co-authored-by: Sander Ploegsma <[email protected]>
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.
# Conflicts: # 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.
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.
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! I think this would make a great addition to the Java track.
Can I ask you to add one more thing before we merge? Since this exercise is new on Exercism, I'd like to mark it as beta so that students on the website are asked to provide feedback on it. You can do this by adding the property "status": "beta"
to the exercise object in the config.json
at the root of this repo.
done |
Introduction
Meet Mickey and Minerva, two clever mice who love to navigate their way through a maze to find cheese. They enjoy a good challenge, but with only their tiny mouse brains, they prefer if there's only one correct path to the cheese.
Instructions
Your task is to generate the perfect mazes for Mickey and Minerva — those with only one solution and no isolated sections. Here's what you need to know:
It's time to create some perfect mazes for these adventurous mice!
Examples
Hints
General
rand
numeric function can generate random numbers.srand
numeric function will be helpful to set the seed forrand
.Maze generation
You can use any algorithm to generate a perfect maze. The recursive backtracker is a good choice.
Box drawing characters