amaze 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +20 -1
- data/Rakefile +5 -5
- data/amaze.gemspec +2 -0
- data/lib/amaze/formatter/image/polar.rb +6 -2
- data/lib/amaze/script.rb +3 -3
- data/lib/amaze/version.rb +1 -1
- data/support/images/algorithm_animation.gif +0 -0
- data/support/images/maze_ortho_distances_longest.png +0 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1928d740f79d0128a57e37282ee4207f9fe83ccd
|
4
|
+
data.tar.gz: 72c00a9d929c8cddd7c6cb9dca046d8677674c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae4372d7842667d9310cd332f27d85e065da1646d2e1389460b645259264366df46f5c343c27082a858994ad5bba5ca38be1165e7bf9a5ac634c505ed22d3345
|
7
|
+
data.tar.gz: df6db3f5788b76475458400cdacb8698d25df2f2ac80ebfb030c88780608a6f3daa36de61d7d6c390dd516ca43c5450e7552d63f6d1cd85cd0cd3d9d676dce16
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
# Changelog
|
3
|
+
|
4
|
+
## v 0.2.1 / 2016-05-23
|
5
|
+
- Fix end point position when path ends in the center of a circular image maze
|
6
|
+
- Add required ruby version in gemspec
|
7
|
+
- Rename visualization modes, option `--visualize [run|autopause|pause|step]`
|
8
|
+
|
9
|
+
|
10
|
+
## v 0.2.0 / 2016-05-21
|
11
|
+
First public release. Amaze is both a ruby library and a command line tool to generate mazes.
|
12
|
+
|
13
|
+
Features include:
|
14
|
+
|
15
|
+
- Render ortho, sigma, delta, upsilon and circular mazes
|
16
|
+
- Output ASCII to the terminal or generate PNG images
|
17
|
+
- Visualize distances with colored cells
|
18
|
+
- Show solution
|
19
|
+
- Show longest path through the maze
|
20
|
+
- Visualize algorithm on work (only ASCII)
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/amaze.svg)](https://badge.fury.io/rb/amaze)
|
2
|
+
|
1
3
|
# Amaze
|
2
4
|
|
3
5
|
Amaze is both a ruby library and a command line tool to generate mazes.
|
@@ -15,11 +17,18 @@ On **OS X** install imagemagick with brew
|
|
15
17
|
|
16
18
|
$ brew install imagemagick
|
17
19
|
|
20
|
+
On **Ubuntu**
|
21
|
+
|
22
|
+
$ sudo apt-get install libmagickwand-dev
|
23
|
+
|
18
24
|
Then run
|
19
25
|
|
20
26
|
$ gem install amaze
|
21
27
|
|
22
28
|
|
29
|
+
Amaze has been tested on OS X 10.11.x and Ubuntu 16.04 with ruby 2.3.x.
|
30
|
+
|
31
|
+
|
23
32
|
## Usage
|
24
33
|
|
25
34
|
Execute `amaze --help` for a short description of all supported options.
|
@@ -85,6 +94,8 @@ How about watching the algorithm doing its work?
|
|
85
94
|
|
86
95
|
$ amaze --visualize
|
87
96
|
|
97
|
+
![Watching the alogorithm generating a maze](support/images/algorithm_animation.gif?raw=true "Visualize Algorithm")
|
98
|
+
|
88
99
|
You can choose between different algorithm (try Hunt and Kill next)
|
89
100
|
|
90
101
|
$ amaze --visualize --algorithm hk
|
@@ -97,7 +108,15 @@ Finally you can render your maze as PNG
|
|
97
108
|
Random seed: 72618483828743227022428199116847991100
|
98
109
|
Maze 'maze.png' saved.
|
99
110
|
|
100
|
-
|
111
|
+
... and a last example
|
112
|
+
|
113
|
+
$ amaze --type ortho -g 12 --format image --distances --longest
|
114
|
+
|
115
|
+
will render something like this:
|
116
|
+
|
117
|
+
![Image of an ortho maze with color coded distances and longest path](support/images/maze_ortho_distances_longest.png?raw=true "Beautiful Maze")
|
118
|
+
|
119
|
+
Amaze has a lot more options to play with. Have fun and create beautiful pieces of [algorithmic art](https://en.wikipedia.org/wiki/Algorithmic_art).
|
101
120
|
|
102
121
|
|
103
122
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
data/amaze.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.required_ruby_version = '>= 2.0.0'
|
23
|
+
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
@@ -85,7 +85,8 @@ class Amaze::Formatter::Image::Polar < Amaze::Formatter::Image
|
|
85
85
|
# center of cell
|
86
86
|
x1, y1 = polar2cartesian(radius, theta)
|
87
87
|
# center of inward cell, but adjusted to the same angle of the current cell
|
88
|
-
|
88
|
+
radius_inward, _ = center_coord cell.inward, :radian
|
89
|
+
x2, y2 = polar2cartesian(radius_inward, theta)
|
89
90
|
canvas.line x1, y1, x2, y2
|
90
91
|
end
|
91
92
|
|
@@ -109,7 +110,10 @@ class Amaze::Formatter::Image::Polar < Amaze::Formatter::Image
|
|
109
110
|
canvas.fill path_color
|
110
111
|
canvas.stroke 'none'
|
111
112
|
[path_start, path_finish].compact.each do |cell|
|
112
|
-
|
113
|
+
radius, theta = center_coord cell, :radian
|
114
|
+
# adjust the angle for cell(0,0)
|
115
|
+
_, theta = center_coord path_outward(cell).first, :radian if cell.row.zero?
|
116
|
+
x, y = polar2cartesian(radius, theta)
|
113
117
|
canvas.ellipse x, y, path_width*2, path_width*2, 0, 360
|
114
118
|
end
|
115
119
|
end
|
data/lib/amaze/script.rb
CHANGED
@@ -47,7 +47,7 @@ class Amaze::Script
|
|
47
47
|
o.on('-S', '--seed SEED', Integer, 'Set random seed') do |seed|
|
48
48
|
options[:seed] = seed
|
49
49
|
end
|
50
|
-
visualization_modes =
|
50
|
+
visualization_modes = %i( run autopause pause step )
|
51
51
|
o.on('-v', '--visualize [MODE]', visualization_modes, 'Visualize the progress of the algorithm', "One of #{visualization_modes.join(', ')}") do |mode|
|
52
52
|
options[:visualize] = mode || :run
|
53
53
|
end
|
@@ -146,10 +146,10 @@ class Amaze::Script
|
|
146
146
|
|
147
147
|
puts stat.info if stat.info
|
148
148
|
sleep algorithm.speed
|
149
|
-
sleep 1 if options[:visualize] == :
|
149
|
+
sleep 1 if options[:visualize] == :autopause && stat.pause?
|
150
150
|
|
151
151
|
# wait for keystroke ?
|
152
|
-
if (options[:visualize] == :
|
152
|
+
if (options[:visualize] == :pause && stat.pause? || options[:visualize] == :step)
|
153
153
|
case read_char
|
154
154
|
when "\e"
|
155
155
|
break
|
data/lib/amaze/version.rb
CHANGED
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amaze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Marchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".gitignore"
|
121
121
|
- ".rspec"
|
122
122
|
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|
@@ -173,6 +174,8 @@ files:
|
|
173
174
|
- lib/amaze/shape/triangle.rb
|
174
175
|
- lib/amaze/version.rb
|
175
176
|
- support/characters.txt
|
177
|
+
- support/images/algorithm_animation.gif
|
178
|
+
- support/images/maze_ortho_distances_longest.png
|
176
179
|
- support/mask/mask1.txt
|
177
180
|
- support/mask/mask2.txt
|
178
181
|
- support/mask/mask3.txt
|
@@ -188,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
191
|
requirements:
|
189
192
|
- - ">="
|
190
193
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
194
|
+
version: 2.0.0
|
192
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
196
|
requirements:
|
194
197
|
- - ">="
|