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
huangzhihao
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
ELO_client.py
+3
-2
ELo_server.py
+9
-6
No files found.
ELO_client.py
View file @
e2206502
...
...
@@ -15,7 +15,7 @@ def choose_game():
name
=
black
+
'_'
+
white
try
:
src
=
'comm/'
+
d
dst
=
'comm/'
+
name
+
'running'
dst
=
'comm/'
+
name
+
'
.
running'
os
.
rename
(
src
,
dst
)
except
:
continue
...
...
@@ -32,8 +32,9 @@ def main():
game
=
choose_game
()
if
game
:
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
.
remove
(
'comm/'
+
game
[
0
]
+
'_'
+
game
[
1
]
+
'.running'
)
else
:
time
.
sleep
(
1
)
...
...
ELo_server.py
View file @
e2206502
...
...
@@ -32,7 +32,7 @@ def main():
os
.
mkdir
(
'comm'
)
if
os
.
path
.
exists
(
'stop.txt'
):
os
.
remove
(
'stop.txt'
)
if
os
.
path
.
exists
(
'gameRecord.txt'
):
print
(
'
\n
game records has found!'
)
if
askYes
(
'read it? if not,will delete it and create a new one <y/n> :'
):
...
...
@@ -46,6 +46,7 @@ def main():
while
True
:
if
ans
==
'stop'
:
#todo 保存记录?通知client退出?
os
.
system
(
'touch stop.txt'
)
break
elif
ans
==
'summary'
:
elo
.
summary
()
...
...
@@ -53,7 +54,7 @@ def main():
matchRes
=
re
.
match
(
r'play (\d+)'
,
ans
)
if
matchRes
:
num
=
matchRes
.
group
(
1
)
play
(
elo
,
num
)
play
(
int
(
num
)
)
print
(
'commandList:
\n
'
+
'
\n
'
.
join
(
commandList
))
ans
=
input
(
'>>'
)
...
...
@@ -84,9 +85,9 @@ def play(total_game):
while
i
<
num
:
black
,
white
=
choose
()
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
os
.
system
(
'touch '
+
name
+
'.init'
)
os
.
system
(
'touch
comm/
'
+
name
+
'.init'
)
i
+=
1
def
read
():
...
...
@@ -121,8 +122,10 @@ def play(total_game):
while
complete_game
<
total_game
:
complete_game
+=
read
()
num
=
exist_game
()
create_game
(
min
(
max_game
-
exist_game
,
total_game
-
complete_game
-
exist_game
+
10
))
time
.
sleep
(
1
)
create_game
(
min
(
max_game
-
num
,
total_game
-
complete_game
-
num
+
10
))
print
(
'{}/{}'
.
format
(
complete_game
,
total_game
))
time
.
sleep
(
5
)
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