tiny_fill 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_fill.rb +33 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44282db4bd5db3aaf1eb05ae7542b3f370c3eb66fbd4cd5b6a4d434b10c1cb53
4
- data.tar.gz: 46b4933fc5872d7d1522a5bebe4bbc93fb3464ada38f4ac393714e09f008ed75
3
+ metadata.gz: d3696a19a77922dca0e2edc37b7e3e38de5e413a6789e603dad3d4ae28761f2f
4
+ data.tar.gz: f08dd834cde0ca3d77f1557b052f1257271f97fbf2959d992edaaf951505b3eb
5
5
  SHA512:
6
- metadata.gz: 7e43f65e6b020ea212853dd5bceee05093dafcefd549c6fa35ce5f4ebb18bcd8180d672f7b13140b6da59b3407faf65dd952a31b3fd3520a5eaf06e7ba08d4f2
7
- data.tar.gz: 651d493412514612ab858485e857f5fecd78a5f79df961b33c8dc1cc35d5de7bfa9674d4039df6a7bfbe65b57905664b521b68f8d0b7942ab6d7b37ceab10503
6
+ metadata.gz: dfc3415d4dd950328fd2faf1c703036d8ba36f974acb5d41e44f594509df368353333b941de72f00e372b2f2c9f7a1a39daf13285f32cdbfc9e59cc080a3ab7e
7
+ data.tar.gz: 233ea64e7a7cfbc1e05fd0d4bfc1d532f91f1e3c1612c9659498f2f01b4069efdab471a89d0aecb37e0494f11abafc88063cb87f37bcf0adeec1a1a148e13e7b
data/lib/tiny_fill.rb CHANGED
@@ -1,5 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TinyFill is a module that implements a flood fill algorithm. It's useful in
4
+ # games for detecting enclosed areas within a 2D map.
5
+ #
6
+ # usage:
7
+ #
8
+ # map = [
9
+ # [false, false, true, false, false],
10
+ # [false, false, true, false, false],
11
+ # [false, false, true, false, false],
12
+ # [true, true, true, false, false],
13
+ # [false, false, false, false, false],
14
+ # ]
15
+ #
16
+ # # fill any enclosed area starting at [1, 1], max search of 10 cells
17
+ #
18
+ # TinyFill.fill!(
19
+ # map: map,
20
+ # start_x: 1,
21
+ # start_y: 1,
22
+ # max_search: 10
23
+ # )
24
+ #
25
+ # => [
26
+ # [true, true, true, false, false],
27
+ # [true, true, true, false, false],
28
+ # [true, true, true, false, false],
29
+ # [true, true, true, false, false],
30
+ # [false, false, false, false, false],
31
+ # ]
32
+
1
33
  module TinyFill
2
- def self.fill(map:, start_x:, start_y:, max_search:)
34
+ def self.fill!(map:, start_x:, start_y:, max_search:)
3
35
  wid = map.first.length
4
36
  hgt = map.length
5
37
  return nil unless start_x >= 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_fill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt