This is a work in progress roguelike game written in Ruby, it is inspired by the original 1980's rogue game.
Most likely it will take me forever to write it... oh well!
Your objective is to move your character (@
) through the mazes, find your way to the stairs (%
) so that you can find the next maze.
This project uses ruby 2.7.2 (see .ruby-version). I use rbenv to install different ruby versions, you may need to install homebrew.
In case you need to install everything you can simply do:
$ ./install.sh
Otherwise you can proceed with the following:
$ brew bundle
$ rbenv install
$ gem install bundler
$ bundle install
See the examples folder with examples of the different algorithms.
If you would like to watch a small demo.
$ pry -r ./play.rb
pry(main)> Vanilla::Demo.run
Vanilla.Demo.mov
There is an executable vanilla.rb
file.
$ ./bin/vanilla.rb
Or you can use the play.rb
file with, but that's mostly used as a playground.
$ pry -r ./play.rb
pry(main)> Vanilla.run
Use your keyboard keys H J K L, or use the arrow keys.
- H - moves left
- J - moves down
- K - moves up
- L - moves right
- q - quits the game (may require multiple presses if you have been using the arrows to move the character)
$ pry -r ./play.rb
pry(main)> Vanilla.play(rows: 10, columns: 10)
The following are some of the known procedural maze generation algorithms. If you looking to understand more about different generation algorithms, then I recommend you to read Jamis Buck blog and his book Mazes for Programmers.
For each cell in the grid, it randomly creates a passage either north or east.
Features a strong diagonal texture, tending toward the north-east corner of the grid. Passages run the length of the northern row and the eastern column.
This is the algorithm used by default.
Starts in a random cell, moves randomly from cell to cell. It creates a passage when finds an unvisited cell.
Starts quickly, although it can take a while to finish. This is considered unbiased, meaning it should generate mazes completely randomly.
$ pry -r ./play.rb
Vanilla.play(rows: 10, columns: 15, algorithm: Vanilla::Algorithms::AldousBroder)
Starts at a random cell, moves randomly, avoids previously visited cells. When there are no more possible moves, it backtracks to the most recently visited cell and continues. It finishes when it tries to backtrack to where it started.
$ pry -r ./play.rb
Vanilla.play(rows: 10, columns: 15, algorithm: Vanilla::Algorithms::RecursiveBacktracker)
It works by dividing the grid into two subgrids, adding a wall between them and a single passage linking them. The algorithm is then repeated on each side, recursively, until the passages are the desired size.
Tends to be of a boxy or rectangular texture.
$ pry -r ./play.rb
Vanilla.play(rows: 10, columns: 15, algorithm: Vanilla::Algorithms::RecursiveDivision)
This is an algorithm for finding the shortest path between two given nodes in a graph.
If you are interested in contributing, please do.
I'm using Yard to create documentation.
Creates HTML documentation
$ yard doc
Starts web server
Open your browser and go to http://localhost:8808/
$ yard server
Vanilla is under the MIT License.