Skip to content

Vanilla... non playable roguelike, just vanilla ruby

License

Notifications You must be signed in to change notification settings

Davidslv/vanilla

Repository files navigation

Vanilla Roguelike

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!

The objective

Your objective is to move your character (@) through the mazes, find your way to the stairs (%) so that you can find the next maze.

Install dependencies

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

Examples

See the examples folder with examples of the different algorithms.

Demo

If you would like to watch a small demo.

$ pry -r ./play.rb
pry(main)> Vanilla::Demo.run
Vanilla.Demo.mov

Play

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

Controls

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)

Playground

$ pry -r ./play.rb
pry(main)> Vanilla.play(rows: 10, columns: 10)

Algorithms

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.

Binary Tree

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.

Aldous Broder

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)

Recursive Backtracker

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)

Recursive Division

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)

Dijkstra's algorithm

This is an algorithm for finding the shortest path between two given nodes in a graph.

Contributing

If you are interested in contributing, please do.

Documentation

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

License

Vanilla is under the MIT License.

Releases

No releases published

Packages

No packages published