gobgems 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gobgems/board.rb +7 -0
- data/lib/gobgems/gbb/gbb_writer.rb +12 -8
- data/lib/gobgems/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8b7e1bf0da89f0fb59d75de162aa6185550563
|
4
|
+
data.tar.gz: 85c431e14f757b91f148fb9b84e4b6dae1518037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58c125024e2fb5520ca817ab816520bc1e92f58c1a11e7e58f78383e9fcb98b67c8ac263d19451103f460ff7dd11dce4dcb577b262264e1cdb0cf59a4945d7bb
|
7
|
+
data.tar.gz: 349d70a9b7beb9ce084936c1fda68ac2955037cd993b5da8a15fa813df3a9ead5e087abfe735d75c5470da1778914e7a29fe28bc178d396be0a8544bfe5d7071
|
data/lib/gobgems/board.rb
CHANGED
@@ -89,6 +89,13 @@ module Gobgems
|
|
89
89
|
cells[-(position[1]+1)][position[0]]
|
90
90
|
end
|
91
91
|
|
92
|
+
def __each_cell__
|
93
|
+
(0..(size[0]-1)).each do |x|
|
94
|
+
(0..(size[1]-1)).each do |y|
|
95
|
+
yield __cell_at__([x, y]), x, y
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
92
99
|
private
|
93
100
|
|
94
101
|
def within_bounds?(position)
|
@@ -3,24 +3,28 @@ module Gobgems
|
|
3
3
|
def self.write(board)
|
4
4
|
"GBB/1.0\n" +
|
5
5
|
"size #{board.size[0]} #{board.size[1]}\n" +
|
6
|
-
"#{write_cells board
|
6
|
+
"#{write_cells board}" +
|
7
7
|
"head #{board.head_position[0]} #{board.head_position[1]}"
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def self.write_cells(
|
12
|
+
def self.write_cells(board)
|
13
13
|
cells_gbb = ''
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
14
|
+
|
15
|
+
board.__each_cell__ do |cell, x, y|
|
16
|
+
cell = cell.select { |color, count| count > 0 }
|
17
|
+
next if cell.empty?
|
18
|
+
cells_gbb << "cell #{x} #{y} #{write_colors cell}\n"
|
20
19
|
end
|
20
|
+
|
21
21
|
cells_gbb
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.write_colors(cell)
|
25
|
+
cell.map { |color, count| "#{to_gbb_color color} #{count}" }.join(' ')
|
26
|
+
end
|
27
|
+
|
24
28
|
def self.to_gbb_color(color)
|
25
29
|
case color
|
26
30
|
when :red then 'Rojo'
|
data/lib/gobgems/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gobgems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Aloi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|