From 82f2a1702e060d96d40f1bc3ef6a38442d11166f Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 8 May 2015 17:42:08 +0200 Subject: Start a MCTS player --- charm.cpp | 91 +++++++++++++++++++++++--------------------------------- competition.py | 7 +++-- fullcompTabMT.sh | 2 ++ 3 files changed, 45 insertions(+), 55 deletions(-) diff --git a/charm.cpp b/charm.cpp index 56af6c5..45b4f65 100644 --- a/charm.cpp +++ b/charm.cpp @@ -44,7 +44,7 @@ public: grid[S*(S-1)+i]=2; } } - int moved(int at,int dir){ + int moved(int at,int dir) const{ int x=at%S,y=at/S,x2,y2; while(true){ x2=x+index_deltas[dir][0]; @@ -87,7 +87,7 @@ public: undomove(oldneuidx,mv.neudir); return true; } - void print(void){ + void print(void) const{ int x,y; if(should_flip_board){ for(y=S-1;y>=0;y--){ @@ -101,59 +101,27 @@ public: } } } -}; - - -int scorefor(const Board &bd){ - int i,score=0; - for(i=0;i &a,const pair &b){ - return a.second>b.second; -} - -Move calculate_move(Board &bd){ - vector> poss; - Move m; - int nd,fr,d; - int newneu; - int score,oldneuidx; - //bd.print(); - for(nd=0;nd<8;nd++){ - newneu=bd.moved(bd.neuidx,nd); - if(newneu==bd.neuidx)continue; - for(fr=0;fr0: break time.sleep(0.1) + if MAXTIMELIMIT==None: continue timeoutfail=False if player==1: p1totaltime+=0.1 - if p1totaltime>=50: + if p1totaltime>=MAXTIMELIMIT: timeoutfail=True else: p2totaltime+=0.1 - if p2totaltime>=50: + if p2totaltime>=MAXTIMELIMIT: timeoutfail=True if timeoutfail: print("P"+str(player)+" timed out!") diff --git a/fullcompTabMT.sh b/fullcompTabMT.sh index 53c442e..c592c00 100755 --- a/fullcompTabMT.sh +++ b/fullcompTabMT.sh @@ -156,5 +156,7 @@ EOF ponei=$((ponei + 1)) done +echo COMPETITION START >competition.log + #run the competition in threads find competitionstubs -type f -name 'game_*' | xargs -P$num_cores -n1 -- bash -- cgit v1.2.3-54-g00ecf