Skip to content

Commit cebf14d

Browse files
committed
Update examples
1 parent c5b4ea4 commit cebf14d

File tree

5 files changed

+12
-26
lines changed

5 files changed

+12
-26
lines changed

bin/console

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,16 @@
33
require 'bundler/setup'
44
require 'evolvable'
55
require 'debug'
6+
require 'irb'
67

7-
Dir['./examples/*.rb'].each { |f| require f }
8-
9-
## HelloWorld
10-
# population = HelloWorld.new_population(size: 100,
11-
# evaluation: { equalize: 0 },
12-
# mutation: { probability: 0.6 })
13-
# population.evolve
14-
# HelloWorld.start_loop(population)
8+
require './examples/stickman'
9+
stickman_pop = Stickman.new_population(size: 5, mutation: { probability: 0.3 })
1510

16-
## Stickman
17-
# population = Stickman.new_population(size: 5,
18-
# mutation: { probability: 0.3 })
19-
# population.evolve
11+
require './examples/ascii_art'
12+
require './examples/ascii_gene'
13+
ascii_pop = AsciiArt.new_population(size: 8, mutation: { probability: 0.3, rate: 0.02 })
2014

21-
## AsciiArt
22-
# ascii_art = AsciiArt.new_population(size: 8,
23-
# mutation: { probability: 0.3, rate: 0.02 })
24-
# ascii_art.evolve
15+
# stickman_pop.evolve
16+
# ascii_pop.evolve
2517

26-
require 'irb'
27-
IRB.start(__FILE__)
18+
binding.irb

examples/hello_world.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/images/diagram.png

-388 KB
Binary file not shown.

examples/stickman.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ def self.before_evaluation(population)
3737

3838
(@best_evolvables ||= []) << population.best_evolvable
3939
animate_best_evolvables if @best_evolvables.count > 1
40-
print "\n\n\n\n\n\n\n #{green_text('Evolve next generation?');} Yes!" \
41-
" #{green_text('...Use Ctrl-C to stop')}#{"\b" * 23}"
42-
gets
43-
print CLEAR_SEQUENCE
4440
end
4541

4642
def self.animate_best_evolvables
4743
@best_evolvables.each_with_index do |evolvable, index|
4844
puts "\n\n#{green_text(evolvable.draw)}\n\n"
4945
print green_text(" Generation: #{index}\r\n ")
50-
sleep 0.12
46+
sleep 0.5
5147
print "#{CLEAR_SEQUENCE}"
5248
end
5349
end

exe/hello_evolvable_world

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
require 'bundler/setup'
1010
require 'evolvable'
11+
require 'irb'
1112

1213
class CharGene
1314
include Evolvable::Gene
@@ -103,5 +104,4 @@ population = HelloWorld.new_population(size: 100,
103104
population.evolve
104105
HelloWorld.start_loop(population)
105106

106-
require 'irb'
107-
IRB.start(__FILE__)
107+
binding.irb

0 commit comments

Comments
 (0)