File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change
1
+ Egaroucid_for_Console /*
2
+ __pycache__ /*
Original file line number Diff line number Diff line change 3
3
from othello_py import *
4
4
from random import choice
5
5
6
+ serial_port = 'COM3'
7
+ executable = '"./Egaroucid_for_Console/Egaroucid_for_Console.exe" -level 10 -quiet'
6
8
7
- robot = serial .Serial ('COM3' , 115200 , timeout = 1000000 )
8
- egaroucid = subprocess .Popen ('egaroucid5.exe 10' .split (), stdin = subprocess .PIPE , stdout = subprocess .PIPE )
9
+ robot = serial .Serial (serial_port , 115200 , timeout = 1000000 )
10
+ egaroucid = subprocess .Popen (executable .split (), stdin = subprocess .PIPE , stdout = subprocess .PIPE )
9
11
10
12
def send_cmds (cmds ):
11
13
for cmd in cmds :
@@ -21,21 +23,22 @@ def send_cmds(cmds):
21
23
record = ''
22
24
23
25
while True :
24
- grid_str = str ( o . player ) + ' \n '
26
+ grid_str = 'setboard '
25
27
for yy in range (hw ):
26
28
for xx in range (hw ):
27
29
if o .grid [yy ][xx ] == black :
28
- grid_str += '0 '
30
+ grid_str += 'X '
29
31
elif o .grid [yy ][xx ] == white :
30
- grid_str += '1 '
32
+ grid_str += 'O '
31
33
else :
32
- grid_str += '.'
33
- grid_str += '\n '
34
- #print(grid_str)
34
+ grid_str += '-'
35
+ grid_str += ' '
36
+ grid_str += 'X' if o .player == black else 'O'
37
+ grid_str += '\n '
35
38
egaroucid .stdin .write (grid_str .encode ('utf-8' ))
36
39
egaroucid .stdin .flush ()
37
- value , coord = egaroucid .stdout .readline ().decode ().split ()
38
- print (value , coord )
40
+ coord = egaroucid .stdout .readline ().decode ().split ()
41
+ print (coord )
39
42
record += coord
40
43
print (record )
41
44
policy = [int (coord [1 ]) - 1 , ord (coord [0 ]) - ord ('a' )]
You can’t perform that action at this time.
0 commit comments