Skip to content
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

Exercise: Mazy Mice #211

Merged
merged 24 commits into from
Aug 29, 2023
Merged

Exercise: Mazy Mice #211

merged 24 commits into from
Aug 29, 2023

Conversation

rabestro
Copy link
Contributor

@rabestro rabestro commented Aug 13, 2023

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:

  • The maze is rectangular, with the outer borders roughly forming a rectangle.
  • The maze has square cells and orthogonal passages intersecting at right angles.
  • The program should accept two parameters: rows and columns. The maze should be between 5 and 100 cells in size.
  • Consider the maze walls by using the formula 2x+1 for the actual width and height, where x is rows or columns.
  • If no seed is provided, generate a random maze. If a seed is provided, get the same labyrinth every time.
  • Use box-drawing characters to draw walls, and an arrow symbol (⇨) for the entrance on the left and exit on the right.

It's time to create some perfect mazes for these adventurous mice!

Examples

  1. The smallest square maze 5x5 cells (or 11x11 characters)
	┌───────┬─┐
	│       │ │
	│ ┌─┬── │ │
	│ │ │   │ ⇨
	│ │ │ ──┤ │
	⇨ │ │   │ │
	┌─┤ └── │ │
	│ │     │ │
	│ │ ────┘ │
	│         │
	└─────────┘
  1. The rectangular maze 6x18 cells
	┌───────────┬─────────┬───────────┬─┐
	│           │         │           │ │
	│ ┌───────┐ │ ┌─┐ ──┐ └───┐ ┌───┐ │ │
	│ │       │ │ │ │   │     │ │   │   ⇨
	│ └─┐ ┌─┐ │ │ │ ├── ├───┐ │ │ ──┼── │
	│   │ │ │   │   │   │   │ │ │   │   │
	└── │ │ ├───┴───┤ ┌─┘ ┌─┘ │ ├── │ ──┤
	⇨   │   │       │ │   │   │ │   │   │
	┌─┬─┴─┐ └─┐ ┌─┐ │ └─┐ │ ┌─┘ │ ──┴─┐ │
	│ │   │   │ │ │ │   │   │   │     │ │
	│ │ │ └── │ │ │ └── │ ──┘ ┌─┘ ──┐ │ │
	│   │       │       │     │     │   │
	└───┴───────┴───────┴─────┴─────┴───┘

Hints

General

Maze generation

You can use any algorithm to generate a perfect maze. The recursive backtracker is a good choice.

Box drawing characters

Character Name Unicode
box drawings light down and right U+250C
box drawings light horizontal U+2500
box drawings light down and horizontal U+252C
box drawings light down and left U+2510
box drawings light vertical U+2502
box drawings light up and right U+2514
box drawings light up and horizontal U+2534
box drawings light up and left U+2518
box drawings light vertical and right U+2520
rightwards white arrow U+21E8

This commit introduces a new algorithm for maze generation in the "maze-generator.awk" file. The code includes essential settings such as rows, columns, and seed initialization. It leverages a recursive backtracking algorithm to create the maze and arranges entry and exit doors. This change was necessary to provide a reliable and customizable maze generation process.
Introduced new tests for the maze-generator, aiming to validate the correctness of the generated mazes. Tests involve a wide range of maze dimensions and scenarios including square, rectangle dimensions, and randomness. The seed parameter's effect on maze generation process is also evaluated. The addition of these tests will help ensure the algorithm performs as expected across different use cases.
In this commit, we have added new tests for the maze-generator module. These tests are aimed at validating the correctness of the generated mazes under different conditions. They involve a wide array of scenarios including different maze dimensions and shapes (square, rectangular), as well as desired levels of randomness. In addition, the tests also evaluate how the seed parameter affects the maze generation process in order to guarantee reproducibility. The addition of these tests will help in ensuring that the algorithm performs as expected across different use cases.
Changed calling of maze-generator.awk to mazy-mice.awk in mazy-mice tests. This is to reflect the renaming of maze-generator.awk to mazy-mice.awk to make names consistent. Also uncommented skip functionality in the tests to ensure they are run during testing process. This highlights that the script being tested matches the name of the test file, increasing code readability and maintainability.
@iHiD iHiD requested a review from a team August 13, 2023 23:14
@iHiD
Copy link
Member

iHiD commented Aug 13, 2023

Thanks! :)

FYI, @glennj will probably want to review this, and he's away on holiday for the next two weeks.

(Also cc @ErikSchierboom)

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on the AWK code, but I've left some general comments.

You'll also want to address the configlet lint error: https://github.com/exercism/awk/actions/runs/5849278159/job/15857441904?pr=211

exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
@ErikSchierboom
Copy link
Member

https://exercism.org/docs/building/tracks/practice-exercises can be helpful

Copy link
Contributor

@glennj glennj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an impressive achievement. I imagine at some point it will be adopted into problem-specifications for other tracks to implement. After merging we'll track its success rate in https://exercism.org/tracks/awk/build

Specific changes needed:

  • add the exercise to the track config.json, at the end of the .exercises.practice array.
    • This is a "hard" exercise, please use difficulty 8
    • generate a UUID with ./bin/configlet uuid
  • Please create a .docs/hints.md file containing perhaps links to articles on how to implement the algorithm.
    • I would have a hard time implementing this.
    • this hints.md file creates a HINTS.md file for CLI users: the variable-length-quantity exercise has one. I'm not sure where it shows up in the web editor.
  • every exercise needs bats-extra.bash -- copy it from another exercise.
  • do we want to expose the awk maze tester to the web editor?
    • Students might want to understand the validate_maze function in the bats test suite
    • If yes, then in .meta/config.json add "editor": ["test-maze.awk"] to the .files object.
  • before submitting again, run ./bin/configlet lint and ./bin/configlet fmt -e mazy-mice

Removed the backstory from the `instructions.md` of mazy-mice exercise. The backstory was not providing any useful context for solving the exercise, thus simplifying it and keeping the focus solely on the exercise details and instructions.
Included concatenated source codes of bats-support and bats-assert in a new file `bats-extra.bash` within mazy-mice exercise. These libraries provide useful helper functions for writing tests, increasing the efficiency of test scripting. The original git repositories (bats-core/bats-support and bats-core/bats-assert) were included as comments to provide reference.
Added 'editor' section in 'config.json' for 'mazy-mice' exercise. The new file 'test-maze.awk' is included in this section to improve the efficiency of test scripting, providing users with better tools for practice. This addition enhances both the utility and robustness of the exercise environment.
A new exercise 'mazy-mice' has been added to the 'config.json' file. This was done to provide more variety and challenge to users. The attributes "slug", "name", "uuid", "practices", "prerequisites" and "difficulty" have been defined for this exercise.
A new hints.md file has been added in the 'mazy-mice' exercise folder. This document provides general advice and specific suggestions on generating mazes, including possible functions to use and a recommended maze generation algorithm. This should aid students in understanding and solving this practice problem.
@rabestro
Copy link
Contributor Author

rabestro commented Aug 17, 2023

  • add the exercise to the track config.json, at the end of the .exercises.practice array.
  • This is a "hard" exercise, please use difficulty 8
  • generate a UUID with ./bin/configlet uuid
  • Please create a .docs/hints.md file containing perhaps links to articles on how to implement the algorithm.
  • every exercise needs bats-extra.bash -- copy it from another exercise.
  • If yes, then in .meta/config.json add "editor": ["test-maze.awk"] to the .files object.
  • before submitting again, run ./bin/configlet lint and ./bin/configlet fmt -e mazy-mice

@rabestro rabestro requested a review from glennj August 17, 2023 15:02
rabestro and others added 3 commits August 17, 2023 19:05
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
@rabestro
Copy link
Contributor Author

https://exercism.org/docs/building/tracks/practice-exercises can be helpful

Thank you for the link. I need some time to learn it :)

Updated the hints.md in the 'mazy-mice' exercise, adding a section that provides specific Box drawing characters with their Unicode. The added detail is to help learners navigate through characters used in this exercise.
@ErikSchierboom
Copy link
Member

@rabestro I'll let @IsaacG and @glennj handle the further reviewing of this PR

Modified maze size notations in instructions.md of the 'mazy-mice' exercise to clarify what the numbers mean. Previously, it could be interpreted as either the number of cells or characters. This change is intended to prevent confusion for learners by specifying it as the number of cells.
@rabestro rabestro requested a review from IsaacG August 23, 2023 15:29
Changed the maze dimension instructions in 'mazy-mice' exercise to be more concise and clear. This aims to alleviate any misunderstanding around the size notation, by specifying the 'x' and 'y' dimensions as referring to the number of cells, not characters, in the maze.
Modified the description of the maze structure in the Mazy Mice exercise instructions to clarify that the dimensions refer to cells not characters. This was done to ensure that the dimensions are interpreted correctly and to prevent possible miscommunication.
Updated instructions for generating mazes in Mazy Mice exercise. The previous description was vague about the nature of the maze's layout, potentially leading to incorrect maze creation. The instructions now clearly state the maze should have a rectangular shape with opening at the start and end, providing a better guide for creating mazes.
@rabestro
Copy link
Contributor Author

Hi @glennj , @IsaacG.
I hope that I have resolved all the comments.

@glennj
Copy link
Contributor

glennj commented Aug 25, 2023

@IsaacG did you want another look at this?

Copy link
Member

@IsaacG IsaacG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for doing this. I have some minor word-smithing suggestions.

exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
rabestro and others added 3 commits August 25, 2023 18:49
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
@rabestro
Copy link
Contributor Author

Looks good! Thanks for doing this. I have some minor word-smithing suggestions.

fixed

Copy link
Contributor

@glennj glennj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments. No changes strictly required.

exercises/practice/mazy-mice/.docs/instructions.md Outdated Show resolved Hide resolved
Changed the description for generating mazes in the training material. The previous instructions ambiguously portrayed the maze's layout, which could lead to inaccurate maze creation. The new instructions specify that the maze should be in a small square format of 5x5 cells, outlining the maze's structure more accurately and effectively.
Inserted a one-second sleep delay in the mazy-mice BATS tests to ensure unique seeds for random maze generation when the seed parameter is omitted or specified. This prevents both unintentional similarities between random mazes and conflicts with the system's default seed.
@glennj glennj merged commit e84dce6 into exercism:main Aug 29, 2023
2 checks passed
@glennj
Copy link
Contributor

glennj commented Aug 29, 2023

Many thanks for persevering @rabestro!

glennj pushed a commit to glennj/exercism-awk that referenced this pull request Sep 7, 2023
* Implement maze generation algorithm

This commit introduces a new algorithm for maze generation in the "maze-generator.awk" file. The code includes essential settings such as rows, columns, and seed initialization. It leverages a recursive backtracking algorithm to create the maze and arranges entry and exit doors. This change was necessary to provide a reliable and customizable maze generation process.

* Add unit tests for maze generator

Introduced new tests for the maze-generator, aiming to validate the correctness of the generated mazes. Tests involve a wide range of maze dimensions and scenarios including square, rectangle dimensions, and randomness. The seed parameter's effect on maze generation process is also evaluated. The addition of these tests will help ensure the algorithm performs as expected across different use cases.

* Add unit tests for maze generator

In this commit, we have added new tests for the maze-generator module. These tests are aimed at validating the correctness of the generated mazes under different conditions. They involve a wide array of scenarios including different maze dimensions and shapes (square, rectangular), as well as desired levels of randomness. In addition, the tests also evaluate how the seed parameter affects the maze generation process in order to guarantee reproducibility. The addition of these tests will help in ensuring that the algorithm performs as expected across different use cases.

* Replace maze-generator.awk with mazy-mice.awk in tests

Changed calling of maze-generator.awk to mazy-mice.awk in mazy-mice tests. This is to reflect the renaming of maze-generator.awk to mazy-mice.awk to make names consistent. Also uncommented skip functionality in the tests to ensure they are run during testing process. This highlights that the script being tested matches the name of the test file, increasing code readability and maintainability.

* Update mazy-mice exercise documentation

Removed the backstory from the `instructions.md` of mazy-mice exercise. The backstory was not providing any useful context for solving the exercise, thus simplifying it and keeping the focus solely on the exercise details and instructions.

* Add bats-support and bats-assert source code

Included concatenated source codes of bats-support and bats-assert in a new file `bats-extra.bash` within mazy-mice exercise. These libraries provide useful helper functions for writing tests, increasing the efficiency of test scripting. The original git repositories (bats-core/bats-support and bats-core/bats-assert) were included as comments to provide reference.

* Update 'config.json' for mazy-mice exercise

Added 'editor' section in 'config.json' for 'mazy-mice' exercise. The new file 'test-maze.awk' is included in this section to improve the efficiency of test scripting, providing users with better tools for practice. This addition enhances both the utility and robustness of the exercise environment.

* Add new exercise 'mazy-mice' to config.json

A new exercise 'mazy-mice' has been added to the 'config.json' file. This was done to provide more variety and challenge to users. The attributes "slug", "name", "uuid", "practices", "prerequisites" and "difficulty" have been defined for this exercise.

* Add hints documentation for 'mazy-mice'

A new hints.md file has been added in the 'mazy-mice' exercise folder. This document provides general advice and specific suggestions on generating mazes, including possible functions to use and a recommended maze generation algorithm. This should aid students in understanding and solving this practice problem.

* Update exercises/practice/mazy-mice/.docs/introduction.md

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Update exercises/practice/mazy-mice/.meta/config.json

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Update exercises/practice/mazy-mice/.docs/instructions.md

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Add box drawing characters to 'mazy-mice' hints

Updated the hints.md in the 'mazy-mice' exercise, adding a section that provides specific Box drawing characters with their Unicode. The added detail is to help learners navigate through characters used in this exercise.

* Update maze size notation in instructions.md

Modified maze size notations in instructions.md of the 'mazy-mice' exercise to clarify what the numbers mean. Previously, it could be interpreted as either the number of cells or characters. This change is intended to prevent confusion for learners by specifying it as the number of cells.

* Refine maze dimension instructions in mazy-mice exercise

Changed the maze dimension instructions in 'mazy-mice' exercise to be more concise and clear. This aims to alleviate any misunderstanding around the size notation, by specifying the 'x' and 'y' dimensions as referring to the number of cells, not characters, in the maze.

* Update Mazy Mice exercise description for clarity

Modified the description of the maze structure in the Mazy Mice exercise instructions to clarify that the dimensions refer to cells not characters. This was done to ensure that the dimensions are interpreted correctly and to prevent possible miscommunication.

* Revise maze details in Mazy Mice instructions

Updated instructions for generating mazes in Mazy Mice exercise. The previous description was vague about the nature of the maze's layout, potentially leading to incorrect maze creation. The instructions now clearly state the maze should have a rectangular shape with opening at the start and end, providing a better guide for creating mazes.

* Update exercises/practice/mazy-mice/.docs/instructions.md

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Update exercises/practice/mazy-mice/.docs/instructions.md

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Update exercises/practice/mazy-mice/.docs/instructions.md

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

* Update maze description in tutorial

Changed the description for generating mazes in the training material. The previous instructions ambiguously portrayed the maze's layout, which could lead to inaccurate maze creation. The new instructions specify that the maze should be in a small square format of 5x5 cells, outlining the maze's structure more accurately and effectively.

* Add sleep to ensure unique seed in mazy-mice test

Inserted a one-second sleep delay in the mazy-mice BATS tests to ensure unique seeds for random maze generation when the seed parameter is omitted or specified. This prevents both unintentional similarities between random mazes and conflicts with the system's default seed.

---------

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants