Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
elo-rating
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songxinkai
elo-rating
Commits
e2206502
Commit
e2206502
authored
Aug 13, 2020
by
ziho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test2
parent
10c22670
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
ELO_client.py
+3
-2
ELo_server.py
+8
-5
No files found.
ELO_client.py
View file @
e2206502
...
@@ -15,7 +15,7 @@ def choose_game():
...
@@ -15,7 +15,7 @@ def choose_game():
name
=
black
+
'_'
+
white
name
=
black
+
'_'
+
white
try
:
try
:
src
=
'comm/'
+
d
src
=
'comm/'
+
d
dst
=
'comm/'
+
name
+
'running'
dst
=
'comm/'
+
name
+
'
.
running'
os
.
rename
(
src
,
dst
)
os
.
rename
(
src
,
dst
)
except
:
except
:
continue
continue
...
@@ -32,8 +32,9 @@ def main():
...
@@ -32,8 +32,9 @@ def main():
game
=
choose_game
()
game
=
choose_game
()
if
game
:
if
game
:
winrate
=
pk
(
game
[
0
],
game
[
1
])
winrate
=
pk
(
game
[
0
],
game
[
1
])
name
=
'_'
.
join
([
game
[
0
],
game
[
1
],
str
(
winrate
)])
+
'.finish'
name
=
'
comm'
+
'
_'
.
join
([
game
[
0
],
game
[
1
],
str
(
winrate
)])
+
'.finish'
os
.
system
(
'touch '
+
name
)
os
.
system
(
'touch '
+
name
)
os
.
remove
(
'comm/'
+
game
[
0
]
+
'_'
+
game
[
1
]
+
'.running'
)
else
:
else
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
...
...
ELo_server.py
View file @
e2206502
...
@@ -46,6 +46,7 @@ def main():
...
@@ -46,6 +46,7 @@ def main():
while
True
:
while
True
:
if
ans
==
'stop'
:
if
ans
==
'stop'
:
#todo 保存记录?通知client退出?
#todo 保存记录?通知client退出?
os
.
system
(
'touch stop.txt'
)
break
break
elif
ans
==
'summary'
:
elif
ans
==
'summary'
:
elo
.
summary
()
elo
.
summary
()
...
@@ -53,7 +54,7 @@ def main():
...
@@ -53,7 +54,7 @@ def main():
matchRes
=
re
.
match
(
r'play (\d+)'
,
ans
)
matchRes
=
re
.
match
(
r'play (\d+)'
,
ans
)
if
matchRes
:
if
matchRes
:
num
=
matchRes
.
group
(
1
)
num
=
matchRes
.
group
(
1
)
play
(
elo
,
num
)
play
(
int
(
num
)
)
print
(
'commandList:
\n
'
+
'
\n
'
.
join
(
commandList
))
print
(
'commandList:
\n
'
+
'
\n
'
.
join
(
commandList
))
ans
=
input
(
'>>'
)
ans
=
input
(
'>>'
)
...
@@ -84,9 +85,9 @@ def play(total_game):
...
@@ -84,9 +85,9 @@ def play(total_game):
while
i
<
num
:
while
i
<
num
:
black
,
white
=
choose
()
black
,
white
=
choose
()
name
=
black
+
'_'
+
white
name
=
black
+
'_'
+
white
if
os
.
path
.
exists
(
name
+
'.init'
)
or
os
.
path
.
exists
(
name
+
'.running'
)
or
os
.
path
.
exists
(
name
+
'.complete'
):
if
os
.
path
.
exists
(
'comm/'
+
name
+
'.init'
)
or
os
.
path
.
exists
(
'comm/'
+
name
+
'.running'
)
or
os
.
path
.
exists
(
'comm/'
+
name
+
'.complete'
):
continue
continue
os
.
system
(
'touch '
+
name
+
'.init'
)
os
.
system
(
'touch
comm/
'
+
name
+
'.init'
)
i
+=
1
i
+=
1
def
read
():
def
read
():
...
@@ -121,8 +122,10 @@ def play(total_game):
...
@@ -121,8 +122,10 @@ def play(total_game):
while
complete_game
<
total_game
:
while
complete_game
<
total_game
:
complete_game
+=
read
()
complete_game
+=
read
()
num
=
exist_game
()
num
=
exist_game
()
create_game
(
min
(
max_game
-
exist_game
,
total_game
-
complete_game
-
exist_game
+
10
))
create_game
(
min
(
max_game
-
num
,
total_game
-
complete_game
-
num
+
10
))
time
.
sleep
(
1
)
print
(
'{}/{}'
.
format
(
complete_game
,
total_game
))
time
.
sleep
(
5
)
os
.
system
(
'touch pause.txt'
)
#通知client先暂停行动
os
.
system
(
'touch pause.txt'
)
#通知client先暂停行动
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment