Commit e2206502 by ziho

test2

parent 10c22670
...@@ -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)
......
...@@ -32,7 +32,7 @@ def main(): ...@@ -32,7 +32,7 @@ def main():
os.mkdir('comm') os.mkdir('comm')
if os.path.exists('stop.txt'): if os.path.exists('stop.txt'):
os.remove('stop.txt') os.remove('stop.txt')
if os.path.exists('gameRecord.txt'): if os.path.exists('gameRecord.txt'):
print('\n game records has found!') print('\n game records has found!')
if askYes('read it? if not,will delete it and create a new one <y/n> :'): if askYes('read it? if not,will delete it and create a new one <y/n> :'):
...@@ -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先暂停行动
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment