elite_universe 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/elite_universe/galaxy.rb +6 -0
- data/lib/elite_universe/version.rb +1 -1
- metadata +5 -6
- data/lib/elite_universe/planet_working.rb +0 -178
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be8f3ad02eeb0a06f99168895873e68d3291b595
|
4
|
+
data.tar.gz: 25e5958265a027994d04aae793dc86e0ee278026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36695193d73d4e9b8243d8671d6d1b61f62f1b660256e01223c443dcec4cc6db3718ebb87cece912f10e9b44f13a91f627666b1d46bd0473ef26870d21cce944
|
7
|
+
data.tar.gz: 7a9b56bacdb0becdc89d01beed47520454ead7f992d96767e6ae74fd2ee8ce3611f2fc193e949fa8fcbe6eaf39e5dd3188694cfc35b4f5c209aec40245ff27c9
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
Generate planets and galaxies following the Acornsoft Elite planet generation
|
4
4
|
algorithm.
|
5
5
|
|
6
|
+
[![Build Status](https://travis-ci.org/jrmhaig/elite_universe.svg?branch=master)](https://travis-ci.org/jrmhaig/elite_universe)
|
7
|
+
|
6
8
|
## Usage
|
7
9
|
|
8
10
|
```ruby
|
@@ -15,9 +17,16 @@ planet.name # = Lave
|
|
15
17
|
```ruby
|
16
18
|
require 'elite_universe/galaxy'
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
galaxy = EliteUniverse::Galaxy.new(23114, 584, 46931)
|
21
|
+
galaxy.planets # = array of 'EliteUniverse::Planet's
|
22
|
+
galaxy.planets[129].name # = Zaonce
|
23
|
+
```
|
24
|
+
|
25
|
+
`EliteUniverse::Galaxy` is an Enumerable class and so, for example, a full list
|
26
|
+
of planet names in the galaxy can be generated with:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
galaxy.map(&:name)
|
21
30
|
```
|
22
31
|
|
23
32
|
## License
|
@@ -2,6 +2,8 @@ require 'elite_universe/planet'
|
|
2
2
|
|
3
3
|
module EliteUniverse
|
4
4
|
class Galaxy
|
5
|
+
include Enumerable
|
6
|
+
|
5
7
|
def initialize a, b, c
|
6
8
|
@w = [ a, b, c ]
|
7
9
|
end
|
@@ -13,5 +15,9 @@ module EliteUniverse
|
|
13
15
|
end
|
14
16
|
p
|
15
17
|
end
|
18
|
+
|
19
|
+
def each &block
|
20
|
+
planets.each { |planet| block.call(planet) }
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elite_universe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Haig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3'
|
19
|
+
version: '3.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3'
|
26
|
+
version: '3.7'
|
27
27
|
description: Implementation of the Acornsoft Elite planet generator algorithm.
|
28
28
|
email:
|
29
29
|
- joe.haig@bbc.co.uk
|
@@ -35,7 +35,6 @@ files:
|
|
35
35
|
- README.md
|
36
36
|
- lib/elite_universe/galaxy.rb
|
37
37
|
- lib/elite_universe/planet.rb
|
38
|
-
- lib/elite_universe/planet_working.rb
|
39
38
|
- lib/elite_universe/version.rb
|
40
39
|
homepage: https://github.com/jrmhaig/elite_universe
|
41
40
|
licenses:
|
@@ -57,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
56
|
version: '0'
|
58
57
|
requirements: []
|
59
58
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
59
|
+
rubygems_version: 2.6.11
|
61
60
|
signing_key:
|
62
61
|
specification_version: 4
|
63
62
|
summary: Elite Universe
|
@@ -1,178 +0,0 @@
|
|
1
|
-
module EliteUniverse
|
2
|
-
class Planet
|
3
|
-
CHARS = '..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion'.scan(/../)
|
4
|
-
CHARS2 = 'abouseitiletstonlonothno'.scan(/../) + CHARS
|
5
|
-
|
6
|
-
GOVS = [
|
7
|
-
'Anarchy',
|
8
|
-
'Feudal',
|
9
|
-
'Multi-Government',
|
10
|
-
'Dictatorship',
|
11
|
-
'Communist',
|
12
|
-
'Confederate',
|
13
|
-
'Democratic',
|
14
|
-
'Corporate',
|
15
|
-
]
|
16
|
-
|
17
|
-
ECONS = [
|
18
|
-
'Rich Industrial',
|
19
|
-
'Average Industrial',
|
20
|
-
'Poor Industrial',
|
21
|
-
'Mainly Industrial',
|
22
|
-
'Mainly Agricultural',
|
23
|
-
'Rich Agricultural',
|
24
|
-
'Average Agricultural',
|
25
|
-
'Poor Agricultural',
|
26
|
-
]
|
27
|
-
DESC_LIST = [
|
28
|
-
["fabled", "notable", "well known", "famous", "noted"],
|
29
|
-
["very", "mildly", "most", "reasonably", ""],
|
30
|
-
["ancient", "\x95", "great", "vast", "pink"],
|
31
|
-
["\x9E \x9D plantations", "mountains", "\x9C", "\x94 forests", "oceans"],
|
32
|
-
["shyness", "silliness", "mating traditions", "loathing of \x86", "love for \x86"],
|
33
|
-
["food blenders", "tourists", "poetry", "discos", "\x8E"],
|
34
|
-
["talking tree", "crab", "bat", "lobst", "\xB2"],
|
35
|
-
["beset", "plagued", "ravaged", "cursed", "scourged"],
|
36
|
-
["\x96 civil war", "\x9B \x98 \x99s", "a \x9B disease", "\x96 earthquakes", "\x96 solar activity"],
|
37
|
-
["its \x83 \x84", "the \xB1 \x98 \x99","its inhabitants' \x9A \x85", "\xA1", "its \x8D \x8E"],
|
38
|
-
["juice", "brandy", "water", "brew", "gargle blasters"],
|
39
|
-
["\xB2", "\xB1 \x99", "\xB1 \xB2", "\xB1 \x9B", "\x9B \xB2"],
|
40
|
-
["fabulous", "exotic", "hoopy", "unusual", "exciting"],
|
41
|
-
["cuisine", "night life", "casinos", "sit coms", " \xA1 "],
|
42
|
-
["\xB0", "The planet \xB0", "The world \xB0", "This planet", "This world"],
|
43
|
-
["n unremarkable", " boring", " dull", " tedious", " revolting"],
|
44
|
-
["planet", "world", "place", "little planet", "dump"],
|
45
|
-
["wasp", "moth", "grub", "ant", "\xB2"],
|
46
|
-
["poet", "arts graduate", "yak", "snail", "slug"],
|
47
|
-
["tropical", "dense", "rain", "impenetrable", "exuberant"],
|
48
|
-
["funny", "wierd", "unusual", "strange", "peculiar"],
|
49
|
-
["frequent", "occasional", "unpredictable", "dreadful", "deadly"],
|
50
|
-
["\x82 \x81 for \x8A", "\x82 \x81 for \x8A and \x8A", "\x88 by \x89", "\x82 \x81 for \x8A but \x88 by \x89","a\x90 \x91"],
|
51
|
-
["\x9B", "mountain", "edible", "tree", "spotted"],
|
52
|
-
["\x9F", "\xA0", "\x87oid", "\x93", "\x92"],
|
53
|
-
["ancient", "exceptional", "eccentric", "ingrained", "\x95"],
|
54
|
-
["killer", "deadly", "evil", "lethal", "vicious"],
|
55
|
-
["parking meters", "dust clouds", "ice bergs", "rock formations", "volcanoes"],
|
56
|
-
["plant", "tulip", "banana", "corn", "\xB2weed"],
|
57
|
-
["\xB2", "\xB1 \xB2", "\xB1 \x9B", "inhabitant", "\xB1 \xB2"],
|
58
|
-
["shrew", "beast", "bison", "snake", "wolf"],
|
59
|
-
["leopard", "cat", "monkey", "goat", "fish"],
|
60
|
-
["\x8C \x8B", "\xB1 \x9F \xA2","its \x8D \xA0 \xA2", "\xA3 \xA4", "\x8C \x8B"],
|
61
|
-
["meat", "cutlet", "steak", "burgers", "soup"],
|
62
|
-
["ice", "mud", "Zero-G", "vacuum", "\xB1 ultra"],
|
63
|
-
["hockey", "cricket", "karate", "polo", "tennis"]
|
64
|
-
]
|
65
|
-
|
66
|
-
def initialize a, b, c
|
67
|
-
@w = [ a, b, c ]
|
68
|
-
end
|
69
|
-
|
70
|
-
def name
|
71
|
-
name = ''
|
72
|
-
v = @w
|
73
|
-
l = v[0] & 64
|
74
|
-
4.times do |i|
|
75
|
-
if i < 3 or l > 0
|
76
|
-
n = ( v[2] >> 8 ) & 31
|
77
|
-
name += CHARS[n]
|
78
|
-
end
|
79
|
-
v = twist v
|
80
|
-
end
|
81
|
-
name.gsub('.', '').capitalize
|
82
|
-
end
|
83
|
-
|
84
|
-
def government
|
85
|
-
GOVS[ gov_n ]
|
86
|
-
end
|
87
|
-
|
88
|
-
def economy
|
89
|
-
ECONS[ econ_n ]
|
90
|
-
end
|
91
|
-
|
92
|
-
def location
|
93
|
-
[ @w[1] >> 8, @w[0] >> 8 ]
|
94
|
-
end
|
95
|
-
|
96
|
-
def description
|
97
|
-
@gs = [
|
98
|
-
@w[1] & 0xFF,
|
99
|
-
@w[1] >> 8,
|
100
|
-
@w[2] & 0xFF,
|
101
|
-
@w[2] >> 8
|
102
|
-
]
|
103
|
-
goatsoup("\x8F is \x97.")
|
104
|
-
end
|
105
|
-
|
106
|
-
def next
|
107
|
-
EliteUniverse::Planet.new *(twist twist twist twist @w)
|
108
|
-
end
|
109
|
-
|
110
|
-
private
|
111
|
-
def twist arr
|
112
|
-
[ arr[1], arr[2], arr.inject(:+) % 65536 ]
|
113
|
-
end
|
114
|
-
|
115
|
-
def gov_n
|
116
|
-
( @w[1] >> 3 ) & 7
|
117
|
-
end
|
118
|
-
|
119
|
-
def econ_n
|
120
|
-
e = ( @w[0] >> 8 ) & 7
|
121
|
-
gov_n <= 1 ? e | 2 : e
|
122
|
-
end
|
123
|
-
|
124
|
-
def goatsoup(source)
|
125
|
-
result = ''
|
126
|
-
source.force_encoding('ISO-8859-1').split(//).each do |c|
|
127
|
-
o = c.ord
|
128
|
-
if o < 128
|
129
|
-
result += c
|
130
|
-
else
|
131
|
-
if o <= 164
|
132
|
-
rnd = gen_rnd_number
|
133
|
-
pos = 0
|
134
|
-
pos += 1 if rnd >= 51
|
135
|
-
pos += 1 if rnd >= 102
|
136
|
-
pos += 1 if rnd >= 153
|
137
|
-
pos += 1 if rnd >= 204
|
138
|
-
result += goatsoup(DESC_LIST[o-129][pos])
|
139
|
-
else
|
140
|
-
case o
|
141
|
-
when 176
|
142
|
-
result += self.name
|
143
|
-
when 177
|
144
|
-
nm = self.name
|
145
|
-
result += "#{(['i', 'e'].include?(nm[-1]) ? nm.chop : nm)}ian"
|
146
|
-
when 178
|
147
|
-
l = gen_rnd_number & 3
|
148
|
-
new_name = ''
|
149
|
-
(0..l).each do |i|
|
150
|
-
x = gen_rnd_number & 0x3E
|
151
|
-
new_name += CHARS2[x/2]
|
152
|
-
end
|
153
|
-
result += new_name.capitalize
|
154
|
-
else
|
155
|
-
result += "[BOOM - #{o}]"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
result
|
162
|
-
end
|
163
|
-
|
164
|
-
def gen_rnd_number
|
165
|
-
x = (@gs[0] * 2 ) & 0xFF
|
166
|
-
a = x + @gs[2]
|
167
|
-
a += 1 if @gs[0] > 127
|
168
|
-
@gs[0] = a & 0xFF
|
169
|
-
@gs[2] = x
|
170
|
-
a = a / 256
|
171
|
-
x = @gs[1]
|
172
|
-
a = ( a + x + @gs[3]) & 0xFF
|
173
|
-
@gs[1] = a
|
174
|
-
@gs[3] = x
|
175
|
-
a
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|