SmallBlue example

This is a sample game playing program.

SmallBlue.C (standalone version)

 #include <string> #include <iostream> #include<fstream> using namespace std; #include"GAME.C" int Simulate(GAME newgame, int col) { int l=0,s; int start=newgame.Value(col,WHITE); newgame.Play(col,WHITE); // newgame.Inverse(); l=0; for(int k=1;k!=XSIZE+1;k++) { s=newgame.Value(k,BLACK); if (s>l) l=s; }; start-=l; return start; } main() { GAME Current(XSIZE,YSIZE); int s,l,k,toplay; char c[2]; while (true) { Current.Display(); do { cout << "?"; cin >> c; c[1]='\0'; l=atoi(c); } while ((l<1) || (l>XSIZE) || !Current.CanPlay(l) ); Current.Play(l,BLACK); if (Current.HasWon(l,BLACK)) { Current.Display(); exit(1); }; l=-100000; for(k=1;k!=XSIZE+1;k++) { if (Current.CanPlay(k)) ...

Get Enabling Applications for Grid Computing with Globus now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.