ImpUnit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ImpUnit/version.rb +1 -1
- data/lib/ImpUnit.rb +76 -276
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccfb425b2ee0985526a81cce9b8b08b857046edc4b430c43220c29ee9a5e7c16
|
4
|
+
data.tar.gz: ee6a928ce7c0297d2363649584bd4467f55ea53594602e713563b15347c7d8dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4930e381874f9f8f4881005b824bd5d3dd7c598d62e24825ac37a4d4f06f7e42f2bc10674b475c3d4e5826dcb8fc96ef345166d14df02db8feeba51184206671
|
7
|
+
data.tar.gz: 4d99f8b6647003c2078d0369c3b5ec6cee70c5ef54429e2377b8c39840fb884b180737741437ac8876268df8725ed0d711ca4b3f6a06d0371d134b08d9135caa
|
data/lib/ImpUnit/version.rb
CHANGED
data/lib/ImpUnit.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "ImpUnit/version"
|
2
2
|
|
3
3
|
module ImpUnit
|
4
|
+
class Error < StandardError; end
|
4
5
|
|
5
6
|
class MainAI
|
6
7
|
def self.seed
|
@@ -54,277 +55,76 @@ module ImpUnit
|
|
54
55
|
end
|
55
56
|
|
56
57
|
# Points to specific subroutines.
|
57
|
-
class
|
58
|
-
def self.apple_color
|
59
|
-
def self.what_color
|
60
|
-
input = File.read("data/apple/colors/color_chart.txt").split(" ")
|
58
|
+
class SimpleSearch
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
# Estimate each word in a sentence from a label.
|
67
|
-
size_limit.times do
|
68
|
-
require 'naive_bayes'
|
69
|
-
|
70
|
-
color = NaiveBayes.new(:red, :green, :yellow)
|
71
|
-
|
72
|
-
# Trains on apple colors.
|
73
|
-
color.train(:red, "red", "word")
|
74
|
-
color.train(:green, "green", "word")
|
75
|
-
color.train(:yellow, "yellow", "word")
|
76
|
-
|
77
|
-
b = input[number]
|
78
|
-
|
79
|
-
puts "Results >> #{color.classify(*b)}"
|
80
|
-
|
81
|
-
sleep(1)
|
82
|
-
|
83
|
-
number = number + 1
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.what_color
|
88
|
-
input = File.read("data/apple/actions/action_chart.txt").split(" ")
|
89
|
-
|
90
|
-
number = 0
|
91
|
-
|
92
|
-
size_limit = input.size.to_i
|
93
|
-
|
94
|
-
# Estimate each word in a sentence from a label.
|
95
|
-
size_limit.times do
|
96
|
-
require 'naive_bayes'
|
97
|
-
|
98
|
-
action = NaiveBayes.new(:eat, :toss)
|
99
|
-
|
100
|
-
# Trains on apple colors.
|
101
|
-
action.train(:eat, "eat", "word")
|
102
|
-
action.train(:toss, "toss", "word")
|
103
|
-
|
104
|
-
b = input[number]
|
105
|
-
|
106
|
-
puts "Results >> #{action.classify(*b)}"
|
107
|
-
|
108
|
-
sleep(1)
|
109
|
-
|
110
|
-
number = number + 1
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
print "Deciding on color...\n\n"; sleep(3)
|
115
|
-
|
116
|
-
ImpUnit::Subroutines.apple_color.what_color
|
117
|
-
|
118
|
-
print "Deciding on action...\n\n"; sleep(3)
|
119
|
-
|
120
|
-
ImpUnit::Subroutines.apple_color.what_action
|
121
|
-
end
|
122
|
-
|
123
|
-
def self.simple_search
|
124
|
-
def self.standard
|
125
|
-
number = 0
|
126
|
-
|
127
|
-
options_list = File.read("options/option_list.txt").to_s.split(" ") #.shuffle
|
128
|
-
|
129
|
-
# Candidate files
|
130
|
-
candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
|
60
|
+
# ImpUnit::SimpleSearch.standard
|
61
|
+
def self.standard
|
62
|
+
number = 0
|
131
63
|
|
132
|
-
|
133
|
-
size_limit = options_list.size.to_i
|
64
|
+
options_list = File.read("options/option_list.txt").to_s.split(" ") #.shuffle
|
134
65
|
|
135
|
-
|
136
|
-
|
137
|
-
option = options_list[number]
|
66
|
+
# Candidate files
|
67
|
+
candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
|
138
68
|
|
139
|
-
|
69
|
+
# Bases iteration limit on options list size.
|
70
|
+
size_limit = options_list.size.to_i
|
140
71
|
|
141
|
-
|
142
|
-
|
72
|
+
# Iterate size limit times comparing option with candidate.
|
73
|
+
size_limit.times do
|
74
|
+
option = options_list[number]
|
143
75
|
|
144
|
-
|
145
|
-
else
|
146
|
-
puts " #{option} does not match the candidate #{candidate}."
|
147
|
-
end
|
76
|
+
print "Candidate: #{candidate} Option: #{option} >> "
|
148
77
|
|
149
|
-
|
78
|
+
if option == candidate
|
79
|
+
puts " #{option} matches the candidate #{candidate}."
|
150
80
|
|
151
|
-
|
81
|
+
abort
|
82
|
+
else
|
83
|
+
puts " #{option} does not match the candidate #{candidate}."
|
152
84
|
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def self.random
|
156
|
-
number = 0
|
157
85
|
|
158
|
-
|
159
|
-
|
160
|
-
# Candidate files
|
161
|
-
candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
|
162
|
-
|
163
|
-
# Bases iteration limit on options list size.
|
164
|
-
size_limit = options_list.size.to_i
|
165
|
-
|
166
|
-
# Iterate size limit times comparing option with candidate.
|
167
|
-
size_limit.times do
|
168
|
-
option = options_list[number]
|
169
|
-
|
170
|
-
print "Candidate: #{candidate} Option: #{option} >> "
|
171
|
-
|
172
|
-
if option == candidate
|
173
|
-
puts " #{option} matches the candidate #{candidate}."
|
174
|
-
|
175
|
-
abort
|
176
|
-
else
|
177
|
-
puts " #{option} does not match the candidate #{candidate}."
|
178
|
-
end
|
179
|
-
|
180
|
-
sleep(3)
|
86
|
+
sleep(3)
|
181
87
|
|
182
|
-
|
183
|
-
end
|
88
|
+
number = number + 1
|
184
89
|
end
|
185
90
|
end
|
186
91
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# Continuous Dice
|
192
|
-
dice = [10.50, 10.75, 21.25,
|
193
|
-
21.50, 21.75, 82.25,
|
194
|
-
82.50, 82.75, 73.25,
|
195
|
-
73.50, 73.75, 54.25,
|
196
|
-
54.50, 54.75, 10.50]
|
197
|
-
|
198
|
-
input = dice.sample.to_i
|
199
|
-
|
200
|
-
attributes = ['Rikusuto']
|
201
|
-
|
202
|
-
training = [
|
203
|
-
[ 0.5, "will you get"],
|
204
|
-
[ 50.0, "will you obtain"],
|
205
|
-
[100.0, "may I have"],
|
206
|
-
]
|
207
|
-
|
208
|
-
# Instantiate the tree, and train it based on the data (set default to '1')
|
209
|
-
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 1, :continuous)
|
210
|
-
dec_tree.train
|
211
|
-
|
212
|
-
test = [input, "may I have"]
|
213
|
-
|
214
|
-
decision = dec_tree.predict(test)
|
215
|
-
|
216
|
-
# puts "Desired Result: #{decision} ... True Result: #{test.last}"
|
217
|
-
|
218
|
-
open("data/rikusuto/request.txt", "w") { |f|
|
219
|
-
f.puts decision
|
220
|
-
}
|
221
|
-
end
|
222
|
-
|
223
|
-
def self.atemu
|
224
|
-
require "decisiontree"
|
225
|
-
|
226
|
-
# Continuous Dice
|
227
|
-
dice = [10.50, 10.75, 21.25,
|
228
|
-
21.50, 21.75, 82.25,
|
229
|
-
82.50, 82.75, 73.25,
|
230
|
-
73.50, 73.75, 54.25,
|
231
|
-
54.50, 54.75, 10.50]
|
232
|
-
|
233
|
-
input = dice.sample.to_i
|
234
|
-
|
235
|
-
attributes = ['Atemu']
|
236
|
-
|
237
|
-
training = [
|
238
|
-
[ 0.5, "a banana"],
|
239
|
-
[ 50.0, "an orange"],
|
240
|
-
[100.0, "a kiwi"],
|
241
|
-
]
|
242
|
-
|
243
|
-
# Instantiate the tree, and train it based on the data (set default to '1')
|
244
|
-
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 1, :continuous)
|
245
|
-
dec_tree.train
|
246
|
-
|
247
|
-
test = [input, "an orange"]
|
248
|
-
|
249
|
-
decision = dec_tree.predict(test)
|
250
|
-
|
251
|
-
# puts "Desired Result: #{decision} ... True Result: #{test.last}"
|
252
|
-
open("data/items/items.txt", "w") { |f|
|
253
|
-
f.puts decision
|
254
|
-
}
|
255
|
-
end
|
256
|
-
|
257
|
-
def self.create
|
258
|
-
|
259
|
-
xml_header = '<?xml version="1.0" encoding="UTF-8"?>
|
260
|
-
<?xml-stylesheet type="text/css" href="stylesheet.css"?>'
|
261
|
-
|
262
|
-
topic_header = "<topic>"
|
263
|
-
topic_bottom = "</topic>"
|
264
|
-
|
265
|
-
def self.salut
|
266
|
-
" <salut>Hello</salut>"
|
267
|
-
end
|
268
|
-
|
269
|
-
def self.ejento
|
270
|
-
agent_name = File.read("data/usr_identity/name.txt").strip.to_s
|
271
|
-
|
272
|
-
" <ejento>#{agent_name}</ejento>"
|
273
|
-
end
|
274
|
-
|
275
|
-
def self.rikusuto
|
276
|
-
request_type = File.read("data/requests/request.txt").strip.to_s
|
92
|
+
# ImpUnit::SimpleSearch.random
|
93
|
+
def self.random
|
94
|
+
number = 0
|
277
95
|
|
278
|
-
|
279
|
-
end
|
96
|
+
options_list = File.read("options/option_list.txt").to_s.split(" ").shuffle
|
280
97
|
|
281
|
-
|
282
|
-
|
98
|
+
# Candidate files
|
99
|
+
candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s
|
283
100
|
|
284
|
-
|
285
|
-
|
101
|
+
# Bases iteration limit on options list size.
|
102
|
+
size_limit = options_list.size.to_i
|
286
103
|
|
287
|
-
|
288
|
-
|
289
|
-
|
104
|
+
# Iterate size limit times comparing option with candidate.
|
105
|
+
size_limit.times do
|
106
|
+
option = options_list[number]
|
290
107
|
|
291
|
-
|
292
|
-
" <kara>from</kara>"
|
293
|
-
end
|
108
|
+
print "Candidate: #{candidate} Option: #{option} >> "
|
294
109
|
|
295
|
-
|
296
|
-
|
110
|
+
if option == candidate
|
111
|
+
puts " #{option} matches the candidate #{candidate}."
|
297
112
|
|
298
|
-
|
113
|
+
abort
|
114
|
+
else
|
115
|
+
puts " #{option} does not match the candidate #{candidate}."
|
299
116
|
end
|
300
117
|
|
301
|
-
|
302
|
-
local_name = File.read("data/usr_identity/local_name.txt").strip.to_s
|
303
|
-
|
304
|
-
" <lieu>#{local_name}</lieu>"
|
305
|
-
end
|
118
|
+
sleep(3)
|
306
119
|
|
307
|
-
|
308
|
-
consign = conjucate.sample
|
309
|
-
|
310
|
-
user_location = [yuza, lieu]
|
311
|
-
usign = user_location[0]
|
312
|
-
|
313
|
-
open("index.xml", "w") { |f|
|
314
|
-
f.puts xml_header
|
315
|
-
f.puts topic_header
|
316
|
-
f.puts salut
|
317
|
-
f.puts ejento
|
318
|
-
f.puts rikusuto
|
319
|
-
f.puts atemu
|
320
|
-
f.puts consign
|
321
|
-
f.puts usign
|
322
|
-
f.puts topic_bottom
|
323
|
-
}
|
120
|
+
number = number + 1
|
324
121
|
end
|
325
122
|
end
|
123
|
+
end
|
326
124
|
|
327
|
-
|
125
|
+
# ImpUnit::Unfiction.process
|
126
|
+
class Unfiction
|
127
|
+
def self.process
|
328
128
|
# Loop limit based on configured screen settings.
|
329
129
|
number = File.read("data/config/line_num.txt").strip.to_i
|
330
130
|
do_size = ["tiny", "small", "medium"]
|
@@ -340,46 +140,46 @@ module ImpUnit
|
|
340
140
|
# Base dialogue sequence on size limit.
|
341
141
|
size_limit.times do
|
342
142
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
if name_limit > character_count
|
349
|
-
name_limit = name_limit % 2
|
350
|
-
else
|
351
|
-
name_limit = name_limit + 1
|
352
|
-
end
|
143
|
+
# Username logistics
|
144
|
+
name_list = File.read("data/identity/name_list.txt").split(", ")
|
145
|
+
name = name_list[name_number].to_s
|
146
|
+
name_limit = name_list[name_number].size
|
353
147
|
|
354
|
-
|
148
|
+
if name_limit > character_count
|
149
|
+
name_limit = name_limit % 2
|
150
|
+
else
|
151
|
+
name_limit = name_limit + 1
|
152
|
+
end
|
355
153
|
|
356
|
-
|
357
|
-
system("date > data/date/date.txt")
|
154
|
+
old_dialogue = File.read("archive/dialogue.txt").strip.to_s
|
358
155
|
|
359
|
-
|
156
|
+
# Write date to file.
|
157
|
+
system("date > data/date/date.txt")
|
360
158
|
|
361
|
-
|
362
|
-
print "[#{date} #{name.strip}] "; new_dialogue = gets.chomp
|
159
|
+
date = File.read("data/date/date.txt").strip
|
363
160
|
|
364
|
-
|
365
|
-
|
366
|
-
abort
|
367
|
-
end
|
161
|
+
# Print character dialogue to screen.
|
162
|
+
print "[#{date} #{name.strip}] "; new_dialogue = gets.chomp
|
368
163
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
f.puts new_dialogue
|
374
|
-
}
|
164
|
+
# If writer specifies exit then aborts
|
165
|
+
if new_dialogue == "exit"
|
166
|
+
abort
|
167
|
+
end
|
375
168
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
169
|
+
# Autosaves dialogue archive. Auto appends old dialogue above new dialogue.
|
170
|
+
open("archive/dialogue.txt", "w") { |f|
|
171
|
+
f.puts old_dialogue
|
172
|
+
f.print "[#{date} #{name.strip}] "
|
173
|
+
f.puts new_dialogue
|
174
|
+
}
|
175
|
+
|
176
|
+
# Changes name as if in a chatroom.
|
177
|
+
if name_number == name_limit
|
178
|
+
name_number = 0
|
179
|
+
else
|
180
|
+
name_number = name_number + 1
|
382
181
|
end
|
383
182
|
end
|
183
|
+
|
384
184
|
end
|
385
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ImpUnit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LWFlouisa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|