evolvable 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 145d256bfb7b28668a14cab664de8dabc2e0bfe8bbfa4c2301e9c1aaae843cf2
4
- data.tar.gz: ce722823a53c91a053657d2bc990372de614b7236390ddc27ac88571932f5a5f
3
+ metadata.gz: '068f9c6690af16e24cb522c25a9a33963bff2f1757dca841858a4baff1f2b777'
4
+ data.tar.gz: 5d4fbe538753cb309042cf7cec6ded7c3e10d7bace1b8a1d495698be5225114d
5
5
  SHA512:
6
- metadata.gz: d68b7d03481e1ff1a3dce744dd98075bfd2567f24acddb5a770c1ae7acd737fd99c32f3f3434381d47bc2a54e5dd4047e822be12cf5f1bcd3e79f6f7b71cc698
7
- data.tar.gz: 2c9fd505b36a76dc6f25dfa3a70d58e6387ab3689716b29bfbfd5291649b9de2f160609f1192e9843fe9c4dd54759350924e8e442ae4d49728cff87510b5c518
6
+ metadata.gz: e49437b455e04a05324091220b215cc99e69576adcd4c8181495cb7ba83d89ed43d0a5743ba3f9264940ea547e2e48790306d3eb03e967a0b3b7f8433eb16479
7
+ data.tar.gz: a2e2ff86d7c325e718e53ae6edf24665e23ea908d3cd3568cedcd643b473c0d4fa8027d54d7d0c3ae25ee1a1218bedb648440a292c2ca28959bfeed07dfdf316
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## Unreleased
1
+ ## 1.2.0 - 2022-1-22
2
+
3
+ * Make it easier to dump and load genomes and use custom serializers. [69afd7c](https://github.com/mattruzicka/evolvable/commit/69afd7c957cbf89cc03b4f3f0ba967bf571c34c5)
4
+ * Avoid needing Gene#combine implementations to deal with nil args. Technically this could be a breaking change if you have custom combination logic for when two evolvables have different numbers of the same kind of gene and you do something other than just return the gene that isn't nil, but that this is the case seems unlikely, especially considering I'm not even aware of anyone else using this gem in the wild. If you do, please reach out! I'd love to hear from you, even if you're angry about this! [7ae1087](https://github.com/mattruzicka/evolvable/commit/7ae108762505230d81afc79b2f6c3e679fadc1a4)
5
+
6
+
7
+ ## 1.1.0 - 2021-12-30
2
8
 
3
9
  Features
4
10
  * Updated documentation.
@@ -45,9 +45,7 @@ module Evolvable
45
45
  end
46
46
 
47
47
  def combine(gene_a, gene_b)
48
- genes = [gene_a, gene_b]
49
- genes.compact!
50
- genes.sample
48
+ [gene_a, gene_b].sample
51
49
  end
52
50
 
53
51
  #
@@ -62,7 +62,11 @@ module Evolvable
62
62
  Array.new(count) do |index|
63
63
  gene_a = genes_1[index]
64
64
  gene_b = genes_2[index]
65
- gene_class.combine(gene_a, gene_b) || gene_class.new
65
+ if gene_a && gene_b
66
+ gene_class.combine(gene_a, gene_b)
67
+ else
68
+ gene_a || gene_b || gene_class.new
69
+ end
66
70
  end
67
71
  end
68
72
  end
@@ -8,8 +8,8 @@ module Evolvable
8
8
  class Genome
9
9
  extend Forwardable
10
10
 
11
- def self.load(data)
12
- new(config: Serializer.load(data))
11
+ def self.load(data, serializer: Serializer)
12
+ new(config: serializer.load(data))
13
13
  end
14
14
 
15
15
  def initialize(config: {})
@@ -79,8 +79,8 @@ module Evolvable
79
79
  self.class.name
80
80
  end
81
81
 
82
- def dump
83
- Serializer.dump @config
82
+ def dump(serializer: Serializer)
83
+ serializer.dump @config
84
84
  end
85
85
  end
86
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evolvable
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/evolvable.rb CHANGED
@@ -230,4 +230,12 @@ module Evolvable
230
230
  :find_genes,
231
231
  :find_genes_count,
232
232
  :genes
233
+
234
+ def dump_genome(serializer: Serializer)
235
+ @genome.dump(serializer: serializer)
236
+ end
237
+
238
+ def load_genome(data, serializer: Serializer)
239
+ @genome = Genome.load(data, serializer: serializer)
240
+ end
233
241
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evolvable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ruzicka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-30 00:00:00.000000000 Z
11
+ date: 2022-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.2.3
122
+ rubygems_version: 3.3.3
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Add evolutionary behavior to any Ruby object