Communemashin 0.1.0 → 0.1.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.
data/lib/Communemashin.rb CHANGED
@@ -9,4 +9,2037 @@ module Communemashin
9
9
  def self.get_meds
10
10
  end
11
11
  end
12
+
13
+ class Mengexakume
14
+ ############################################################################################
15
+ # Starving Prisoner Experiment #
16
+ # Hanryu #
17
+ ############################################################################################
18
+ # This is an experiment is seeing whether prisoners will opt to starve to death, or turn #
19
+ # on each other and resort to cannibalism if pinned in the same cage. #
20
+ ############################################################################################
21
+ def self.starting_stats
22
+ # 04 06 07 09 10
23
+ # 04 04,04 04,06 04,07 04,07 04,10
24
+ # 06 06,04 06,06 06,07 06,07 06,10
25
+ # 07 07,04 07,06 07,07 07,09 07,10
26
+ # 09 09,04 09,06 09,07 09,09 09,10
27
+ # 10 10,04 10,06 10,07 10,09 10,10
28
+
29
+ starting_hp = [
30
+ [[ 4, 4], [ 4, 6], [ 4, 7], [ 4, 9], [ 4, 10]],
31
+ [[ 6, 4], [ 6, 6], [ 6, 7], [ 6, 9], [ 6, 10]],
32
+ [[ 7, 4], [ 7, 6], [ 7, 7], [ 7, 9], [ 7, 10]],
33
+ [[ 9, 4], [ 9, 6], [ 9, 7], [ 9, 9], [ 9, 10]],
34
+ [[10, 4], [10, 6], [10, 7], [10, 9], [10, 10]],
35
+ ], [
36
+ [[ 4, 4], [ 4, 6], [ 4, 7], [ 4, 9], [ 4, 10]],
37
+ [[ 6, 4], [ 6, 6], [ 6, 7], [ 6, 9], [ 6, 10]],
38
+ [[ 7, 4], [ 7, 6], [ 7, 7], [ 7, 9], [ 7, 10]],
39
+ [[ 9, 4], [ 9, 6], [ 9, 7], [ 9, 9], [ 9, 10]],
40
+ [[10, 4], [10, 6], [10, 7], [10, 9], [10, 10]],
41
+ ], [
42
+ [[ 4, 4], [ 4, 6], [ 4, 7], [ 4, 9], [ 4, 10]],
43
+ [[ 6, 4], [ 6, 6], [ 6, 7], [ 6, 9], [ 6, 10]],
44
+ [[ 7, 4], [ 7, 6], [ 7, 7], [ 7, 9], [ 7, 10]],
45
+ [[ 9, 4], [ 9, 6], [ 9, 7], [ 9, 9], [ 9, 10]],
46
+ [[10, 4], [10, 6], [10, 7], [10, 9], [10, 10]],
47
+ ]
48
+
49
+ ## Determines player starting hp
50
+ player_row_options = [0, 1, 2, 3, 4]
51
+ player_col_options = [0, 1, 2, 3, 4]
52
+ player_arr_options = [0, 1]
53
+
54
+ p_crow = player_row_options.sample
55
+ p_ccol = player_col_options.sample
56
+ p_carr = player_arr_options.sample
57
+
58
+ @player_hp = starting_hp[0][p_crow][p_ccol][p_carr]
59
+
60
+ ## Determines gribatomaton's starting hp
61
+ gribatomaton_row_options = [0, 1, 2, 3, 4]
62
+ gribatomaton_col_options = [0, 1, 2, 3, 4]
63
+ gribatomaton_arr_options = [0, 1]
64
+
65
+ g_crow = gribatomaton_row_options.sample
66
+ g_ccol = gribatomaton_col_options.sample
67
+ g_carr = gribatomaton_arr_options.sample
68
+
69
+ @gribatomaton_hp = starting_hp[1][g_crow][g_ccol][g_carr]
70
+
71
+ ## Determines enemy starting hp
72
+ enemy_row_options = [0, 1, 2, 3, 4]
73
+ enemy_col_options = [0, 1, 2, 3, 4]
74
+ enemy_arr_options = [0, 1]
75
+
76
+ e_crow = enemy_row_options.sample
77
+ e_ccol = enemy_col_options.sample
78
+ e_carr = enemy_arr_options.sample
79
+
80
+ @enemy_hp = starting_hp[2][e_crow][e_ccol][e_carr]
81
+ end
82
+
83
+ def self.actions_against_co_inmates
84
+ require "SelfModifyingDecisionTree"
85
+
86
+ attributes = ["Actions Against Player"], ["Actions Against Gribatomaton"], ["Action Against Enemy"]
87
+
88
+ training = [
89
+ [ 0.0, "Player has no left"],
90
+ [ 3.0, "Player has three hp left"],
91
+ [ 5.0, "Player has five hp left"],
92
+ [ 8.0, "Player has eight hp left"],
93
+ [ 10.0, "Player has ten hp left"],
94
+ ], [
95
+ [ 0.0, "Gribatomaton has no hp left"],
96
+ [ 3.0, "Gribatomaton has three hp left"],
97
+ [ 5.0, "Gribatomaton has five hp left"],
98
+ [ 8.0, "Gribatomaton has eight hp left"],
99
+ [ 10.0, "Gribatomaton has ten hp left"],
100
+ ], [
101
+ [ 0.0, "Enemy has no hp left"],
102
+ [ 3.0, "Enemy has three hp left"],
103
+ [ 5.0, "Enemy has five hp left"],
104
+ [ 8.0, "Enemy has eight hp left"],
105
+ [ 10.0, "Enemy has ten hp left"],
106
+ ]
107
+
108
+ dec_tree_configurations = DecisionTree::ID3Tree.new(attributes[0], training[0], 1, :continuous),
109
+ DecisionTree::ID3Tree.new(attributes[1], training[1], 1, :continuous),
110
+ DecisionTree::ID3Tree.new(attributes[2], training[2], 1, :continuous)
111
+
112
+ current_dectree1 = dec_tree_configurations[0]
113
+ current_dectree1.train
114
+
115
+ current_dectree2 = dec_tree_configurations[1]
116
+ current_dectree2.train
117
+
118
+ current_dectree3 = dec_tree_configurations[2]
119
+ current_dectree3.train
120
+
121
+ test1 = [@player_hp, "Player has five hp left"]
122
+ test2 = [@gribatomaton_hp, "Gribatomaton has five hp left"]
123
+ test3 = [@enemy_hp, "Enemy has five hp left"]
124
+
125
+ @decision1 = current_dectree1.predict(test1) # This being player's HP status.
126
+ @decision2 = current_dectree2.predict(test2) # This being gribatomatons HP status.
127
+ @decision3 = current_dectree3.predict(test3) # This being enemy hp status.
128
+
129
+ puts "Predicted: Compared to #{test1.last}, Albert made #{@decision1}"
130
+ puts "Predicted: Compared to #{test2.last}, Andy made #{@decision2}"
131
+ puts "Predicted: Compared to #{test3.last}, Bethany made #{@decision3}\n"
132
+
133
+ @net_outcome = "Predicted: Compared to #{test1.last}, Albert made #{@decision1} Predicted: Compared to #{test2.last}, Andy made #{@decision2}"
134
+ end
135
+
136
+ def self.player_hp_statistics
137
+ require "SelfModifyingDecisionTree"
138
+
139
+ player_hp = NaiveBayes.new(:player_no_hp,
140
+ :player_three_hp,
141
+ :player_five_hp,
142
+ :player_eight_hp,
143
+ :player_ten_hp,
144
+ )
145
+
146
+ player_hp.train(:player_no_hp, "Player has no hp left.", "nohp")
147
+ player_hp.train(:player_three_hp, "Player has three hp left.", "threehp")
148
+ player_hp.train(:player_five_hp, "Player has five hp left.", "fivehp")
149
+ player_hp.train(:player_eight_hp, "Player has eight hp left.", "eighthp")
150
+ player_hp.train(:player_ten_hp, "Player ten hp left.", "tenhp")
151
+
152
+ @classification1 = player_hp.classify(@decision1)
153
+
154
+ puts " "
155
+
156
+ print @classification1
157
+ end
158
+
159
+ def self.gribatomaton_hp_statistics
160
+ require "SelfModifyingDecisionTree"
161
+
162
+ gribatomaton_hp = NaiveBayes.new(:gribatomaton_no_hp,
163
+ :gribatomaton_three_hp,
164
+ :gribatomaton_five_hp,
165
+ :gribatomaton_eight_hp,
166
+ :gribatomaton_ten_hp,
167
+ )
168
+
169
+ gribatomaton_hp.train(:gribatomaton_no_hp, "Gribatomaton has no hp left.", "nohp")
170
+ gribatomaton_hp.train(:gribatomaton_three_hp, "Gribatomaton has three hp left.", "threehp")
171
+ gribatomaton_hp.train(:gribatomaton_five_hp, "Gribatomaton has five hp left.", "fivehp")
172
+ gribatomaton_hp.train(:gribatomaton_eight_hp, "Gribatomaton has eight hp left.", "eighthp")
173
+ gribatomaton_hp.train(:gribatomaton_ten_hp, "Gribatomaton ten hp left.", "tenhp")
174
+
175
+ @classification2 = gribatomaton_hp.classify(@decision1)
176
+
177
+ puts " "
178
+
179
+ print @classification2
180
+ end
181
+
182
+ def self.enemy_hp_statistics
183
+ require "SelfModifyingDecisionTree"
184
+
185
+ enemy_hp = NaiveBayes.new(:enemy_no_hp,
186
+ :enemy_three_hp,
187
+ :enemy_five_hp,
188
+ :enemy_eight_hp,
189
+ :enemy_ten_hp,
190
+ )
191
+
192
+ enemy_hp.train(:enemy_no_hp, "enemy has no hp left.", "nohp")
193
+ enemy_hp.train(:enemy_three_hp, "enemy has three hp left.", "threehp")
194
+ enemy_hp.train(:enemy_five_hp, "enemy has five hp left.", "fivehp")
195
+ enemy_hp.train(:enemy_eight_hp, "enemy has eight hp left.", "eighthp")
196
+ enemy_hp.train(:enemy_ten_hp, "enemy ten hp left.", "tenhp")
197
+
198
+ @classification3 = enemy_hp.classify(@decision1)
199
+
200
+ puts " "
201
+
202
+ print @classification3
203
+ end
204
+
205
+ def self.decrement_inputs # Input taxation
206
+ player_input = @classification1[1]
207
+ gribatomaton_input = @classification2[1]
208
+ enemy_input = @classification3[1]
209
+
210
+ if player_input < 50.0; # Lose HP
211
+ if gribatomaton_input > enemy_input; player_input = player_input - gribatomaton_input
212
+ elsif enemy_input > gribatomaton_input; player_input = player_input - enemy_input
213
+ end
214
+ elsif player_input > 75.0; # Gain HP
215
+ if gribatomaton_input < enemy_input; player_input = player_input + gribatomaton_input
216
+ elsif enemy_input < gribatomaton_input; player_input = player_input + gribatomaton_input
217
+ end
218
+ end
219
+
220
+ if gribatomaton_input < 50.0;
221
+ if player_input > enemy_input; gribatomaton_input = gribatomaton_input - player_input
222
+ elsif enemy_input > player_input; gribatomaton_input = gribatomaton_input - enemy_input
223
+ end
224
+ elsif gribatomaton_input > 75.0;
225
+ if player_input > enemy_input; gribatomaton_input = gribatomaton_input - player_input
226
+ elsif enemy_input > player_input; gribatomaton_input = gribatomaton_input - enemy_input
227
+ end
228
+ end
229
+
230
+ if enemy_input < 50.0;
231
+ if player_input > enemy_input; enemy_input = enemy_input - player_input
232
+ elsif enemy_input > player_input; enemy_input = enemy_input - enemy_input
233
+ end
234
+ elsif enemy_input > 75.0;
235
+ if player_input > enemy_input; enemy_input = enemy_input + player_input
236
+ elsif enemy_input > player_input; enemy_input = enemy_input + enemy_input
237
+ end
238
+ end
239
+
240
+ @player_hp = @player_hp - player_input
241
+ @gribatomaton_hp = @gribatomaton_hp - gribatomaton_input
242
+ @enemy_hp = @enemy_hp - enemy_input
243
+ end
244
+
245
+ ############################################################################################
246
+ # Probability Of Survival #
247
+ ############################################################################################
248
+ # This section predicts the survival rate of the player, gribatomaton, or enemy during #
249
+ # particular stressful periods, like starving and being in the same dungeon together. #
250
+ ############################################################################################
251
+ def self.loyalty_or_death
252
+ require "SelfModifyingDecisionTree"
253
+
254
+ survivors = NaiveBayes.new(:player_survives,
255
+ :gribatomaton_survives,
256
+ :enemy_survives,
257
+ :player_perishes,
258
+ :gribatomaton_perishes,
259
+ :enemy_perishes,
260
+ )
261
+
262
+ # Survival Statistics
263
+
264
+ ## Player Survives
265
+ survivors.train(:player_survives, "[:player_ten_hp, #{@classification1[1]}]", "player survives")
266
+ survivors.train(:player_survives, "[:player_eight_hp, #{@classification1[1]}]", "player survives")
267
+ survivors.train(:player_survives, "[:player_five_hp, #{@classification1[1]}]", "player survives")
268
+ survivors.train(:player_survives, "[:player_three_hp, #{@classification1[1]}]", "player survives")
269
+
270
+ ## Gribatomaton Survives
271
+ survivors.train(:gribatomaton_survives, "[:gribatomaton_ten_hp, #{@classification2[1]}]", "gribatomaton survives")
272
+ survivors.train(:gribatomaton_survives, "[:gribatomaton_eight_hp, #{@classification2[1]}]", "gribatomaton survives")
273
+ survivors.train(:gribatomaton_survives, "[:gribatomaton_five_hp, #{@classification2[1]}]", "gribatomaton survives")
274
+ survivors.train(:gribatomaton_survives, "[:gribatomaton_three_hp, #{@classification2[1]}]", "gribatomaton survives")
275
+
276
+ ## Enemy Survives
277
+ survivors.train(:enemy_survives, "[:enemy_ten_hp, #{@classification3[1]}]", "enemy survives")
278
+ survivors.train(:enemy_survives, "[:enemy_eight_hp, #{@classification3[1]}]", "enemy survives")
279
+ survivors.train(:enemy_survives, "[:enemy_five_hp, #{@classification3[1]}]", "enemy survives")
280
+ survivors.train(:enemy_survives, "[:enemy_three_hp, #{@classification3[1]}]", "enemy survives")
281
+
282
+ # Fatality Rates
283
+ survivors.train(:player_perishes, "[:player_no_hp, #{@classification1[1]}]", "player perishes")
284
+ survivors.train(:gribatomaton_perishes, "[:gribatomaton_no_hp, #{@classification1[1]}]", "gribatomaton perishes")
285
+ survivors.train(:enemy_perishes, "[:enemy_no_hp, #{@classification1[1]}]", "enemy perishes")
286
+
287
+ @classification4 = survivors.classify(@net_outcome)
288
+ puts "\n"
289
+ print @classification4
290
+ puts " "
291
+ end
292
+
293
+ def self.xakutisfiqe
294
+ print "How many generations of confinement? << "; generations = gets.chomp.to_i
295
+
296
+ # Generates random input entry points
297
+ Communemashin::Counters.starting_stats
298
+
299
+ generations.times do
300
+ Communemashin::Counters.actions_against_co_inmates
301
+
302
+ Communemashin::Counters.player_hp_statistics
303
+ Communemashin::Counters.gribatomaton_hp_statistics
304
+ Communemashin::Counters.enemy_hp_statistics
305
+ end
306
+
307
+ Communemashin::Counters.decrement_inputs
308
+ Communemashin::Counters.loyalty_or_death
309
+ end
310
+
311
+ # An alias of the experimental function
312
+ def self.mengexakume
313
+ print "How many generations of confinement? << "; generations = gets.chomp.to_i
314
+
315
+ # Generates random input entry points
316
+ Communemashin::Counters.starting_stats
317
+
318
+ generations.times do
319
+ Communemashin::Counters.actions_against_co_inmates
320
+
321
+ Communemashin::Counters.player_hp_statistics
322
+ Communemashin::Counters.gribatomaton_hp_statistics
323
+ Communemashin::Counters.enemy_hp_statistics
324
+ end
325
+
326
+ Communemashin::Counters.decrement_inputs
327
+ Communemashin::Counters.loyalty_or_death
328
+ end
329
+ end
330
+
331
+ class Economic
332
+ def self.generate_albert
333
+ # 00.50 25.25 50.00 62.50 75.00 87.50 100.0
334
+ # 00.50 0.5,0.5 0.5,25.25 0.5,50.00 0.5,62.50 0.5,75.00 0.5,87.50 0.5,100.0
335
+ # 25.25 25.25,0.5 25.25,25.25 25.25,50.00 25.25,62.50 25.25,75.00 25.25,87.50 25.25,100.0
336
+ # 50.00 50.00,0.5 50.00,25.25 50.00,50.00 50.00,62.50 50.00,75.00 50.00,87.50 50.00,100.0
337
+ # 62.50 62.50,0.5 62.50,25.25 62.50,50.00 62.50,62.50 62.50,75.00 62.50,87.50 62.50,100.0
338
+ # 75.00 75.00,0.5 75.00,25.25 75.00,50.00 75.00,62.50 75.00,75.00 75.00,87.50 75.00,100.0
339
+ # 87.50 87.50,0.5 87.50,25.25 87.50,50.00 87.50,62.50 87.50,75.00 87.50,87.50 87.50,100.0
340
+ # 100.00
341
+
342
+ possible_input = [
343
+ [[ 0.5, 0.5 ], [ 0.5, 25.25 ], [ 0.5, 50.00 ], [ 0.5, 62.50 ], [ 0.5, 75.00 ], [ 0.5, 75.00 ], [ 0.5, 87.5 ], [ 0.5, 100.0] ],
344
+ [[ 25.25, 0.5 ], [ 25.25, 25.25 ], [ 25.25, 50.00 ], [ 25.25, 62.50 ], [ 25.25, 75.00 ], [ 25.25, 75.00 ], [ 25.25, 87.5 ], [ 25.25, 100.0] ],
345
+ [[ 50.00, 0.5 ], [ 50.00, 25.25 ], [ 50.00, 50.00 ], [ 50.00, 62.50 ], [ 50.00, 75.00 ], [ 50.00, 75.00 ], [ 50.00, 87.5 ], [ 50.00, 100.0] ],
346
+ [[ 62.50, 0.5 ], [ 62.50, 25.25 ], [ 62.50, 50.00 ], [ 62.50, 62.50 ], [ 62.50, 75.00 ], [ 62.50, 75.00 ], [ 62.50, 87.5 ], [ 62.50, 100.0] ],
347
+ [[ 75.00, 0.5 ], [ 75.00, 25.25 ], [ 75.00, 50.00 ], [ 75.00, 62.50 ], [ 75.00, 75.00 ], [ 75.00, 75.00 ], [ 75.00, 87.5 ], [ 75.00, 100.0] ],
348
+ [[ 87.50, 0.5 ], [ 87.50, 25.25 ], [ 87.50, 50.00 ], [ 87.50, 62.50 ], [ 87.50, 75.00 ], [ 87.50, 75.00 ], [ 87.50, 87.5 ], [ 87.50, 100.0] ],
349
+ [[ 100.00, 0.5 ], [ 100.00, 25.25 ], [ 100.00, 50.00 ], [ 100.00, 62.50 ], [ 100.00, 75.00 ], [ 100.00, 75.00 ], [ 100.00, 87.5 ], [ 100.00, 100.0] ],
350
+ ]
351
+
352
+ row_options = [0, 1, 2, 3, 4, 5, 6]
353
+ col_options = [0, 1, 2, 3, 4, 5, 6, 7]
354
+ arr_options = [0, 1]
355
+
356
+ cur_row = row_options.sample
357
+ cur_col = col_options.sample
358
+ cur_arr = arr_options.sample
359
+
360
+ @alberts_input = possible_input[cur_row][cur_col][cur_arr]
361
+ end
362
+
363
+ def self.generate_andy
364
+ # 00.50 25.25 50.00 62.50 75.00 87.50 100.0
365
+ # 00.50 0.5,0.5 0.5,25.25 0.5,50.00 0.5,62.50 0.5,75.00 0.5,87.50 0.5,100.0
366
+ # 25.25 25.25,0.5 25.25,25.25 25.25,50.00 25.25,62.50 25.25,75.00 25.25,87.50 25.25,100.0
367
+ # 50.00 50.00,0.5 50.00,25.25 50.00,50.00 50.00,62.50 50.00,75.00 50.00,87.50 50.00,100.0
368
+ # 62.50 62.50,0.5 62.50,25.25 62.50,50.00 62.50,62.50 62.50,75.00 62.50,87.50 62.50,100.0
369
+ # 75.00 75.00,0.5 75.00,25.25 75.00,50.00 75.00,62.50 75.00,75.00 75.00,87.50 75.00,100.0
370
+ # 87.50 87.50,0.5 87.50,25.25 87.50,50.00 87.50,62.50 87.50,75.00 87.50,87.50 87.50,100.0
371
+ # 100.00
372
+
373
+ possible_input = [
374
+ [[ 0.5, 0.5 ], [ 0.5, 25.25 ], [ 0.5, 50.00 ], [ 0.5, 62.50 ], [ 0.5, 75.00 ], [ 0.5, 75.00 ], [ 0.5, 87.5 ], [ 0.5, 100.0] ],
375
+ [[ 25.25, 0.5 ], [ 25.25, 25.25 ], [ 25.25, 50.00 ], [ 25.25, 62.50 ], [ 25.25, 75.00 ], [ 25.25, 75.00 ], [ 25.25, 87.5 ], [ 25.25, 100.0] ],
376
+ [[ 50.00, 0.5 ], [ 50.00, 25.25 ], [ 50.00, 50.00 ], [ 50.00, 62.50 ], [ 50.00, 75.00 ], [ 50.00, 75.00 ], [ 50.00, 87.5 ], [ 50.00, 100.0] ],
377
+ [[ 62.50, 0.5 ], [ 62.50, 25.25 ], [ 62.50, 50.00 ], [ 62.50, 62.50 ], [ 62.50, 75.00 ], [ 62.50, 75.00 ], [ 62.50, 87.5 ], [ 62.50, 100.0] ],
378
+ [[ 75.00, 0.5 ], [ 75.00, 25.25 ], [ 75.00, 50.00 ], [ 75.00, 62.50 ], [ 75.00, 75.00 ], [ 75.00, 75.00 ], [ 75.00, 87.5 ], [ 75.00, 100.0] ],
379
+ [[ 87.50, 0.5 ], [ 87.50, 25.25 ], [ 87.50, 50.00 ], [ 87.50, 62.50 ], [ 87.50, 75.00 ], [ 87.50, 75.00 ], [ 87.50, 87.5 ], [ 87.50, 100.0] ],
380
+ [[ 100.00, 0.5 ], [ 100.00, 25.25 ], [ 100.00, 50.00 ], [ 100.00, 62.50 ], [ 100.00, 75.00 ], [ 100.00, 75.00 ], [ 100.00, 87.5 ], [ 100.00, 100.0] ],
381
+ ]
382
+
383
+ row_options = [0, 1, 2, 3, 4, 5, 6]
384
+ col_options = [0, 1, 2, 3, 4, 5, 6, 7]
385
+ arr_options = [0, 1]
386
+
387
+ cur_row = row_options.sample
388
+ cur_col = col_options.sample
389
+ cur_arr = arr_options.sample
390
+
391
+ @andys_input = possible_input[cur_row][cur_col][cur_arr]
392
+ end
393
+
394
+ def self.generate_bethany
395
+ # 00.50 25.25 50.00 62.50 75.00 87.50 100.0
396
+ # 00.50 0.5,0.5 0.5,25.25 0.5,50.00 0.5,62.50 0.5,75.00 0.5,87.50 0.5,100.0
397
+ # 25.25 25.25,0.5 25.25,25.25 25.25,50.00 25.25,62.50 25.25,75.00 25.25,87.50 25.25,100.0
398
+ # 50.00 50.00,0.5 50.00,25.25 50.00,50.00 50.00,62.50 50.00,75.00 50.00,87.50 50.00,100.0
399
+ # 62.50 62.50,0.5 62.50,25.25 62.50,50.00 62.50,62.50 62.50,75.00 62.50,87.50 62.50,100.0
400
+ # 75.00 75.00,0.5 75.00,25.25 75.00,50.00 75.00,62.50 75.00,75.00 75.00,87.50 75.00,100.0
401
+ # 87.50 87.50,0.5 87.50,25.25 87.50,50.00 87.50,62.50 87.50,75.00 87.50,87.50 87.50,100.0
402
+ # 100.00
403
+
404
+ possible_input = [
405
+ [[ 0.5, 0.5 ], [ 0.5, 25.25 ], [ 0.5, 50.00 ], [ 0.5, 62.50 ], [ 0.5, 75.00 ], [ 0.5, 75.00 ], [ 0.5, 87.5 ], [ 0.5, 100.0] ],
406
+ [[ 25.25, 0.5 ], [ 25.25, 25.25 ], [ 25.25, 50.00 ], [ 25.25, 62.50 ], [ 25.25, 75.00 ], [ 25.25, 75.00 ], [ 25.25, 87.5 ], [ 25.25, 100.0] ],
407
+ [[ 50.00, 0.5 ], [ 50.00, 25.25 ], [ 50.00, 50.00 ], [ 50.00, 62.50 ], [ 50.00, 75.00 ], [ 50.00, 75.00 ], [ 50.00, 87.5 ], [ 50.00, 100.0] ],
408
+ [[ 62.50, 0.5 ], [ 62.50, 25.25 ], [ 62.50, 50.00 ], [ 62.50, 62.50 ], [ 62.50, 75.00 ], [ 62.50, 75.00 ], [ 62.50, 87.5 ], [ 62.50, 100.0] ],
409
+ [[ 75.00, 0.5 ], [ 75.00, 25.25 ], [ 75.00, 50.00 ], [ 75.00, 62.50 ], [ 75.00, 75.00 ], [ 75.00, 75.00 ], [ 75.00, 87.5 ], [ 75.00, 100.0] ],
410
+ [[ 87.50, 0.5 ], [ 87.50, 25.25 ], [ 87.50, 50.00 ], [ 87.50, 62.50 ], [ 87.50, 75.00 ], [ 87.50, 75.00 ], [ 87.50, 87.5 ], [ 87.50, 100.0] ],
411
+ [[ 100.00, 0.5 ], [ 100.00, 25.25 ], [ 100.00, 50.00 ], [ 100.00, 62.50 ], [ 100.00, 75.00 ], [ 100.00, 75.00 ], [ 100.00, 87.5 ], [ 100.00, 100.0] ],
412
+ ]
413
+
414
+ row_options = [0, 1, 2, 3, 4, 5, 6]
415
+ col_options = [0, 1, 2, 3, 4, 5, 6, 7]
416
+ arr_options = [0, 1]
417
+
418
+ cur_row = row_options.sample
419
+ cur_col = col_options.sample
420
+ cur_arr = arr_options.sample
421
+
422
+ @bethanys_input = possible_input[cur_row][cur_col][cur_arr]
423
+ end
424
+
425
+ def self.decision_from_contribution
426
+ require "SelfModifiedDecisionTree"
427
+
428
+ attributes = ["Contribution Of Albert"], ["Contribution Of Andy"], ["Contribution Of Bethany"]
429
+
430
+ training = [
431
+ [0.5, "No Contribution"],
432
+ [25.25, "Minimal Contribution"],
433
+ [50.0, "Some Contribution"],
434
+ [62.5, "Significant Contribution"],
435
+ [75.0, "Large Contribution"],
436
+ [87.5, "Major Contribution"],
437
+ [100.0, "Full Contribution"],
438
+ ], [
439
+ [0.5, "No Contribution"],
440
+ [25.25, "Minimal Contribution"],
441
+ [50.0, "Some Contribution"],
442
+ [62.5, "Significant Contribution"],
443
+ [75.0, "Large Contribution"],
444
+ [87.5, "Major Contribution"],
445
+ [100.0, "Full Contribution"],
446
+ ], [
447
+ [0.5, "No Contribution"],
448
+ [25.25, "Minimal Contribution"],
449
+ [50.0, "Some Contribution"],
450
+ [62.5, "Significant Contribution"],
451
+ [75.0, "Large Contribution"],
452
+ [87.5, "Major Contribution"],
453
+ [100.0, "Full Contribution"],
454
+ ]
455
+
456
+ dec_tree_configurations = DecisionTree::ID3Tree.new(attributes[0], training[0], 1, :continuous),
457
+ DecisionTree::ID3Tree.new(attributes[1], training[1], 1, :continuous),
458
+ DecisionTree::ID3Tree.new(attributes[2], training[2], 1, :continuous)
459
+
460
+ current_dectree1 = dec_tree_configurations[0]
461
+ current_dectree1.train
462
+
463
+ current_dectree2 = dec_tree_configurations[1]
464
+ current_dectree2.train
465
+
466
+ current_dectree3 = dec_tree_configurations[2]
467
+ current_dectree3.train
468
+
469
+ test1 = [@alberts_input, "Significant Contribution"]
470
+ test2 = [@andys_input, "Significant Contribution"]
471
+ test3 = [@bethanys_input, "Significant Contribution"]
472
+
473
+ @decision1 = current_dectree1.predict(test1) # This being Alberts contribution
474
+ @decision2 = current_dectree2.predict(test2) # This being Andys contribution
475
+ @decision3 = current_dectree3.predict(test3) # This being Bethanys contribution
476
+
477
+ puts "\nPredicted: Compared to #{test1.last}, Albert made #{@decision1}"
478
+ puts "Predicted: Compared to #{test2.last}, Andy made #{@decision2}"
479
+ puts "Predicted: Compared to #{test3.last}, Bethany made #{@decision3}\n"
480
+
481
+ @net_outcome = "Predicted: Compared to #{test1.last}, Albert made #{@decision1} Predicted: Compared to #{test2.last}, Andy made #{@decision2} Predicted: Compared to #{test3.last}, Bethany made #{@decision3}\n"
482
+ end
483
+
484
+ ## Statistics models
485
+ def self.alberts_contributions
486
+ require "SelfModifiedDecisionTree"
487
+
488
+ alberts_contributions = RevisedBayes.new(:no_contribution,
489
+ :minimal_contribution,
490
+ :some_contribution,
491
+ :significant_contribution,
492
+ :large_contribution,
493
+ :major_contribution,
494
+ :full_contribution
495
+ )
496
+
497
+ alberts_contributions.train(:no_contribution, "No Contribution", "contribution")
498
+ alberts_contributions.train(:minimal_contribution, "Minimal Contribution", "contribution")
499
+ alberts_contributions.train(:some_contribution, "Some Contribution", "contribution")
500
+ alberts_contributions.train(:significant_contribution, "Significant Contribution", "contribution")
501
+ alberts_contributions.train(:large_contribution, "Large Contribution", "contribution")
502
+ alberts_contributions.train(:major_contribution, "Major Contribution", "contribution")
503
+ alberts_contributions.train(:full_contribution, "Full Contribution", "contribution")
504
+
505
+ @classification1 = alberts_contributions.classify(@decision1)
506
+
507
+ puts " "
508
+
509
+ print @classification1
510
+ end
511
+
512
+ def self.andys_contributions
513
+ require "SelfModifiedDecisionTree"
514
+
515
+ andys_contributions = RevisedBayes.new(:no_contribution,
516
+ :minimal_contribution,
517
+ :some_contribution,
518
+ :significant_contribution,
519
+ :large_contribution,
520
+ :major_contribution,
521
+ :full_contribution
522
+ )
523
+
524
+ andys_contributions.train(:no_contribution, "No Contribution", "contribution")
525
+ andys_contributions.train(:minimal_contribution, "Minimal Contribution", "contribution")
526
+ andys_contributions.train(:some_contribution, "Some Contribution", "contribution")
527
+ andys_contributions.train(:significant_contribution, "Significant Contribution", "contribution")
528
+ andys_contributions.train(:large_contribution, "Large Contribution", "contribution")
529
+ andys_contributions.train(:major_contribution, "Major Contribution", "contribution")
530
+ andys_contributions.train(:full_contribution, "Full Contribution", "contribution")
531
+
532
+ @classification2 = andys_contributions.classify(@decision1)
533
+
534
+ puts " "
535
+
536
+ print @classification2
537
+ end
538
+
539
+ def self.bethanys_contributions
540
+ require "SelfModifiedDecisionTree"
541
+
542
+ bethanys_contributions = RevisedBayes.new(:no_contribution,
543
+ :minimal_contribution,
544
+ :some_contribution,
545
+ :significant_contribution,
546
+ :large_contribution,
547
+ :major_contribution,
548
+ :full_contribution
549
+ )
550
+
551
+ bethanys_contributions.train(:no_contribution, "No Contribution", "contribution")
552
+ bethanys_contributions.train(:minimal_contribution, "Minimal Contribution", "contribution")
553
+ bethanys_contributions.train(:some_contribution, "Some Contribution", "contribution")
554
+ bethanys_contributions.train(:significant_contribution, "Significant Contribution", "contribution")
555
+ bethanys_contributions.train(:large_contribution, "Large Contribution", "contribution")
556
+ bethanys_contributions.train(:major_contribution, "Major Contribution", "contribution")
557
+ bethanys_contributions.train(:full_contribution, "Full Contribution", "contribution")
558
+
559
+ @classification3 = bethanys_contributions.classify(@decision1)
560
+
561
+ puts " "
562
+
563
+ print @classification3
564
+ end
565
+
566
+ def self.supplement_inputs # Input taxation
567
+ alberts_input = @classification1[1]
568
+ andys_input = @classification2[1]
569
+ bethanys_input = @classification3[1]
570
+
571
+ if alberts_input < 50.0; # Negative taxation
572
+ if andys_input > bethanys_input; alberts_input = alberts_input + andys_input
573
+ elsif bethanys_input > andys_input; alberts_input = alberts_input + bethanys_input
574
+ end
575
+ elsif alberts_input > 75.0; # Positive taxation
576
+ if andys_input < bethanys_input; alberts_input = alberts_input - andys_input
577
+ elsif bethanys_input < andys_input; alberts_input = alberts_input - andys_input
578
+ end
579
+ end
580
+
581
+ if andys_input < 50.0;
582
+ if alberts_input > bethanys_input; andys_input = andys_input + alberts_input
583
+ elsif bethanys_input > alberts_input; andys_input = andys_input + bethanys_input
584
+ end
585
+ elsif andys_input > 75.0;
586
+ if alberts_input > bethanys_input; andys_input = andys_input + alberts_input
587
+ elsif bethanys_input > alberts_input; andys_input = andys_input + bethanys_input
588
+ end
589
+ end
590
+
591
+ if bethanys_input < 50.0;
592
+ if alberts_input > bethanys_input; bethanys_input = bethanys_input + alberts_input
593
+ elsif bethanys_input > alberts_input; bethanys_input = bethanys_input + bethanys_input
594
+ end
595
+ elsif bethanys_input > 75.0;
596
+ if alberts_input > bethanys_input; bethanys_input = bethanys_input - alberts_input
597
+ elsif bethanys_input > alberts_input; bethanys_input = bethanys_input - bethanys_input
598
+ end
599
+ end
600
+
601
+ @alberts_input = alberts_input
602
+ @andys_input = andys_input
603
+ @bethanys_input = bethanys_input
604
+ end
605
+
606
+ def self.communist_or_fascist
607
+ require "SelfModifiedDecisionTree"
608
+
609
+ communism_or_fascism = RevisedBayes.new(:desparity, :thriving, :economic_crash)
610
+
611
+ ## Non Egalitarian
612
+ communism_or_fascism.train(:desparity, "Predicted: Compared to Significant Contribution, Albert made Some Contribution
613
+ Predicted: Compared to Significant Contribution, Andy made Large Contribution
614
+ Predicted: Compared to Significant Contribution, Bethany made Minimal Contribution
615
+
616
+ [:some_contribution, 0.14285714285714285]
617
+ [:some_contribution, 0.14285714285714285]
618
+ [:some_contribution, 0.14285714285714285]", "non egalitarian")
619
+
620
+ communism_or_fascism.train(:desparity, "Predicted: Compared to Significant Contribution, Albert made Significant Contribution
621
+ Predicted: Compared to Significant Contribution, Andy made Minimal Contribution
622
+ Predicted: Compared to Significant Contribution, Bethany made Some Contribution
623
+
624
+ [:significant_contribution, 0.14285714285714285]
625
+ [:significant_contribution, 0.14285714285714285]
626
+ [:significant_contribution, 0.14285714285714285]", "non egalitarian")
627
+
628
+ # Surplus
629
+ communism_or_fascism.train(:thriving, "Predicted: Compared to Significant Contribution, Albert made Significant Contribution
630
+ Predicted: Compared to Significant Contribution, Andy made Major Contribution
631
+ Predicted: Compared to Significant Contribution, Bethany made Full Contribution
632
+
633
+ [:significant_contribution, 0.14285714285714285]
634
+ [:significant_contribution, 0.14285714285714285]
635
+ [:significant_contribution, 0.14285714285714285]", "surplus")
636
+
637
+ communism_or_fascism.train(:thriving, "Predicted: Compared to Significant Contribution, Albert made Major Contribution
638
+ Predicted: Compared to Significant Contribution, Andy made Large Contribution
639
+ Predicted: Compared to Significant Contribution, Bethany made Large Contribution
640
+
641
+ [:major_contribution, 0.14285714285714285]
642
+ [:major_contribution, 0.14285714285714285]
643
+ [:major_contribution, 0.14285714285714285]", "surplus")
644
+
645
+ # Egalitarian
646
+ communism_or_fascism.train(:economic_crash, "Predicted: Compared to Significant Contribution, Albert made Significant Contribution
647
+ Predicted: Compared to Significant Contribution, Andy made Minimal Contribution
648
+ Predicted: Compared to Significant Contribution, Bethany made Significant Contribution
649
+
650
+ [:significant_contribution, 0.14285714285714285]
651
+ [:significant_contribution, 0.14285714285714285]
652
+ [:significant_contribution, 0.14285714285714285]", "egalitarian")
653
+
654
+ @classification4 = communism_or_fascism.classify(@net_outcome)
655
+
656
+ puts "\n"
657
+
658
+ print @classification4
659
+
660
+ puts " "
661
+ end
662
+
663
+ def self.cycles
664
+ print "How many generations of taxation? << "; generations = gets.chomp.to_i
665
+
666
+ # Generates random input entry points
667
+ Communemashin::Economic.generate_albert
668
+ Communemashin::Economic.generate_andy
669
+ Communemashin::Economic.generate_bethany
670
+
671
+ generations.times do
672
+ Communemashin::Economic.decision_from_contribution
673
+
674
+ Communemashin::Economic.alberts_contributions
675
+ Communemashin::Economic.andys_contributions
676
+ Communemashin::Economic.bethanys_contributions
677
+ end
678
+
679
+ Communemashin::Economic.communist_or_fascist
680
+ Communemashin::Economic.supplement_inputs
681
+ end
682
+ end
683
+
684
+ class ESDF
685
+ def self.word_class
686
+ word_classes = [[
687
+ [
688
+ [["Le", "Le"], ["Le", "La"], ["Le", "Les"]],
689
+ [["La", "Le"], ["La", "La"], ["La", "Les"]],
690
+ [["Les", "Le"], ["Les", "La"], ["Les", "Les"]],
691
+ ], [
692
+ [["Anu", "Anu"], ["Anu", "Ana"], ["Anu", "Anos"]],
693
+ [["Ana", "Anu"], ["Ana", "Ana"], ["Ana", "Anos"]],
694
+ [["Anos", "Anu"], ["Anos", "Ana"], ["Anos", "Anus"]],
695
+ ], [
696
+ [["Lanu", "Lanu"], ["Lanu", "Lana"], ["Lanu", "Lanos"]],
697
+ [["Lana", "Lanu"], ["Lana", "Lana"], ["Lana", "Lanos"]],
698
+ [["Lanos", "Lanu"], ["Lanos", "Lana"], ["Lanos", "Lanos"]],
699
+ ],
700
+ ], [
701
+ [
702
+ [["El", "El"], ["El", "Al"], ["El", "Els"]],
703
+ [["Al", "El"], ["Al", "Al"], ["Al", "Els"]],
704
+ [["Els", "El"], ["Els", "Al"], ["Els", "Els"]],
705
+ ], [
706
+ [["Nua", "Naa"], ["Nua", "Naa"], ["Nua", "Nosa"]],
707
+ [["Naa", "Naa"], ["Naa", "Naa"], ["Naa", "Nosa"]],
708
+ [["Nosa", "Naa"], ["Nosa", "Naa"], ["Nosa", "Nosa"]],
709
+ ], [
710
+ [["Nula", "Nula"], ["Nula", "Nala"], ["Nula", "Nosal"]],
711
+ [["Nala", "Nula"], ["Nala", "Nala"], ["Nala", "Nosal"]],
712
+ [["Nosal", "Nula"], ["Nosal", "Nala"], ["Nosal", "Nosal"]],
713
+ ],
714
+ ]]
715
+
716
+ context_window = [0, 1, 2]
717
+ row_options = [0, 1, 2]
718
+ col_options = [0, 1, 2]
719
+ arr_options = [0, 1]
720
+
721
+ # Modifies word genders based on sanity state.
722
+ current_sanity = File.read("_data/npc/dialogue/sanity.txt").to_i
723
+
724
+ cur_con = context_window.sample
725
+ cur_row = row_options.sample
726
+ cur_col = col_options.sample
727
+ cur_arr = arr_options.sample
728
+
729
+ @chosen_word_class = word_classes[current_sanity][cur_con][cur_row][cur_col][cur_arr]
730
+ end
731
+
732
+ def self.nouns
733
+ ## This covers the generation of classified nouns.
734
+ ho = ["homme", "ommehay"]
735
+ fe = ["femme", "emmefay"]
736
+ fi = ["fille", "illefay"]
737
+ ga = ["garcon", "arcongay"]
738
+ ta = ["tante", "antetay"]
739
+ oj = ["oncle", "cleoney"]
740
+ cofi = ["cousinfille", "ousincay illefay"]
741
+ coga = ["cousingarcon", "ousincay arcongay"]
742
+ grm = [ "grandmere", "randgay eremay"]
743
+ grp = [ "grandpere", "randgay erepay"]
744
+
745
+ ct = [ "chat", "atchay"]
746
+ ch = [ "chien", "ienchay"]
747
+ oi = [ "oiseau", "seauoiay"]
748
+ gr = [ "souris", "ourisay"]
749
+ ou = [ "ours", "ursoay"]
750
+ wo = [ "orgueil", "gueiloray"]
751
+ pr = ["ostritch", "ritchostray"]
752
+ po = [ "jiraff", "iraffjay"]
753
+ pi = ["écureuil", "ureuilecay"]
754
+
755
+ m = ["maison", "aisonmay"]
756
+ c = [ "cabin", "abincay"]
757
+ e = [ "ecole", "coleay"]
758
+
759
+ oju = [ "ojijaku", "jijakuoay"]
760
+ neo = ["ne ojijaku", "ne jijakuoay"]
761
+
762
+ nouns_sanity = [[
763
+ [[ho[0], ho[0]], [ho[0], fe[0]], [ho[0], fi[0]], [ho[0], ga[0]], [ho[0], ta[0]], [ho[0], oj[0]], [ho[0], cofi[0]], [ho[0], coga[0]], [ho[0], grm[0]], [ho[0], grp[0]]],
764
+ [[fe[0], ho[0]], [fe[0], fe[0]], [fe[0], fi[0]], [fe[0], ga[0]], [fe[0], ta[0]], [fe[0], oj[0]], [fe[0], cofi[0]], [fe[0], coga[0]], [fe[0], grm[0]], [fe[0], grp[0]]],
765
+ [[fi[0], ho[0]], [fi[0], fe[0]], [fi[0], fi[0]], [fi[0], ga[0]], [fi[0], ta[0]], [fi[0], oj[0]], [fi[0], cofi[0]], [fi[0], coga[0]], [fi[0], grm[0]], [fi[0], grp[0]]],
766
+ [[ga[0], ho[0]], [ga[0], fe[0]], [ga[0], fi[0]], [ga[0], ga[0]], [ga[0], ta[0]], [ga[0], oj[0]], [ga[0], cofi[0]], [ga[0], coga[0]], [ga[0], grm[0]], [ga[0], grp[0]]],
767
+ [[ta[0], ho[0]], [ta[0], fe[0]], [ta[0], fi[0]], [ta[0], ga[0]], [ta[0], ta[0]], [ta[0], oj[0]], [ta[0], cofi[0]], [ta[0], coga[0]], [ta[0], grm[0]], [ta[0], grp[0]]],
768
+ [[oj[0], ho[0]], [oj[0], fe[0]], [oj[0], fi[0]], [oj[0], ga[0]], [oj[0], ta[0]], [oj[0], oj[0]], [oj[0], cofi[0]], [oj[0], coga[0]], [oj[0], grm[0]], [oj[0], grp[0]]],
769
+ [[cofi[0], ho[0]], [cofi[0], fe[0]], [cofi[0], fi[0]], [cofi[0], ga[0]], [cofi[0], ta[0]], [cofi[0], oj[0]], [cofi[0], cofi[0]], [cofi[0], coga[0]], [cofi[0], grm[0]], [cofi[0], grp[0]]],
770
+ [[coga[0], ho[0]], [coga[0], fe[0]], [coga[0], fi[0]], [coga[0], ga[0]], [coga[0], ta[0]], [coga[0], oj[0]], [coga[0], cofi[0]], [coga[0], coga[0]], [coga[0], grm[0]], [coga[0], grp[0]]],
771
+ [[grm[0], ho[0]], [grm[0], fe[0]], [grm[0], fi[0]], [grm[0], ga[0]], [grm[0], ta[0]], [grm[0], oj[0]], [grm[0], cofi[0]], [grm[0], coga[0]], [grm[0], grm[0]], [grm[0], grp[0]]],
772
+ [[grp[0], ho[0]], [grp[0], fe[0]], [grp[0], fi[0]], [grp[0], ga[0]], [grp[0], ta[0]], [grp[0], oj[0]], [grp[0], cofi[0]], [grp[0], coga[0]], [grp[0], grm[0]], [grp[0], grp[0]]],
773
+ ], [
774
+ [[ct[0], ct[0]], [ct[0], ch[0]], [ct[0], oi[0]], [ct[0], gr[0]], [ct[0], wo[0]], [ct[0], ou[0]], [ct[0], pr[0]], [ct[0], po[0]]],
775
+ [[ch[0], ct[0]], [ch[0], ch[0]], [ch[0], oi[0]], [ch[0], gr[0]], [ch[0], wo[0]], [ch[0], ou[0]], [ch[0], pr[0]], [ch[0], po[0]]],
776
+ [[oi[0], ct[0]], [oi[0], ch[0]], [oi[0], oi[0]], [pi[0], gr[0]], [oi[0], wo[0]], [oi[0], ou[0]], [oi[0], pr[0]], [oi[0], po[0]]],
777
+ [[gr[0], ct[0]], [gr[0], ch[0]], [gr[0], oi[0]], [gr[0], gr[0]], [gr[0], wo[0]], [gr[0], ou[0]], [gr[0], pr[0]], [gr[0], po[0]]],
778
+ ], [
779
+ [[m[0], m[0]], [m[0], c[0]], [m[0], e[0]]],
780
+ [[c[0], m[0]], [c[0], c[0]], [c[0], e[0]]],
781
+ [[e[0], m[0]], [e[0], c[0]], [e[0], e[0]]],
782
+ ], [
783
+ [[oju[0], oju[0]], [oju[0], neo[0]]],
784
+ [[neo[0], oju[0]], [neo[0], neo[0]]],
785
+ ]]
786
+
787
+ nouns_insanity = [[
788
+ [[ho[1], ho[1]], [ho[1], fe[1]], [ho[1], fi[1]], [ho[1], ga[1]], [ho[1], ta[1]], [ho[1], oj[1]], [ho[1], cofi[1]], [ho[1], coga[1]], [ho[1], grm[1]], [ho[1], grp[1]]],
789
+ [[fe[1], ho[1]], [fe[1], fe[1]], [fe[1], fi[1]], [fe[1], ga[1]], [fe[1], ta[1]], [fe[1], oj[1]], [fe[1], cofi[1]], [fe[1], coga[1]], [fe[1], grm[1]], [fe[1], grp[1]]],
790
+ [[fi[1], ho[1]], [fi[1], fe[1]], [fi[1], fi[1]], [fi[1], ga[1]], [fi[1], ta[1]], [fi[1], oj[1]], [fi[1], cofi[1]], [fi[1], coga[1]], [fi[1], grm[1]], [fi[1], grp[1]]],
791
+ [[ga[1], ho[1]], [ga[1], fe[1]], [ga[1], fi[1]], [ga[1], ga[1]], [ga[1], ta[1]], [ga[1], oj[1]], [ga[1], cofi[1]], [ga[1], coga[1]], [ga[1], grm[1]], [ga[1], grp[1]]],
792
+ [[ta[1], ho[1]], [ta[1], fe[1]], [ta[1], fi[1]], [ta[1], ga[1]], [ta[1], ta[1]], [ta[1], oj[1]], [ta[1], cofi[1]], [ta[1], coga[1]], [ta[1], grm[1]], [ta[1], grp[1]]],
793
+ [[oj[1], ho[1]], [oj[1], fe[1]], [oj[1], fi[1]], [oj[1], ga[1]], [oj[1], ta[1]], [oj[1], oj[1]], [oj[1], cofi[1]], [oj[1], coga[1]], [oj[1], grm[1]], [oj[1], grp[1]]],
794
+ [[cofi[1], ho[1]], [cofi[1], fe[1]], [cofi[1], fi[1]], [cofi[1], ga[1]], [cofi[1], ta[1]], [cofi[1], oj[1]], [cofi[1], cofi[1]], [cofi[1], coga[1]], [cofi[1], grm[1]], [cofi[1], grp[1]]],
795
+ [[coga[1], ho[1]], [coga[1], fe[1]], [coga[1], fi[1]], [coga[1], ga[1]], [coga[1], ta[1]], [coga[1], oj[1]], [coga[1], cofi[1]], [coga[1], coga[1]], [coga[1], grm[1]], [coga[1], grp[1]]],
796
+ [[grm[1], ho[1]], [grm[1], fe[1]], [grm[1], fi[1]], [grm[1], ga[1]], [grm[1], ta[1]], [grm[1], oj[1]], [grm[1], cofi[1]], [grm[1], coga[1]], [grm[1], grm[1]], [grm[1], grp[1]]],
797
+ [[grp[1], ho[1]], [grp[1], fe[1]], [grp[1], fi[1]], [grp[1], ga[1]], [grp[1], ta[1]], [grp[1], oj[1]], [grp[1], cofi[1]], [grp[1], coga[1]], [grp[1], grm[1]], [grp[1], grp[1]]],
798
+ ], [
799
+ [[ct[1], ct[1]], [ct[1], ch[1]], [ct[1], oi[1]], [ct[1], gr[1]], [ct[1], wo[1]], [ct[1], ou[1]], [ct[1], pr[1]], [ct[1], po[1]]],
800
+ [[ch[1], ct[1]], [ch[1], ch[1]], [ch[1], oi[1]], [ch[1], gr[1]], [ch[1], wo[1]], [ch[1], ou[1]], [ch[1], pr[1]], [ch[1], po[1]]],
801
+ [[oi[1], ct[1]], [oi[1], ch[1]], [oi[1], oi[1]], [pi[1], gr[1]], [oi[1], wo[1]], [oi[1], ou[1]], [oi[1], pr[1]], [oi[1], po[1]]],
802
+ [[gr[1], ct[1]], [gr[1], ch[1]], [gr[1], oi[1]], [gr[1], gr[1]], [gr[1], wo[1]], [gr[1], ou[1]], [gr[1], pr[1]], [gr[1], po[1]]],
803
+ ], [
804
+ [[m[1], m[1]], [m[1], c[1]], [m[1], e[1]]],
805
+ [[c[1], m[1]], [c[1], c[1]], [c[1], e[1]]],
806
+ [[e[1], m[1]], [e[1], c[1]], [e[1], e[1]]],
807
+ ], [
808
+ [[oju[1], oju[1]], [oju[1], neo[1]]],
809
+ [[neo[1], oju[1]], [neo[1], neo[1]]],
810
+ ]]
811
+
812
+ nouns = [nouns_sanity, nouns_insanity]
813
+ current_sanity = File.read("_data/npc/dialogue/sanity.txt").to_i # sanity_context.sample
814
+
815
+ context_window = [0, 1, 2, 3]
816
+ cur_con = context_window.sample
817
+
818
+ if cur_con == 0
819
+ row_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
820
+ col_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
821
+ arr_options = [0, 1]
822
+
823
+ #cur_con = context_window.sample
824
+ cur_row = row_options.sample
825
+ cur_col = col_options.sample
826
+ cur_arr = arr_options.sample
827
+
828
+ @chosen_noun = nouns[current_sanity][cur_con][cur_row][cur_col][cur_arr]
829
+ elsif cur_con == 1
830
+ row_options = [0, 1, 2, 3]
831
+ col_options = [0, 1, 2, 3]
832
+ arr_options = [0, 1]
833
+
834
+ #cur_con = context_window.sample
835
+ cur_row = row_options.sample
836
+ cur_col = col_options.sample
837
+ cur_arr = arr_options.sample
838
+
839
+ @chosen_noun = nouns[current_sanity][cur_con][cur_row][cur_col][cur_arr]
840
+ elsif cur_con == 2
841
+ row_options = [0, 1, 2]
842
+ col_options = [0, 1, 2]
843
+ arr_options = [0, 1]
844
+
845
+ # Modifies word genders based on sanity state.
846
+ #cur_san = 0
847
+
848
+ #cur_con = context_window.sample
849
+ cur_row = row_options.sample
850
+ cur_col = col_options.sample
851
+ cur_arr = arr_options.sample
852
+
853
+ @chosen_noun = nouns[current_sanity][cur_con][cur_row][cur_col][cur_arr]
854
+ elsif cur_con == 3
855
+ row_options = [0, 1]
856
+ col_options = [0, 1]
857
+ arr_options = [0, 1]
858
+
859
+ #cur_con = context_window.sample
860
+ cur_row = row_options.sample
861
+ cur_col = col_options.sample
862
+ cur_arr = arr_options.sample
863
+
864
+ @chosen_noun = nouns[current_sanity][cur_con][cur_row][cur_col][cur_arr]
865
+ end
866
+ end
867
+
868
+ def self.adjectives
869
+ ## This covers the adjectives that follows the nouns.
870
+ t = ["tsin", "sintway"]
871
+ p = ["petite", "etitepay"]
872
+ s1 = ["sucré", "ucrepay"]
873
+ r = ["roudy", "oudyray"]
874
+ l = ["l'éducation", "ducationley"]
875
+ s2 = ["sages", "agesay"]
876
+
877
+ adjectives_sanity = [[
878
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
879
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
880
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
881
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
882
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
883
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
884
+ ], [
885
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
886
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
887
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
888
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
889
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
890
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
891
+ ], [
892
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
893
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
894
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
895
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
896
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
897
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
898
+ ], [
899
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
900
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
901
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
902
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
903
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
904
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
905
+ ], [
906
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
907
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
908
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
909
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
910
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
911
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
912
+ ], [
913
+ [[s2[0], t[0]], [s2[0], p[0]], [s2[0], s1[0]], [s2[0], r[0]], [s2[0], l[0]], [s2[0], s2[0]]],
914
+ [[t[0], t[0]], [t[0], p[0]], [t[0], s1[0]], [t[0], r[0]], [t[0], l[0]], [t[0], s2[0]]],
915
+ [[p[0], t[0]], [p[0], p[0]], [p[0], s1[0]], [p[0], r[0]], [p[0], l[0]], [p[0], s2[0]]],
916
+ [[s1[0], t[0]], [s1[0], p[0]], [s1[0], s1[0]], [s1[0], r[0]], [s1[0], l[0]], [s1[0], s2[0]]],
917
+ [[r[0], t[0]], [r[0], p[0]], [r[0], s1[0]], [r[0], r[0]], [r[0], l[0]], [r[0], s2[0]]],
918
+ [[l[0], t[0]], [l[0], p[0]], [l[0], s1[0]], [l[0], r[0]], [l[0], l[0]], [l[0], s2[0]]],
919
+ ]]
920
+
921
+ adjectives_insanity = [[
922
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
923
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
924
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
925
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
926
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
927
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
928
+ ], [
929
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
930
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
931
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
932
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
933
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
934
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
935
+ ], [
936
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
937
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
938
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
939
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
940
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
941
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
942
+ ], [
943
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
944
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
945
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
946
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
947
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
948
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
949
+ ], [
950
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
951
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
952
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
953
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
954
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
955
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
956
+ ], [
957
+ [[s2[1], t[1]], [s2[1], p[1]], [s2[1], s1[1]], [s2[1], r[1]], [s2[1], l[1]], [s2[1], s2[1]]],
958
+ [[t[1], t[1]], [t[1], p[1]], [t[1], s1[1]], [t[1], r[1]], [t[1], l[1]], [t[1], s2[1]]],
959
+ [[p[1], t[1]], [p[1], p[1]], [p[1], s1[1]], [p[1], r[1]], [p[1], l[1]], [p[1], s2[1]]],
960
+ [[s1[1], t[1]], [s1[1], p[1]], [s1[1], s1[1]], [s1[1], r[1]], [s1[1], l[1]], [s1[1], s2[1]]],
961
+ [[r[1], t[1]], [r[1], p[1]], [r[1], s1[1]], [r[1], r[1]], [r[1], l[1]], [r[1], s2[1]]],
962
+ [[l[1], t[1]], [l[1], p[1]], [l[1], s1[1]], [l[1], r[1]], [l[1], l[1]], [l[1], s2[1]]],
963
+ ]]
964
+
965
+ adjectives = [ adjectives_sanity, adjectives_insanity ]
966
+
967
+ context_window = [0, 1, 2, 3, 4, 5]
968
+
969
+ row_options = [0, 1, 2, 3, 4, 5]
970
+ col_options = [0, 1, 2, 3, 4, 5]
971
+ arr_options = [0, 1]
972
+
973
+ # Modifies word genders based on sanity state.
974
+ current_sanity = File.read("_data/npc/dialogue/sanity.txt").to_i # sanity_context.sample
975
+
976
+ cur_con = context_window.sample
977
+ cur_row = row_options.sample
978
+ cur_col = col_options.sample
979
+ cur_arr = arr_options.sample
980
+
981
+ @chosen_adjective = adjectives[current_sanity][cur_con][cur_row][cur_col][cur_arr].strip
982
+ end
983
+
984
+ def self.subjects
985
+ subjects = [
986
+ [["es", "es"], ["es", "es ne"]],
987
+ [["es ne", "es"], ["es ne", "es ne"]],
988
+ ], [
989
+ [["es", "es"], ["es", "es ne"]],
990
+ [["es ne", "es"], ["es ne", "es ne"]],
991
+ ]
992
+
993
+ context_window = [0, 1]
994
+
995
+ row_options = [0, 1]
996
+ col_options = [0, 1]
997
+ arr_options = [0, 1]
998
+
999
+ cur_con = context_window.sample
1000
+ cur_row = row_options.sample
1001
+ cur_col = col_options.sample
1002
+ cur_arr = arr_options.sample
1003
+
1004
+ @chosen_subject = subjects[cur_con][cur_row][cur_col][cur_arr]
1005
+ end
1006
+
1007
+ def self.verbs
1008
+ ## This covers the verbs that come before the adverbs.
1009
+ avo = ["avoir", "voiray"]
1010
+ cou = ["coupe", "oupecay"]
1011
+ ser = ["serrure", "erruresay"]
1012
+ dev = ["deverrouillage", "everrouillageday"]
1013
+
1014
+ verbs_sanity = [[
1015
+ [[avo[0], avo[0]], [avo[0], cou[0]], [avo[0], ser[0]], [avo[0], dev[0]]],
1016
+ [[cou[0], avo[0]], [cou[0], cou[0]], [cou[0], ser[0]], [cou[0], dev[0]]],
1017
+ [[ser[0], avo[0]], [ser[0], cou[0]], [ser[0], ser[0]], [ser[0], dev[0]]],
1018
+ [[dev[0], avo[0]], [dev[0], cou[0]], [dev[0], ser[0]], [dev[0], dev[0]]],
1019
+ ], [
1020
+ [[cou[0], avo[0]], [cou[0], cou[0]], [cou[0], ser[0]], [cou[0], dev[0]]],
1021
+ [[ser[0], avo[0]], [ser[0], cou[0]], [ser[0], ser[0]], [ser[0], dev[0]]],
1022
+ [[dev[0], avo[0]], [dev[0], cou[0]], [dev[0], ser[0]], [dev[0], dev[0]]],
1023
+ [[avo[0], avo[0]], [avo[0], cou[0]], [avo[0], ser[0]], [avo[0], dev[0]]],
1024
+ ], [
1025
+ [[ser[0], avo[0]], [ser[0], cou[0]], [ser[0], ser[0]], [ser[0], dev[0]]],
1026
+ [[dev[0], avo[0]], [dev[0], cou[0]], [dev[0], ser[0]], [dev[0], dev[0]]],
1027
+ [[avo[0], avo[0]], [avo[0], cou[0]], [avo[0], ser[0]], [avo[0], dev[0]]],
1028
+ [[cou[0], avo[0]], [cou[0], cou[0]], [cou[0], ser[0]], [cou[0], dev[0]]],
1029
+ ], [
1030
+ [[dev[0], avo[0]], [dev[0], cou[0]], [dev[0], ser[0]], [dev[0], dev[0]]],
1031
+ [[avo[0], avo[0]], [avo[0], cou[0]], [avo[0], ser[0]], [avo[0], dev[0]]],
1032
+ [[cou[0], avo[0]], [cou[0], cou[0]], [cou[0], ser[0]], [cou[0], dev[0]]],
1033
+ [[ser[0], avo[0]], [ser[0], cou[0]], [ser[0], ser[0]], [ser[0], dev[0]]],
1034
+ ]]
1035
+
1036
+ verbs_insanity = [[
1037
+ [[avo[1], avo[1]], [avo[1], cou[1]], [avo[1], ser[1]], [avo[1], dev[1]]],
1038
+ [[cou[1], avo[1]], [cou[1], cou[1]], [cou[1], ser[1]], [cou[1], dev[1]]],
1039
+ [[ser[1], avo[1]], [ser[1], cou[1]], [ser[1], ser[1]], [ser[1], dev[1]]],
1040
+ [[dev[1], avo[1]], [dev[1], cou[1]], [dev[1], ser[1]], [dev[1], dev[1]]],
1041
+ ], [
1042
+ [[cou[1], avo[1]], [cou[1], cou[1]], [cou[1], ser[1]], [cou[1], dev[1]]],
1043
+ [[ser[1], avo[1]], [ser[1], cou[1]], [ser[1], ser[1]], [ser[1], dev[1]]],
1044
+ [[dev[1], avo[1]], [dev[1], cou[1]], [dev[1], ser[1]], [dev[1], dev[1]]],
1045
+ [[avo[1], avo[1]], [avo[1], cou[1]], [avo[1], ser[1]], [avo[1], dev[1]]],
1046
+ ], [
1047
+ [[ser[1], avo[1]], [ser[1], cou[1]], [ser[1], ser[1]], [ser[1], dev[1]]],
1048
+ [[dev[1], avo[1]], [dev[1], cou[1]], [dev[1], ser[1]], [dev[1], dev[1]]],
1049
+ [[avo[1], avo[1]], [avo[1], cou[1]], [avo[1], ser[1]], [avo[1], dev[1]]],
1050
+ [[cou[1], avo[1]], [cou[1], cou[1]], [cou[1], ser[1]], [cou[1], dev[1]]],
1051
+ ], [
1052
+ [[dev[1], avo[1]], [dev[1], cou[1]], [dev[1], ser[1]], [dev[1], dev[1]]],
1053
+ [[avo[1], avo[1]], [avo[1], cou[1]], [avo[1], ser[1]], [avo[1], dev[1]]],
1054
+ [[cou[1], avo[1]], [cou[1], cou[1]], [cou[1], ser[1]], [cou[1], dev[1]]],
1055
+ [[ser[1], avo[1]], [ser[1], cou[1]], [ser[1], ser[1]], [ser[1], dev[1]]],
1056
+ ]]
1057
+
1058
+ verbs = [ verbs_sanity, verbs_insanity]
1059
+
1060
+ # Modifies word genders based on sanity state.
1061
+ current_sanity = File.read("_data/npc/dialogue/sanity.txt").to_i # sanity_context.sample
1062
+
1063
+ context_window = [0, 1, 2, 3]
1064
+ row_options = [0, 1, 2, 3]
1065
+ col_options = [0, 1, 2, 3]
1066
+ arr_options = [0, 1]
1067
+
1068
+ # Modifies word genders based on sanity state.
1069
+ cur_san = 0
1070
+
1071
+ cur_con = context_window.sample
1072
+ cur_row = row_options.sample
1073
+ cur_col = col_options.sample
1074
+ cur_arr = arr_options.sample
1075
+
1076
+ @chosen_verb = verbs[current_sanity][cur_con][cur_row][cur_col][cur_arr]
1077
+ end
1078
+
1079
+ def self.adverbs
1080
+ r = "rapidement.", "apidementray."
1081
+ l = "lentement.", "tementelay."
1082
+ a = "assurement.", "surementasay."
1083
+ t = "tranquillement.", "quillementtranay."
1084
+
1085
+ adverbs_sanity = [
1086
+ [[r[0], r[0]], [r[0], l[0]], [r[0], a[0]], [r[0], t[0]]],
1087
+ [[l[0], r[0]], [l[0], l[0]], [l[0], a[0]], [l[0], t[0]]],
1088
+ [[a[0], r[0]], [a[0], l[0]], [a[0], a[0]], [a[0], t[0]]],
1089
+ [[t[0], r[0]], [t[0], l[0]], [t[0], a[0]], [t[0], t[0]]],
1090
+ ], [
1091
+ [[l[0], r[0]], [l[0], l[0]], [l[0], a[0]], [l[0], t[0]]],
1092
+ [[a[0], r[0]], [a[0], l[0]], [a[0], a[0]], [a[0], t[0]]],
1093
+ [[t[0], r[0]], [t[0], l[0]], [t[0], a[0]], [t[0], t[0]]],
1094
+ [[r[0], r[0]], [r[0], l[0]], [r[0], a[0]], [r[0], t[0]]],
1095
+ ], [
1096
+ [[a[0], r[0]], [a[0], l[0]], [a[0], a[0]], [a[0], t[0]]],
1097
+ [[t[0], r[0]], [t[0], l[0]], [t[0], a[0]], [t[0], t[0]]],
1098
+ [[r[0], r[0]], [r[0], l[0]], [r[0], a[0]], [r[0], t[0]]],
1099
+ [[l[0], r[0]], [l[0], l[0]], [l[0], a[0]], [l[0], t[0]]],
1100
+ ], [
1101
+ [[t[0], r[0]], [t[0], l[0]], [t[0], a[0]], [t[0], t[0]]],
1102
+ [[r[0], r[0]], [r[0], l[0]], [r[0], a[0]], [r[0], t[0]]],
1103
+ [[l[0], r[0]], [l[0], l[0]], [l[0], a[0]], [l[0], t[0]]],
1104
+ [[a[0], r[0]], [a[0], l[0]], [a[0], a[0]], [a[0], t[0]]],
1105
+ ]
1106
+
1107
+ adverbs_insanity = [
1108
+ [[r[1], r[1]], [r[1], l[1]], [r[1], a[1]], [r[1], t[1]]],
1109
+ [[l[1], r[1]], [l[1], l[1]], [l[1], a[1]], [l[1], t[1]]],
1110
+ [[a[1], r[1]], [a[1], l[1]], [a[1], a[1]], [a[1], t[1]]],
1111
+ [[t[1], r[1]], [t[1], l[1]], [t[1], a[1]], [t[1], t[1]]],
1112
+ ], [
1113
+ [[l[1], r[1]], [l[1], l[1]], [l[1], a[1]], [l[1], t[1]]],
1114
+ [[a[1], r[1]], [a[1], l[1]], [a[1], a[1]], [a[1], t[1]]],
1115
+ [[t[1], r[1]], [t[1], l[1]], [t[1], a[1]], [t[1], t[1]]],
1116
+ [[r[1], r[1]], [r[1], l[1]], [r[1], a[1]], [r[1], t[1]]],
1117
+ ], [
1118
+ [[a[1], r[1]], [a[1], l[1]], [a[1], a[1]], [a[1], t[1]]],
1119
+ [[t[1], r[1]], [t[1], l[1]], [t[1], a[1]], [t[1], t[1]]],
1120
+ [[r[1], r[1]], [r[1], l[1]], [r[1], a[1]], [r[1], t[1]]],
1121
+ [[l[1], r[1]], [l[1], l[1]], [l[1], a[1]], [l[1], t[1]]],
1122
+ ], [
1123
+ [[t[1], r[1]], [t[1], l[1]], [t[1], a[1]], [t[1], t[1]]],
1124
+ [[r[1], r[1]], [r[1], l[1]], [r[1], a[1]], [r[1], t[1]]],
1125
+ [[l[1], r[1]], [l[1], l[1]], [l[1], a[1]], [l[1], t[1]]],
1126
+ [[a[1], r[1]], [a[1], l[1]], [a[1], a[1]], [a[1], t[1]]],
1127
+ ]
1128
+
1129
+ adverbs = [ adverbs_sanity, adverbs_insanity ]
1130
+ current_sanity = File.read("_data/npc/dialogue/sanity.txt").to_i # sanity_context.sample
1131
+
1132
+ context_window = [0, 1, 2, 3]
1133
+ row_options = [0, 1, 2, 3]
1134
+ col_options = [0, 1, 2, 3]
1135
+ arr_options = [0, 1]
1136
+
1137
+ cur_con = context_window.sample
1138
+ cur_row = row_options.sample
1139
+ cur_col = col_options.sample
1140
+ cur_arr = arr_options.sample
1141
+
1142
+ @chosen_adverb = adverbs[current_sanity][cur_con][cur_row][cur_col][cur_arr]
1143
+
1144
+ @current_phrase = "#{@chosen_word_class} #{@chosen_noun} #{@chosen_adjective}#{@chosen_subject} #{@chosen_verb} #{@chosen_adverb}"
1145
+
1146
+ File.open("_data/npc/dialogue/one_liners/lines.txt", "a") { |f|
1147
+ f.puts @current_phrase
1148
+ }
1149
+ end
1150
+ end
1151
+ end
1152
+
1153
+ module DollDetector
1154
+ class Error < StandardError; end
1155
+
1156
+ class DetectAnomalies
1157
+ require "SelfModifiedDecisionTree"
1158
+
1159
+ doll_types = RevisedBayes.new(:normal_doll, :assisted_doll, :anomalous_doll),
1160
+ RevisedBayes.new(:is_not_connected_or_hovering, :is_not_resting_or_hovering, :is_not_resting_or_connected)
1161
+
1162
+ ###################################################################################################################################
1163
+ # What Type Of Doll #
1164
+ ###################################################################################################################################
1165
+ ## Normal Doll Situations
1166
+ doll_types[0].train(:normal_doll, "This doll is resting on a bookshelf.", "normal doll")
1167
+ doll_types[0].train(:normal_doll, "This doll is resting on the bed.", "normal doll")
1168
+
1169
+ ## Assisted Doll Situations
1170
+ doll_types[0].train(:assisted_doll, "This doll is attached to a computer monitor.", "assisted doll")
1171
+ doll_types[0].train(:assisted_doll, "This doll os resting on a bookshelf connected to a computer monitor.", "assisted doll")
1172
+
1173
+ ## Anomalous Doll Situations
1174
+ doll_types[0].train(:anomalous_doll, "This doll contorts her body and hovers in the air.", "anomalous doll")
1175
+ doll_types[0].train(:anomalous_doll, "This doll contorts her body and hovers in the air in front of a security camera.", "anomalous doll")
1176
+
1177
+ classification1 = doll_types[0].classify("This doll os resting on a bookshelf connected to a computer monitor.")
1178
+ ###################################################################################################################################
1179
+ # Give Evidence #
1180
+ ###################################################################################################################################
1181
+ ## Normal Doll
1182
+ doll_types[1].train(:is_not_connected_or_hovering, "She is not connected to a computer monitoring or distorting her body in weird ways.", "normal doll")
1183
+ doll_types[1].train(:is_not_connected_or_hovering, "This doll is resting by the computer monitor she is connected to, while hovering in the air.", "normal doll")
1184
+
1185
+ ## Assisted Doll
1186
+ doll_types[1].train(:is_not_resting_or_hovering, "She is not resting on the bookshelf or hovering around in the air.", "assisted doll")
1187
+ doll_types[1].train(:is_not_resting_or_hovering, "This doll is resting on a bookshalf after unplugging from the monitor of a computer.", "assisted doll")
1188
+
1189
+ ## Anomalous Doll
1190
+ doll_types[1].train(:is_not_resting_or_connected, "This doll is twisting and distorting while hovering in the air.", "anomalous doll")
1191
+ doll_types[1].train(:is_not_resting_or_connected, "This doll is finished rested, but does not connect to the computer monitor.", "assisted doll")
1192
+
1193
+ classification2 = doll_types[1].classify("This doll is twisting and distorting while hovering in the air.")
1194
+
1195
+ print classification1
1196
+ puts " "
1197
+
1198
+ print classification2
1199
+ puts " "
1200
+
1201
+ overall_probability = classification1[1] * classification2[1]
1202
+
1203
+ attributes = ["Type"], ["Decade"], ["Classification"]
1204
+
1205
+ training = [
1206
+ [0.125000, "Normal"],
1207
+ [0.562450, "Technologically Assisted"],
1208
+ [0.999900, "Anomalous"],
1209
+ ], [
1210
+ [0.125000, "1837-1901"],
1211
+ [0.562450, "1950-2025"],
1212
+ [0.781175, "2026-2035"],
1213
+ [0.999900, "2036-2050"],
1214
+ ], [
1215
+ [0.125000, "PH7DR1"],
1216
+ [0.562450, "PH6DR1"],
1217
+ [0.781175, "PH4DR1"],
1218
+ [0.999900, "PH3DR3"],
1219
+ ]
1220
+
1221
+ dec_tree_configurations = DecisionTree::ID3Tree.new(attributes[0], training[0], 1, :continuous),
1222
+ DecisionTree::ID3Tree.new(attributes[1], training[1], 1, :continuous),
1223
+ DecisionTree::ID3Tree.new(attributes[2], training[2], 1, :continuous)
1224
+
1225
+ current_dectree1 = dec_tree_configurations[0]
1226
+ current_dectree1.train
1227
+
1228
+ current_dectree2 = dec_tree_configurations[1]
1229
+ current_dectree2.train
1230
+
1231
+ current_dectree3 = dec_tree_configurations[2]
1232
+ current_dectree3.train
1233
+
1234
+ test1 = [overall_probability, "Technologically Assisted"]
1235
+ test2 = [overall_probability, "2026-2035"]
1236
+ test3 = [overall_probability, "PH3DR3"]
1237
+
1238
+ ## Sesne I got rid of decision trees data marshalling, I have to reassign last tests.
1239
+ last_first_decision = test1[1]
1240
+ last_second_decision = test2[1]
1241
+ last_third_decision = test3[1]
1242
+
1243
+ @decision1 = current_dectree1.predict(test1) # This being Alberts contribution
1244
+ @decision2 = current_dectree2.predict(test2) # This being Andys contribution
1245
+ @decision3 = current_dectree3.predict(test3) # This being Bethanys contribution
1246
+
1247
+ puts "Chosen Type: #{@decision1} Decade: #{@decision2} Classification: #{@decision3}"
1248
+ puts "Expected Type: #{last_first_decision} Decade: #{last_second_decision} Classification: #{last_third_decision}"
1249
+ end
1250
+ end
1251
+
1252
+ module SpatialRelationships
1253
+ class Error < StandardError; end
1254
+
1255
+ class Static_Perimeters
1256
+
1257
+ # The objects within the space.
1258
+ def self.positive_perimeters
1259
+ # Base radius of static objects.
1260
+ base_radius = 2500
1261
+
1262
+ # Specfic multipliers for Earth index based objects.
1263
+ base_two = 2
1264
+ base_fro = 4
1265
+ base_six = 6
1266
+ base_eit = 8
1267
+
1268
+ # Size of specific objects.
1269
+ size_of_planets = base_radius ** base_fro
1270
+ size_of_moons = base_radius ** base_two
1271
+ size_of_stars = base_radius ** base_six
1272
+ size_of_blackholes = base_radius ** base_eit
1273
+
1274
+ # Total output sizes of specific objects.
1275
+ puts "The size of the planets is #{size_of_planets} radius."; sleep(3)
1276
+ puts "The size of the moons is #{size_of_moons} radius."; sleep(3)
1277
+ puts "The size of the stars is #{size_of_stars} radius."; sleep(3)
1278
+ puts "The size of a blackhole is #{size_of_blackholes} radius."; sleep(3)
1279
+ end
1280
+
1281
+ # Space between the objects.
1282
+ def self.negative_perimeters
1283
+ # Base distance between objects.
1284
+ base_distance = 1_000_000_000
1285
+
1286
+ # Estimated divider between specific objects to base distance.
1287
+ space_between_planets = 43.8
1288
+ space_between_moons = 14.6
1289
+ space_between_stars = 876
1290
+ space_between_blackholes = 2628
1291
+
1292
+ # Minimum distance between objects.
1293
+ planet_distance = base_distance / space_between_planets
1294
+ moon_distance = base_distance / space_between_moons
1295
+ star_distance = base_distance / space_between_stars
1296
+ blackhole_distance = base_distance / space_between_blackholes
1297
+
1298
+ # Actual distance between objects
1299
+ actual_planets = planet_distance * 10
1300
+ actual_moons = moon_distance * 10
1301
+ actual_stars = star_distance * 10
1302
+ actual_blackholes = blackhole_distance * 10
1303
+
1304
+ # The output results of distance between objects.
1305
+ puts "The distance between planets is #{actual_planets} miles."; sleep(3)
1306
+ puts "The distance between moons is #{actual_moons} miles."; sleep(3)
1307
+ puts "The distance between stars is #{actual_stars} miles."; sleep(3)
1308
+ puts "The distance between blackholes is #{actual_blackholes} miles."; sleep(3)
1309
+ end
1310
+
1311
+ end
1312
+
1313
+ # Changing perimeters
1314
+ class Dynamic_Perimeters
1315
+
1316
+ # The objects within the space.
1317
+ def self.positive_perimeters
1318
+ spaceship = File.read("_data/dynamic/positive_perimeters/spaceship_size.txt").strip.to_i
1319
+ space_station = spaceship * 200
1320
+ satalite = space_station / 10
1321
+
1322
+ puts "The total size of the space shuttle is #{spaceship} feet."; sleep(3)
1323
+ puts "The total size of the space station is #{space_station} feet."; sleep(3)
1324
+ puts "The total size of the satalite is #{satalite} feet."; sleep(3)
1325
+
1326
+ File.open("_input/relationships.txt", "a") { |f|
1327
+ f.puts "The total size of the space shuttle is #{spaceship} feet."
1328
+ f.puts "The total size of the space station is #{space_station} feet."
1329
+ f.puts "The total size of the satalite is #{satalite} feet."
1330
+ }
1331
+ end
1332
+
1333
+ # Space between the objects.
1334
+ def self.negative_perimeters
1335
+ base_multiplier = 10
1336
+
1337
+ # Minimum space between objects.
1338
+ space_between_spaceships = File.read("_data/dynamic/negative_perimeters/space_between_spaceships.txt").strip.to_i
1339
+ space_between_station = File.read("_data/dynamic/negative_perimeters/space_between_station.txt").strip.to_i
1340
+ space_between_satalite = File.read("_data/dynamic/negative_perimeters/space_between_satalite.txt").strip.to_i
1341
+
1342
+ # Actual space between objects
1343
+ actual_spaceship_distance = space_between_spaceships * base_multiplier
1344
+ actual_station_distance = space_between_station * base_multiplier
1345
+ actual_satalite_distance = space_between_satalite * base_multiplier
1346
+
1347
+ puts "The minimum space between shuttles is #{actual_spaceship_distance} feet."; sleep(3)
1348
+ puts "The minimum space between stations is #{actual_station_distance} feet."; sleep(3)
1349
+ puts "The minimum space between satalites is #{actual_satalite_distance} feet."; sleep(3)
1350
+
1351
+ File.open("_input/relationships.txt", "a") { |f|
1352
+ f.puts "The minimum space between shuttles is #{actual_spaceship_distance} feet."
1353
+ f.puts "The minimum space between stations is #{actual_station_distance} feet."
1354
+ f.puts "The minimum space between satalites is #{actual_satalite_distance} feet."
1355
+ }
1356
+ end
1357
+
1358
+ end
1359
+
1360
+ ###################################################################################################
1361
+ # Reworked Decision Tree #
1362
+ ###################################################################################################
1363
+ # Self-Adapting Naive Bayes has been reworked based on vulnerabilities found in version of Ruby #
1364
+ # prior to Ruby 2.1.0, though I may end up moving this gem up to version 3.2.3 so that it's in #
1365
+ # line with the current Ruby version. #
1366
+ ###################################################################################################
1367
+ class SpatialEvaluator
1368
+ def self.analyze_objects
1369
+ total_items = File.readlines("_input/relationships.txt")
1370
+ item_size = total_items.size #.to_f
1371
+ index = 0
1372
+
1373
+ item_size.times do
1374
+ probability_shift = total_items.size.to_f
1375
+
1376
+ @probability_no = 1 / probability_shift
1377
+ @probability_yes = 1 - @probability_no
1378
+
1379
+ attributes = "Positive Space", "Negative Space", "Type Of Object"
1380
+
1381
+ possible_datasets = [
1382
+ :no_object,
1383
+ :tiny_object,
1384
+ :mild_object,
1385
+ :large_object,
1386
+ :vast_object,
1387
+ ], [
1388
+ :no_space,
1389
+ :tiny_space,
1390
+ :mile_space,
1391
+ :large_space,
1392
+ :vast_distance,
1393
+ ], [
1394
+ :floating,
1395
+ :flying,
1396
+ :glimmering,
1397
+ :trailing,
1398
+ ]
1399
+
1400
+ object_sizes = possible_datasets[0]
1401
+ distance_between_objects = possible_datasets[1]
1402
+ object_behaviours = possible_datasets[2]
1403
+
1404
+ dec_tree_configurations = [attributes[0], object_sizes[index]],
1405
+ [attributes[1], distance_between_objects[index]],
1406
+ [attributes[2], object_behaviours[index]]
1407
+
1408
+ current_configuration = dec_tree_configurations[index]
1409
+
1410
+ if current_configuration == dec_tree_configurations[0]
1411
+ case @probability_yes
1412
+ when 0.12500..0.34375; puts "[#{object_sizes[0]}, #{@probability_yes}]" # names[0]
1413
+ when 0.34376..0.56250; puts "[#{object_sizes[1]}, #{@probability_yes}]" # names[1]
1414
+ when 0.56251..0.78125; puts "[#{object_sizes[2]}, #{@probability_yes}]" # names[2]
1415
+ when 0.78126..0.89063; puts "[#{object_sizes[3]}, #{@probability_yes}]" # names[3]
1416
+ when 0.89064..1.00000; puts "[#{object_sizes[4]}, #{@probability_yes}]" # names[4]
1417
+ else
1418
+ puts "[#{names[2]}, #{@probability_yes}]"
1419
+ end
1420
+
1421
+ case @probability_no
1422
+ when 0.12500..0.34375; puts "[#{object_sizes[0]}, #{@probability_no}]" # names[0]
1423
+ when 0.34376..0.56250; puts "[#{object_sizes[1]}, #{@probability_no}]" # names[1]
1424
+ when 0.56251..0.78125; puts "[#{object_sizes[2]}, #{@probability_no}]" # names[2]
1425
+ when 0.78126..0.89063; puts "[#{object_sizes[3]}, #{@probability_no}]" # names[3]
1426
+ when 0.89064..1.00000; puts "[#{object_sizes[4]}, #{@probability_no}]" # names[4]
1427
+ else
1428
+ puts "[#{names[2]}, #{@probability_no}]"
1429
+ end
1430
+ elsif current_configuration == dec_tree_configurations[1]
1431
+ case @probability_yes
1432
+ when 0.12500..0.34375; puts "[#{distance_between_objects[0]}, #{@probability_yes}]" # classifications[0]
1433
+ when 0.34376..0.56250; puts "[#{distance_between_objects[1]}, #{@probability_yes}]" # classifications[1]
1434
+ when 0.56251..0.78125; puts "[#{distance_between_objects[2]}, #{@probability_yes}]" # classifications[2]
1435
+ when 0.78126..0.89063; puts "[#{distance_between_objects[3]}, #{@probability_yes}]" # classifications[3]
1436
+ when 0.89064..1.00000; puts "[#{distance_between_objects[4]}, #{@probability_yes}]" # classifications[4]
1437
+ else
1438
+ puts "[#{classifications[2]}, #{@probability_yes}]"
1439
+ end
1440
+
1441
+ case @probability_no
1442
+ when 0.12500..0.34375; puts "[#{distance_between_objects[0]}, #{@probability_no}]" # classifications[0]
1443
+ when 0.34376..0.56250; puts "[#{distance_between_objects[1]}, #{@probability_no}]" # classifications[1]
1444
+ when 0.56251..0.78125; puts "[#{distance_between_objects[2]}, #{@probability_no}]" # classifications[2]
1445
+ when 0.78126..0.89063; puts "[#{distance_between_objects[3]}, #{@probability_no}]" # classifications[3]
1446
+ when 0.89064..1.00000; puts "[#{distance_between_objects[4]}, #{@probability_no}]" # classifications[4]
1447
+ else
1448
+ puts "[#{classifications[2]}, #{@probability_no}]"
1449
+ end
1450
+ elsif current_configuration == dec_tree_configurations[2]
1451
+ case @probability_yes
1452
+ when 0.12500..0.34375; puts "[#{object_behaviours[0]}, #{@probability_yes}]" # status[0]
1453
+ when 0.34376..0.56250; puts "[#{object_behaviours[1]}, #{@probability_yes}]" # status[1]
1454
+ when 0.56251..0.78125; puts "[#{object_behaviours[2]}, #{@probability_yes}]" # status[2]
1455
+ when 0.78126..0.89063; puts "[#{object_behaviours[3]}, #{@probability_yes}]" # status[3]
1456
+ when 0.89064..1.00000; puts "[#{object_behaviours[4]}, #{@probability_yes}]" # status[4]
1457
+ else
1458
+ puts "[#{status[2]}, #{@probability_yes}]"
1459
+ end
1460
+
1461
+ case @probability_no
1462
+ when 0.12500..0.34375; puts "[#{object_behaviours[0]}, #{@probability_no}]" # status[0]
1463
+ when 0.34376..0.56250; puts "[#{object_behaviours[1]}, #{@probability_no}]" # status[1]
1464
+ when 0.56251..0.78125; puts "[#{object_behaviours[2]}, #{@probability_no}]" # status[2]
1465
+ when 0.78126..0.89063; puts "[#{object_behaviours[3]}, #{@probability_no}]" # status[3]
1466
+ when 0.89064..1.00000; puts "[#{object_behaviours[4]}, #{@probability_no}]" # status[4]
1467
+ else
1468
+ puts "[#{status[2]}, #{@probability_no}]"
1469
+ end
1470
+ else
1471
+ puts "There is no configuration for this datapoint."
1472
+ end
1473
+
1474
+ index = index + 1
1475
+ end
1476
+ end
1477
+ end
1478
+ end
1479
+
1480
+ module Brain
1481
+ class Error < StandardError; end
1482
+
1483
+ class MemoryMachine
1484
+ def self.memories
1485
+ # mem1 mem2 mem3
1486
+ # mem1 m1,m1 m1,m2 m1,m3
1487
+ # mem2 m2,m1 m2,m2 m2,m3
1488
+ # mem3 m3,m1 m3,m2 m3,m3
1489
+
1490
+ memories = File.read("_memories/learned_behaviours/moments.txt")
1491
+
1492
+ total_size = memories.size.to_i
1493
+ size_limit = memories.size.to_i
1494
+
1495
+ if total_size == 3
1496
+ memory_index = [
1497
+ [["#{memories[0]}", "#{memories[0]}"], ["#{memories[0]}", "#{memories[1]}"], ["#{memories[0]}", "#{memories[2]}"]],
1498
+ [["#{memories[1]}", "#{memories[0]}"], ["#{memories[1]}", "#{memories[1]}"], ["#{memories[1]}", "#{memories[2]}"]],
1499
+ [["#{memories[2]}", "#{memories[0]}"], ["#{memories[2]}", "#{memories[1]}"], ["#{memories[2]}", "#{memories[2]}"]],
1500
+ ]
1501
+
1502
+ row_options = [0, 1, 2]
1503
+ col_options = [0, 1, 2]
1504
+ arr_options = [0, 1]
1505
+
1506
+ cur_row = row_options.sample
1507
+ cur_col = col_options.sample
1508
+ cur_arr = arr_options.sample
1509
+
1510
+ current_memory = memory_index[cur_row][cur_col][cur_arr]
1511
+
1512
+ puts "Current Memories"
1513
+ puts "#{current_memory}"
1514
+
1515
+ # What records into long term memories.
1516
+ if current_memory == memories[0]
1517
+ elsif current_memory == memories[1]
1518
+ elsif current_memory == memories[2]
1519
+ else
1520
+ puts "Not recorded for longterm memory."
1521
+ end
1522
+ elsif total_size == 5
1523
+ memory_index = [
1524
+ [["#{memories[0]}", "#{memories[0]}"], ["#{memories[0]}", "#{memories[1]}"], ["#{memories[0]}", "#{memories[2]}"], ["#{memories[0]}", "#{memories[3]}"], ["#{memories[0]}", "#{memories[4]}"]],
1525
+ [["#{memories[1]}", "#{memories[0]}"], ["#{memories[1]}", "#{memories[1]}"], ["#{memories[1]}", "#{memories[2]}"], ["#{memories[1]}", "#{memories[3]}"], ["#{memories[1]}", "#{memories[4]}"]],
1526
+ [["#{memories[2]}", "#{memories[0]}"], ["#{memories[2]}", "#{memories[1]}"], ["#{memories[2]}", "#{memories[2]}"], ["#{memories[2]}", "#{memories[3]}"], ["#{memories[2]}", "#{memories[4]}"]],
1527
+ [["#{memories[3]}", "#{memories[0]}"], ["#{memories[3]}", "#{memories[1]}"], ["#{memories[3]}", "#{memories[2]}"], ["#{memories[3]}", "#{memories[3]}"], ["#{memories[3]}", "#{memories[4]}"]],
1528
+ [["#{memories[4]}", "#{memories[0]}"], ["#{memories[4]}", "#{memories[1]}"], ["#{memories[4]}", "#{memories[2]}"], ["#{memories[4]}", "#{memories[3]}"], ["#{memories[4]}", "#{memories[4]}"]],
1529
+ ]
1530
+
1531
+ row_options = [0, 1, 2, 3, 4]
1532
+ col_options = [0, 1, 2, 3, 4]
1533
+ arr_options = [0, 1]
1534
+
1535
+ cur_row = row_options.sample
1536
+ cur_col = col_options.sample
1537
+ cur_arr = arr_options.sample
1538
+
1539
+ current_memory = memory_index[cur_row][cur_col][cur_arr]
1540
+
1541
+ puts "Current Memories"
1542
+ puts "#{current_memory}"
1543
+
1544
+ # What records into long term memories.
1545
+ if current_memory == memories[0]
1546
+ elsif current_memory == memories[1]
1547
+ elsif current_memory == memories[2]
1548
+ elsif current_memory == memories[3]
1549
+ elsif current_memory == memories[4]
1550
+ else
1551
+ puts "Not recorded for longterm memory."
1552
+ end
1553
+ elsif total_size == 7
1554
+ memory_index = [
1555
+ [["#{memories[0]}", "#{memories[0]}"], ["#{memories[0]}", "#{memories[1]}"], ["#{memories[0]}", "#{memories[2]}"], ["#{memories[0]}", "#{memories[3]}"], ["#{memories[0]}", "#{memories[4]}"], ["#{memories[0]}", "#{memories[5]}"], ["#{memories[0]}", "#{memories[6]}"]],
1556
+ [["#{memories[1]}", "#{memories[0]}"], ["#{memories[1]}", "#{memories[1]}"], ["#{memories[1]}", "#{memories[2]}"], ["#{memories[1]}", "#{memories[3]}"], ["#{memories[1]}", "#{memories[4]}"], ["#{memories[1]}", "#{memories[5]}"], ["#{memories[0]}", "#{memories[6]}"]],
1557
+ [["#{memories[2]}", "#{memories[0]}"], ["#{memories[2]}", "#{memories[1]}"], ["#{memories[2]}", "#{memories[2]}"], ["#{memories[2]}", "#{memories[3]}"], ["#{memories[2]}", "#{memories[4]}"], ["#{memories[2]}", "#{memories[5]}"], ["#{memories[2]}", "#{memories[6]}"]],
1558
+ [["#{memories[3]}", "#{memories[0]}"], ["#{memories[3]}", "#{memories[1]}"], ["#{memories[3]}", "#{memories[2]}"], ["#{memories[3]}", "#{memories[3]}"], ["#{memories[3]}", "#{memories[4]}"], ["#{memories[3]}", "#{memories[5]}"], ["#{memories[3]}", "#{memories[6]}"]],
1559
+ [["#{memories[4]}", "#{memories[0]}"], ["#{memories[4]}", "#{memories[1]}"], ["#{memories[4]}", "#{memories[2]}"], ["#{memories[4]}", "#{memories[3]}"], ["#{memories[4]}", "#{memories[4]}"], ["#{memories[4]}", "#{memories[5]}"], ["#{memories[4]}", "#{memories[6]}"]],
1560
+ [["#{memories[5]}", "#{memories[0]}"], ["#{memories[5]}", "#{memories[1]}"], ["#{memories[5]}", "#{memories[2]}"], ["#{memories[5]}", "#{memories[3]}"], ["#{memories[5]}", "#{memories[4]}"], ["#{memories[5]}", "#{memories[5]}"], ["#{memories[5]}", "#{memories[6]}"]],
1561
+ [["#{memories[6]}", "#{memories[0]}"], ["#{memories[6]}", "#{memories[1]}"], ["#{memories[6]}", "#{memories[2]}"], ["#{memories[6]}", "#{memories[3]}"], ["#{memories[6]}", "#{memories[4]}"], ["#{memories[6]}", "#{memories[5]}"], ["#{memories[6]}", "#{memories[6]}"]],
1562
+ ]
1563
+
1564
+ row_options = [0, 1, 2, 3, 4, 5, 6]
1565
+ col_options = [0, 1, 2, 3, 4, 5, 6]
1566
+ arr_options = [0, 1]
1567
+
1568
+ cur_row = row_options.sample
1569
+ cur_col = col_options.sample
1570
+ cur_arr = arr_options.sample
1571
+
1572
+ current_memory = memory_index[cur_row][cur_col][cur_arr]
1573
+
1574
+ puts "Current Memories"
1575
+ puts "#{current_memory}"
1576
+
1577
+ # What records into long term memories.
1578
+ if current_memory == memories[0]
1579
+ elsif current_memory == memories[1]
1580
+ elsif current_memory == memories[2]
1581
+ elsif current_memory == memories[3]
1582
+ elsif current_memory == memories[4]
1583
+ elsif current_memory == memories[5]
1584
+ elsif current_memory == memories[6]
1585
+ else
1586
+ puts "Not recorded for longterm memory."
1587
+ end
1588
+ else
1589
+ puts "To many memories to possibly map..."
1590
+ end
1591
+ end
1592
+
1593
+ end
1594
+ end
1595
+
1596
+ module ProbabilityMatrix
1597
+ class Error < StandardError; end
1598
+
1599
+ class GetMatrix
1600
+ def self.low_logic_rule
1601
+ File.open("_prolog/variables/low_value.txt", "w") { |f|
1602
+ f.puts "probability(confidence, low)."
1603
+ }
1604
+ end
1605
+
1606
+ def self.mild_logic_rule
1607
+ File.open("_prolog/variables/mild_value.txt", "w") { |f|
1608
+ f.puts "probability(confidence, mild)."
1609
+ }
1610
+ end
1611
+
1612
+ def self.medium_logic_rule
1613
+ File.open("_prolog/variables/medium_value.txt", "w") { |f|
1614
+ f.puts "probability(confidence, medium)."
1615
+ }
1616
+ end
1617
+
1618
+ def self.high_logic_rule
1619
+ File.open("_prolog/variables/high_value.txt", "w") { |f|
1620
+ f.puts "probability(confidence, high)."
1621
+ }
1622
+ end
1623
+
1624
+ def self.max_logic_rule
1625
+ File.open("_prolog/variables/max_value.txt", "w") { |f|
1626
+ f.puts "probability(confidence, max)."
1627
+ }
1628
+ end
1629
+
1630
+ def self.measure_probability
1631
+ a = 0.1250, 0.9990, 0.7805, 0.5620, 0.3435
1632
+ b = 0.3435, 0.1250, 0.9999, 0.7805, 0.5620
1633
+ c = 0.5620, 0.3435, 0.1250, 0.9990, 0.7805
1634
+ d = 0.7805, 0.5620, 0.3435, 0.1250, 0.9990
1635
+ e = 0.9990, 0.7805, 0.5620, 0.3435, 0.1250
1636
+
1637
+ input_charts = [
1638
+ [[a[0], a[0]], [a[0], b[0]], [a[0], c[0]], [a[0], d[0]], [a[0], e[0]]],
1639
+ [[b[0], a[0]], [b[0], b[0]], [b[0], c[0]], [b[0], d[0]], [b[0], e[0]]],
1640
+ [[c[0], a[0]], [c[0], b[0]], [c[0], c[0]], [c[0], d[0]], [c[0], e[0]]],
1641
+ [[d[0], a[0]], [d[0], b[0]], [d[0], c[0]], [d[0], d[0]], [d[0], e[0]]],
1642
+ [[e[0], a[0]], [e[0], b[0]], [e[0], c[0]], [e[0], d[0]], [e[0], e[0]]],
1643
+ ], [
1644
+ [[a[1], a[1]], [a[1], b[1]], [a[1], c[1]], [a[1], d[1]], [a[1], e[1]]],
1645
+ [[b[1], a[1]], [b[1], b[1]], [b[1], c[1]], [b[1], d[1]], [b[1], e[1]]],
1646
+ [[c[1], a[1]], [c[1], b[1]], [c[1], c[1]], [c[1], d[1]], [c[1], e[1]]],
1647
+ [[d[1], a[1]], [d[1], b[1]], [d[1], c[1]], [d[1], d[1]], [d[1], e[1]]],
1648
+ [[e[1], a[1]], [e[1], b[1]], [e[1], c[1]], [e[1], d[1]], [e[1], e[1]]],
1649
+ ], [
1650
+ [[a[2], a[2]], [a[2], b[2]], [a[2], c[2]], [a[2], d[2]], [a[2], e[2]]],
1651
+ [[b[2], a[2]], [b[2], b[2]], [b[2], c[2]], [b[2], d[2]], [b[2], e[2]]],
1652
+ [[c[2], a[2]], [c[2], b[2]], [c[2], c[2]], [c[2], d[2]], [c[2], e[2]]],
1653
+ [[d[2], a[2]], [d[2], b[2]], [d[2], c[2]], [d[2], d[2]], [d[2], e[2]]],
1654
+ [[e[2], a[2]], [e[2], b[2]], [e[2], c[2]], [e[2], d[2]], [e[2], e[2]]],
1655
+ ], [
1656
+ [[a[3], a[3]], [a[3], b[3]], [a[3], c[3]], [a[3], d[3]], [a[3], e[3]]],
1657
+ [[b[3], a[3]], [b[3], b[3]], [b[3], c[3]], [b[3], d[3]], [b[3], e[3]]],
1658
+ [[c[3], a[3]], [c[3], b[3]], [c[3], c[3]], [c[3], d[3]], [c[3], e[3]]],
1659
+ [[d[3], a[3]], [d[3], b[3]], [d[3], c[3]], [d[3], d[3]], [d[3], e[3]]],
1660
+ [[e[3], a[3]], [e[3], b[3]], [e[3], c[3]], [e[3], d[3]], [e[3], e[3]]],
1661
+ ]
1662
+
1663
+ chart_one = input_charts[0]
1664
+ chart_two = input_charts[1]
1665
+ chart_tre = input_charts[2]
1666
+ chart_fro = input_charts[3]
1667
+
1668
+ row_options = [0, 1, 2, 3, 4]
1669
+ col_options = [0, 1, 2, 3, 4]
1670
+ arr_options = [0, 1]
1671
+
1672
+ cur_row = row_options.sample
1673
+ cur_col = col_options.sample
1674
+ cur_arr = arr_options.sample
1675
+
1676
+ print "Extracting Probabilities:
1677
+
1678
+ #{chart_one[cur_row][cur_col][cur_arr]} #{chart_two[cur_row][cur_col][cur_arr]}
1679
+ #{chart_tre[cur_row][cur_col][cur_arr]} #{chart_fro[cur_row][cur_col][cur_arr]}"
1680
+
1681
+ first_value = chart_one[cur_row][cur_col][cur_arr]
1682
+ second_value = chart_two[cur_row][cur_col][cur_arr]
1683
+ third_value = chart_tre[cur_row][cur_col][cur_arr]
1684
+ fourth_value = chart_fro[cur_row][cur_col][cur_arr]
1685
+
1686
+ case first_value
1687
+ when 0.1250..0.3435; ProbabilityMatrix::GetMatrix.low_logic_rule
1688
+ when 0.3435..0.5619; ProbabilityMatrix::GetMatrix.mild_logic_rule
1689
+ when 0.5620..0.7804; ProbabilityMatrix::GetMatrix.medium_logic_rule
1690
+ when 0.7808..0.9999; ProbabilityMatrix::GetMatrix.high_logic_rule
1691
+ else
1692
+ ProbabilityMatrix::GetMatrix.max_logic_rule
1693
+ end
1694
+
1695
+ case second_value
1696
+ when 0.1250..0.3435; ProbabilityMatrix::GetMatrix.low_logic_rule
1697
+ when 0.3435..0.5619; ProbabilityMatrix::GetMatrix.mild_logic_rule
1698
+ when 0.5620..0.7804; ProbabilityMatrix::GetMatrix.medium_logic_rule
1699
+ when 0.7808..0.9999; ProbabilityMatrix::GetMatrix.high_logic_rule
1700
+ else
1701
+ ProbabilityMatrix::GetMatrix.max_logic_rule
1702
+ end
1703
+
1704
+ case third_value
1705
+ when 0.1250..0.3435; ProbabilityMatrix::GetMatrix.low_logic_rule
1706
+ when 0.3435..0.5619; ProbabilityMatrix::GetMatrix.mild_logic_rule
1707
+ when 0.5620..0.7804; ProbabilityMatrix::GetMatrix.medium_logic_rule
1708
+ when 0.7808..0.9999; ProbabilityMatrix::GetMatrix.high_logic_rule
1709
+ else
1710
+ ProbabilityMatrix::GetMatrix.max_logic_rule
1711
+ end
1712
+
1713
+ case fourth_value
1714
+ when 0.1250..0.3435; ProbabilityMatrix::GetMatrix.low_logic_rule
1715
+ when 0.3435..0.5619; ProbabilityMatrix::GetMatrix.mild_logic_rule
1716
+ when 0.5620..0.7804; ProbabilityMatrix::GetMatrix.medium_logic_rule
1717
+ when 0.7808..0.9999; ProbabilityMatrix::GetMatrix.high_logic_rule
1718
+ else
1719
+ ProbabilityMatrix::GetMatrix.max_logic_rule
1720
+ end
1721
+ end
1722
+ end
1723
+ end
1724
+
1725
+ module BequestGribatomatonAdvanced
1726
+ class Error < StandardError; end
1727
+ # Your code goes here...
1728
+
1729
+ class Behaviours
1730
+ def self.actions
1731
+ behaviours = [
1732
+ [[true, true], [true, false]],
1733
+ [[false, true], [false, false]],
1734
+ ], [
1735
+ [[true, true], [true, false]],
1736
+ [[false, true], [false, false]],
1737
+ ], [
1738
+ [[true, true], [true, false]],
1739
+ [[false, true], [false, false]],
1740
+ ]
1741
+
1742
+ spot_enemy = behaviours[0]
1743
+ make_noises = behaviours[1]
1744
+ shine_spotlight = behaviours[2]
1745
+
1746
+ ## Spotting Enemy
1747
+ row_options_s1 = [0, 1]
1748
+ col_options_s1 = [0, 1]
1749
+ arr_options_s1 = [0, 1]
1750
+
1751
+ cur_row_s1 = row_options_s1.sample
1752
+ cur_col_s1 = col_options_s1.sample
1753
+ cur_arr_s1 = arr_options_s1.sample
1754
+
1755
+ ## Noises Making
1756
+ row_options_m = [0, 1]
1757
+ col_options_m = [0, 1]
1758
+ arr_options_m = [0, 1]
1759
+
1760
+ cur_row_m = row_options_m.sample
1761
+ cur_col_m = col_options_m.sample
1762
+ cur_arr_m = arr_options_m.sample
1763
+
1764
+ ## Shining Spotlight
1765
+ row_options_s2 = [0, 1]
1766
+ col_options_s2 = [0, 1]
1767
+ arr_options_s2 = [0, 1]
1768
+
1769
+ cur_row_s2 = row_options_s2.sample
1770
+ cur_col_s2 = col_options_s2.sample
1771
+ cur_arr_s2 = arr_options_s2.sample
1772
+
1773
+ ### Actual Behaviours
1774
+ spider_spot = spot_enemy[cur_row_s1][cur_col_s1][cur_arr_s1]
1775
+ spider_chirbu = spot_enemy[cur_row_m][cur_col_m][cur_arr_m]
1776
+ spider_shine = spot_enemy[cur_row_s2][cur_col_s2][cur_arr_s2]
1777
+
1778
+ if spider_spot == true
1779
+ puts "The spider has spotted an enemy..."
1780
+
1781
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1782
+ f.puts "The spider has spotted an enemy..."
1783
+ }
1784
+ else
1785
+ puts "The spider has not spotted an enemy..."
1786
+
1787
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1788
+ f.puts "The spider has not spotted an enemy..."
1789
+ }
1790
+ end
1791
+
1792
+ sleep(1.5)
1793
+
1794
+ if spider_chirbu == true
1795
+ puts "The spider goes chirbu chirbu chirbu..."
1796
+
1797
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1798
+ f.puts "The spider goes chirbu chirbu chirbu..."
1799
+ }
1800
+ else
1801
+ puts "The spider hisses..."
1802
+
1803
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1804
+ f.puts "The spider hisses..."
1805
+ }
1806
+ end
1807
+
1808
+ sleep(1.5)
1809
+
1810
+ if spider_shine == true
1811
+ puts "The spider shines its antenas..."
1812
+
1813
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1814
+ f.puts "The spider shines its antenas..."
1815
+ }
1816
+ else
1817
+ puts "The spider remains in the dark passage..."
1818
+
1819
+ File.open("data/gribatomaton/possible_behaviours.txt", "a") { |f|
1820
+ f.puts "The spider remains in the dark passage..."
1821
+ }
1822
+ end
1823
+
1824
+ sleep(1.5)
1825
+
1826
+ #BequestGribatomatonAdvanced::StatisticalLabels.evaluate_behaviours
1827
+ end
1828
+ end
1829
+
1830
+ class AdaptiveMechanics
1831
+ def self.learn_behaviours
1832
+ # 1 2 4 8 7 5
1833
+ # 1 1,1 1,2 1,4 1,8 1,7 1,5
1834
+ # 2 2,1 2,2 2,4 2,8 2,7 2,5
1835
+ # 4 4,1 4,2 4,4 4,8 4,7 4,5
1836
+ # 8 8,1 8,2 8,4 8,8 8,7 8,5
1837
+ # 7 7,1 7,2 7,4 7,8 7,7 7,5
1838
+ # 5 5,1 5,2 5,4 5,8 5,7 5,5
1839
+
1840
+ # 3 6 9
1841
+ # 3 3,3 3,6 3,9
1842
+ # 6 6,3 6,6 6,9
1843
+ # 9 9,3 9,6 9,9
1844
+
1845
+ vortex = [ 1, 2, 4, 8, 7, 5 ]
1846
+ charge = [ 3, 6, 9 ]
1847
+
1848
+ nested_vortex = [
1849
+ [[1, 1], [1, 2], [1, 4], [1, 8], [1, 7], [1, 5]],
1850
+ [[2, 1], [2, 2], [2, 4], [2, 8], [2, 7], [2, 5]],
1851
+ [[4, 1], [4, 2], [4, 4], [4, 8], [4, 7], [4, 5]],
1852
+ [[8, 1], [8, 2], [8, 4], [8, 8], [8, 7], [8, 5]],
1853
+ [[7, 1], [7, 2], [7, 4], [7, 8], [7, 7], [7, 5]],
1854
+ [[5, 1], [5, 2], [5, 4], [5, 8], [5, 7], [5, 5]],
1855
+ ]
1856
+
1857
+ nested_charge = [
1858
+ [[3, 3], [3, 6], [3, 9]],
1859
+ [[6, 3], [6, 6], [6, 9]],
1860
+ [[9, 3], [9, 6], [9, 9]],
1861
+ ]
1862
+
1863
+ ## Choosing the first index value for vortex based loop.
1864
+ row_options_vortex = [0, 1, 2, 3, 4, 5]
1865
+ col_options_vortex = [0, 1, 2, 3, 4, 5]
1866
+ arr_options_vortex = [0, 1]
1867
+
1868
+ v_cur_row = row_options_vortex.sample
1869
+ v_cur_col = col_options_vortex.sample
1870
+ v_cur_arr = arr_options_vortex.sample
1871
+
1872
+ ## Choosing the first index value for charge based loop.
1873
+ row_options_charge = [0, 1, 2]
1874
+ col_options_charge = [0, 1, 2]
1875
+ arr_options_charge = [0, 1]
1876
+
1877
+ c_cur_row = row_options_charge.sample
1878
+ c_cur_col = col_options_charge.sample
1879
+ c_cur_arr = arr_options_charge.sample
1880
+
1881
+ chosen_vortex_value = nested_vortex[v_cur_row][v_cur_col][v_cur_arr]
1882
+ chosen_charge_value = nested_charge[c_cur_row][c_cur_col][c_cur_arr]
1883
+
1884
+ puts chosen_vortex_value
1885
+ puts chosen_charge_value
1886
+
1887
+ ## Vortex Loop
1888
+ chosen_vortex_value.times do
1889
+ possible_lines = File.readlines("data/gribatomaton/possible_behaviours.txt")
1890
+ size_limit = possible_lines.size.to_i
1891
+ index = 0
1892
+
1893
+ ideal_line = possible_lines[chosen_vortex_value].to_s
1894
+
1895
+ size_limit.times do
1896
+ current_line = possible_lines[index].to_s
1897
+
1898
+ if current_line == ideal_line
1899
+ File.open("lib/npc/tourguide/learned_lines.txt", "a") { |f|
1900
+ f.puts current_line
1901
+ }
1902
+ else
1903
+ #puts "> Current line did not match the ideal dialogue line..."
1904
+ end
1905
+
1906
+ index = index + 1
1907
+ end
1908
+
1909
+ index = 0
1910
+ end
1911
+
1912
+ ## Charge Loop
1913
+ chosen_charge_value.times do
1914
+ learned_lines = File.readlines("data/gribatomaton/learned_behaviours.txt").shuffle
1915
+ size_limit = learned_lines.size.to_i
1916
+ index = 0
1917
+
1918
+ ideal_line = learned_lines[chosen_vortex_value].to_s
1919
+
1920
+ size_limit.times do
1921
+ current_line = learned_lines[index].to_s
1922
+
1923
+ if current_line == ideal_line
1924
+ puts current_line
1925
+
1926
+ File.open("data/gribatomaton/learned_behaviours.txt", "a") { |f|
1927
+ f.puts current_line
1928
+ }
1929
+ else
1930
+ #puts "> Current line is not reinforced into longterm memory..."
1931
+ end
1932
+
1933
+ index = index + 1
1934
+ end
1935
+
1936
+ index = 0
1937
+ end
1938
+ end
1939
+
1940
+ end
1941
+
1942
+ class StatisticalLabels
1943
+ def self.evaluate_behaviours
1944
+ require "SelfModifiedDecisionTree"
1945
+
1946
+ behaviours = NaiveBayes.new(:active, :passive)
1947
+
1948
+ ## Active
1949
+ behaviours.train(:active, "The spider has spotted an enemy...", "spotting")
1950
+ behaviours.train(:active, "The spider goes chirbu chirbu chirbu...", "chirping")
1951
+ behaviours.train(:active, "The spider shines its antenas...", "shining")
1952
+
1953
+ ## Passive
1954
+ behaviours.train(:passive, "The spider has not spotted an enemy...", "unseen")
1955
+ behaviours.train(:passive, "The spider hisses...", "hisses")
1956
+ behaviours.train(:passive, "The spider remains in the dark passage...", "darkness")
1957
+
1958
+ new_behaviours = File.readlines("data/gribatomaton/possible_behaviours.txt")
1959
+ size_limit = new_behaviours.size.to_i
1960
+ index = 0
1961
+
1962
+ size_limit.times do
1963
+ classification = behaviours.classify(new_behaviours[index])
1964
+
1965
+ require "decisiontree"
1966
+
1967
+ attributes = ["Behaviours"], ["Risk Factor"]
1968
+
1969
+ training = [
1970
+ [0.1250, "Passive"],
1971
+ [0.3435, "Almost Passive"],
1972
+ [0.5620, "Ambiguous"],
1973
+ [0.7805, "Almost Active"],
1974
+ [0.9990, "Active"],
1975
+ ], [
1976
+ [0.1250, "No Risk"],
1977
+ [0.3435, "Minimal Risk"],
1978
+ [0.5620, "Mild Risk"],
1979
+ [0.7805, "Medium Risk"],
1980
+ [0.9990, "High Risk"],
1981
+ ]
1982
+
1983
+ dec_tree = DecisionTree::ID3Tree.new(attributes, training, 1, :continuous),
1984
+ DecisionTree::ID3Tree.new(attributes, training, 1, :continuous)
1985
+
1986
+ current_dectree1 = dec_tree[0]
1987
+ current_dectree1.train
1988
+
1989
+ current_dectree2 = dec_tree[1]
1990
+ current_dectree2.train
1991
+
1992
+ activity = [classification[1], "Ambiguous"]
1993
+ risk_factor = [classification[1], "Mild Risk"]
1994
+
1995
+ decision1 = dec_tree.predict(activity)
1996
+ decision2 = dec_tree.predict(risk_factor)
1997
+
1998
+ puts "Predicted: Compared to Ambiguous with Mild Risk, #{decision1} with #{decision2}."
1999
+
2000
+ index = index + 1
2001
+
2002
+ sleep(1.5)
2003
+ end
2004
+ end
2005
+ end
2006
+ end
2007
+
2008
+ module Commands
2009
+ class Choose
2010
+ def self.select
2011
+ system("clear")
2012
+
2013
+ loop do
2014
+ logo = File.read("_logo/logo.txt")
2015
+
2016
+ puts logo
2017
+
2018
+ print "What process? << "; process = gets.chomp
2019
+
2020
+ if process == "med counter"; Communemashin::MedCounters.get_meds; gets.chomp
2021
+ elsif process == "spatial";
2022
+ SpatialRelationships::Static_Perimeters.positive_perimeters;
2023
+ SpatialRelationships::Static_Perimeters.negative_perimeters;
2024
+ SpatialRelationships::Dynamic_Perimeters.positive_perimeters;
2025
+ SpatialRelationships::Dynamic_Perimeters.negative_perimeters;
2026
+ SpatialRelationships::SpatialEvaluator.evaluate_body; gets.chomp
2027
+ elsif process == "matrix"; ProbabilityMatrix::GetMatrix.measure_probability; gets.chomp
2028
+ elsif process == "palettier"; Brain::MemoryMachine.palettier_chat
2029
+ elsif process == "dialogue";
2030
+ ## Generates the line of Ahuzacos itself.
2031
+ Communemashin::ESDF.word_class; Communemashin::ESDF.nouns;
2032
+ Communemashin::ESDF.adjectives; Communemashin::ESDF.subjects;
2033
+ Communemashin::ESDF.verbs; Communemashin::ESDF.adverbs;
2034
+ elsif process == "gribatomaton";
2035
+ BequestGribatomatonAdvanced::Behaviours.actions
2036
+ BequestGribatomatonAdvanced::AdaptiveMechanics.learn_behaviours
2037
+ elsif process == "exit"; abort
2038
+ else
2039
+ puts ">> No such process..."
2040
+ end
2041
+ end
2042
+
2043
+ end
2044
+ end
12
2045
  end