diff options
author | tomsmeding <hallo@tomsmeding.nl> | 2015-10-23 12:23:11 +0200 |
---|---|---|
committer | tomsmeding <hallo@tomsmeding.nl> | 2015-10-23 12:23:11 +0200 |
commit | e22b0edd4822ad5030d19d8fdb61511690e34239 (patch) | |
tree | 4d46b2f0ba77c67ce95a271402ea581370a27843 /player_rand.cpp | |
parent | b5077ff9a36c89c84c04f33dce3a2a0ff45e9184 (diff) |
handwapper
Diffstat (limited to 'player_rand.cpp')
-rw-r--r-- | player_rand.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/player_rand.cpp b/player_rand.cpp new file mode 100644 index 0000000..a672f18 --- /dev/null +++ b/player_rand.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <string> +#include <sys/time.h> +#include "common.h" + +using namespace std; + +int main(void){ + struct timeval tv; + gettimeofday(&tv,NULL); + srand(tv.tv_sec*1000000+tv.tv_usec); + + Board bd; + char c; + Move mv; + cin>>c; cin.ignore(1024,'\n'); + int me=c-'A'; + int x,y,i; + for(int turnidx=me;;turnidx+=NPLAYERS){ + c=cin.peek(); + if(c=='q'||c=='Q')break; + for(i=me+1;i%NPLAYERS!=me;i++){ + cin>>x>>y; + if(x!=-1&&y!=-1)bd.put(x,y,i%NPLAYERS); + } + cin.ignore(1024,'\n'); + mv=randommove(bd,me); + bd.put(mv.idx(),me); + cout<<mv.x<<' '<<mv.y<<endl; + } +} |