16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/dynamicAI.rb', line 16
def self.behaviours
old_action = File.read("data/action/history.txt")
behaviours = File.readlines("data/script/behaviours.txt")
size_limit_file = behaviours.size.to_i
size_limit = size_limit_file - 1
number = File.read("data/input/number.txt").strip.to_i
if number > size_limit
number = 0
end
new_action = behaviours[number]
open("temp.rb", "w") { |f|
f.puts new_action
f.puts old_action
}
open("data/action/history.txt", "w") { |f|
f.puts new_action
f.puts old_action
}
open("data/input/number.txt", "w") { |f|
f.puts number = number + 1
}
end
|