Commit e2206502 by ziho

test2

parent 10c22670
......@@ -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)
......
......@@ -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先暂停行动
......
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