Permalink
Browse files

Fix rules without condition

  • Loading branch information...
1 parent 69259dd commit 86d7d3fa4e2bc8801def6b02b9c57fb6049e02a8 @ai committed Jan 15, 2010
Showing with 6 additions and 6 deletions.
  1. +3 −2 evolution/lib/d2na-evolution/mutable_code.rb
  2. +3 −4 examples/prisoner's dilemma.rb
@@ -171,7 +171,6 @@ def mutate!(params = {})
elsif choice < sum - p[:remove_state]
# Add state
state = new_state_name
- before_permutation = @conditions_permutations.length
before_conditions = conditions_count
before_commands = @commands.length
add_states(state)
@@ -319,7 +318,9 @@ def add_command(rule_number, command, param)
@modified_rules.delete(old)
@rules[rule_number] = rule = clone_rule(old)
else
- rule = on(*@unused_conditions[rule_number - @rules.length].to_a)
+ condition = @unused_conditions[rule_number - @rules.length]
+ return unless condition
+ rule = on(*condition.to_a)
end
rule.commands << [command, param]
@modified_rules << rule
@@ -10,8 +10,8 @@
}
opponents = {
- good: proc { :Keep },
- bad: proc { :Betray }
+ good: proc { :Keep },
+ bad: proc { :Betray }
}
def input_name(output)
@@ -57,6 +57,5 @@ def input_name(output)
putc '.'
end
-puts
-puts
+puts "\n"
puts evolution.population.best.to_ruby

0 comments on commit 86d7d3f

Please sign in to comment.