-
Notifications
You must be signed in to change notification settings - Fork 4
/
ai_black.rb
61 lines (45 loc) · 1.12 KB
/
ai_black.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
54
55
56
57
58
59
60
61
require "xmlrpc/server"
require "socket"
require 'json'
s = XMLRPC::Server.new(ARGV[0])
MAX_NUMBER = 16000
class MyAlggago
def calculate(positions)
params = ""
params += " #{positions[0].count}"
params += " #{positions[1].count}"
positions[0].each do |coord|
params += " #{coord}"
end
positions[1].each do |coord|
params += " #{coord}"
end
count = 0
my_position_hash = {}
positions[0].each do |coord|
my_position_hash[count] = coord
count += 1
end
count = 0
your_position_hash = {}
positions[1].each do |coord|
your_position_hash[count] = coord
count += 1
end
tempHash = {
"my_position" => my_position_hash,
"your_position" => your_position_hash
}
File.open("temp.json","w") do |f|
f.write(JSON.pretty_generate(tempHash))
end
result_from_python = `python ai_team_TNK.py`
results = result_from_python.split(",")
return [results[0].to_i, results[1].to_f, results[2].to_f, results.to_s]
end
def get_name
"MY AI!!!"
end
end
s.add_handler("alggago", MyAlggago.new)
s.serve