BasicAI : basic.java Reader.java piece.java
gcj -o BasicAI --main=BasicAI basic.java Reader.java piece.java
-#BasicAI.class : basic.java Reader.java piece.java
-# javac Reader.java
-# javac piece.java
-# javac basic.java
+BasicAI.class : basic.java Reader.java piece.java
+ javac Reader.java
+ javac piece.java
+ javac basic.java
clean :
- rm BasicAI
+ rm -f BasicAI
+ rm -f *.class
-vixen.py
+vixen.patched.py
Sam Moore
python
Sample AI - An improvement on <a href=asmodeus.html>asmodeus'</a> score optimisation. Considers probabilities for unknown enemy units, and sums scores for paths with common first move.
--- /dev/null
+#Makefile for Stratego
+
+LIBRARIES = -lpthread
+FRAMEWORKS = -framework SDL -framework OpenGL
+LDFLAGS = $(FRAMEWORKS) $(LIBRARIES)
+CXXFLAGS = -Wall -pedantic -g -I/Library/Frameworks/SDL.framework/Headers/
+
+OBJ = main.o controller.o network_controller.o ai_controller.o human_controller.o program.o network.o thread_util.o stratego.o graphics.o game.o
+
+BIN = stratego
+
+$(BIN) : $(OBJ)
+ $(CXX) $(CXXFLAGS) -o $(BIN) $(OBJ) osx/SDLMain.m -framework Cocoa $(LDFLAGS)
+
+
+%.o : %.cpp %.h
+ $(CXX) $(CXXFLAGS) -c $<
+
+clean :
+ $(RM) $(BIN) $(OBJ) $(LINKOBJ)
+
+clean_full: #cleans up all backup files
+ $(RM) $(BIN) $(OBJ) $(LINKOBJ)
+ $(RM) *.*~
+ $(RM) *~
+
+
{
return MovementResult::BAD_RESPONSE; //You need to include a flag!
}
+
+ //Added 9/04/12 - Check all pieces that can be placed are placed
+ for (int ii = 0; ii <= (int)(Piece::BOMB); ++ii)
+ {
+ if (usedUnits[ii] != Piece::maxUnits[ii])
+ return MovementResult::BAD_RESPONSE; //You must place ALL possible pieces
+ }
+
return MovementResult::OK;
buffer += " OK";
return MovementResult::OK;
}
+ */
+ //Restored SURRENDER 9/04/12, because... it kind of seems necessary?
if (buffer == "SURRENDER")
{
buffer += " OK";
return MovementResult::SURRENDER;
}
- */
+
+
int x; int y; string direction="";
stringstream s(buffer);
if (wait <= 0)
return;
- TimerThread timer(wait*1000000); //Wait in seconds
- timer.Start();
+
+
#ifdef BUILD_GRAPHICS
+
+
if (!graphicsEnabled)
{
- while (!timer.Finished());
- timer.Stop();
+ usleep(1000000*wait); //Wait in seconds
return;
}
- #endif //BUILD_GRAPHICS
+ TimerThread timer(wait*1000000); //Wait in seconds
+ timer.Start();
while (!timer.Finished())
{
- #ifdef BUILD_GRAPHICS
+
SDL_Event event;
while (SDL_PollEvent(&event))
{
break;
}
}
- #endif //BUILD_GRAPHICS
}
timer.Stop();
+
+ #else
+ usleep(wait*1000000); //Wait in seconds
+ #endif //BUILD_GRAPHICS
}
}
else
{
- glColor3f(colour.r,colour.g,colour.b);
+ glColor4f(colour.r,colour.g,colour.b,1);
Draw(x,y,angle,scale);
- glColor3f(1,1,1);
+ glColor4f(1,1,1,1);
}
}
setbuf(file, NULL);
}
+ struct timeval tv;
+ fd_set readfds;
+
+ tv.tv_sec = (int)(timeout);
+ tv.tv_usec = (timeout - (double)((int)timeout)) * 1000000;
+
+ FD_ZERO(&readfds);
+ FD_SET(sfd, &readfds);
+
+ select(sfd+1, &readfds, NULL, NULL, &tv);
+
+ if (!FD_ISSET(sfd, &readfds))
+ return false; //Timed out
+ //fprintf(stderr, "Got message!\n");
+ for (char c = fgetc(file); c != '\n' && (int)(c) != EOF; c = fgetc(file))
+ {
+ //fprintf(stderr, "%c", c);
+ buffer += c;
+ }
+ //fprintf(stderr, "%s\n", buffer.c_str());
+ return true;
+
+
+ /* Old way, which is apparently terrible
+
assert(&buffer != NULL);
GetterThread getterThread(file, buffer);
assert(&(getterThread.buffer) != NULL);
if (buffer.size() == 1 && buffer[0] == EOF)
return false;
return true;
+ */
}
//fprintf(stderr," NetworkReceiver::QuerySetup... ");
for (int ii=0; ii < 4; ++ii)
{
- assert(network->GetMessage(setup[ii], 20));
+ assert(network->GetMessage(setup[ii], 20000));
}
//fprintf(stderr,"Done!\n");
return MovementResult::OK;
MovementResult NetworkReceiver::QueryMove(string & buffer)
{
- assert(network->GetMessage(buffer, 20));
+ assert(network->GetMessage(buffer, 20000));
return MovementResult::OK;
}
--- /dev/null
+/* SDLMain.m - main entry point for our Cocoa-ized SDL app
+
+ Feel free to customize this file to suit your needs
+*/
+
+#ifndef _SDLMain_h_
+#define _SDLMain_h_
+
+#import <Cocoa/Cocoa.h>
+
+@interface SDLMain : NSObject
+@end
+
+#endif /* _SDLMain_h_ */
--- /dev/null
+/* SDLMain.m - main entry point for our Cocoa-ized SDL app
+
+ Feel free to customize this file to suit your needs
+*/
+
+#include "SDL.h"
+#include "SDLMain.h"
+#include <sys/param.h> /* for MAXPATHLEN */
+#include <unistd.h>
+
+/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
+ but the method still is there and works. To avoid warnings, we declare
+ it ourselves here. */
+@interface NSApplication(SDL_Missing_Methods)
+- (void)setAppleMenu:(NSMenu *)menu;
+@end
+
+/* Use this flag to determine whether we use SDLMain.nib or not */
+#define SDL_USE_NIB_FILE 0
+
+/* Use this flag to determine whether we use CPS (docking) or not */
+#define SDL_USE_CPS 1
+#ifdef SDL_USE_CPS
+/* Portions of CPS.h */
+typedef struct CPSProcessSerNum
+{
+ UInt32 lo;
+ UInt32 hi;
+} CPSProcessSerNum;
+
+extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
+extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
+extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
+
+#endif /* SDL_USE_CPS */
+
+static int gArgc;
+static char **gArgv;
+static BOOL gFinderLaunch;
+static BOOL gCalledAppMainline = FALSE;
+
+static NSString *getApplicationName(void)
+{
+ const NSDictionary *dict;
+ NSString *appName = 0;
+
+ /* Determine the application name */
+ dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
+ if (dict)
+ appName = [dict objectForKey: @"CFBundleName"];
+
+ if (![appName length])
+ appName = [[NSProcessInfo processInfo] processName];
+
+ return appName;
+}
+
+#if SDL_USE_NIB_FILE
+/* A helper category for NSString */
+@interface NSString (ReplaceSubString)
+- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
+@end
+#endif
+
+@interface NSApplication (SDLApplication)
+@end
+
+@implementation NSApplication (SDLApplication)
+/* Invoked from the Quit menu item */
+- (void)terminate:(id)sender
+{
+ /* Post a SDL_QUIT event */
+ SDL_Event event;
+ event.type = SDL_QUIT;
+ SDL_PushEvent(&event);
+}
+@end
+
+/* The main class of the application, the application's delegate */
+@implementation SDLMain
+
+/* Set the working directory to the .app's parent directory */
+- (void) setupWorkingDirectory:(BOOL)shouldChdir
+{
+ if (shouldChdir)
+ {
+ char parentdir[MAXPATHLEN];
+ CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
+ if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
+ chdir(parentdir); /* chdir to the binary app's parent */
+ }
+ CFRelease(url);
+ CFRelease(url2);
+ }
+}
+
+#if SDL_USE_NIB_FILE
+
+/* Fix menu to contain the real app name instead of "SDL App" */
+- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
+{
+ NSRange aRange;
+ NSEnumerator *enumerator;
+ NSMenuItem *menuItem;
+
+ aRange = [[aMenu title] rangeOfString:@"SDL App"];
+ if (aRange.length != 0)
+ [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
+
+ enumerator = [[aMenu itemArray] objectEnumerator];
+ while ((menuItem = [enumerator nextObject]))
+ {
+ aRange = [[menuItem title] rangeOfString:@"SDL App"];
+ if (aRange.length != 0)
+ [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
+ if ([menuItem hasSubmenu])
+ [self fixMenu:[menuItem submenu] withAppName:appName];
+ }
+}
+
+#else
+
+static void setApplicationMenu(void)
+{
+ /* warning: this code is very odd */
+ NSMenu *appleMenu;
+ NSMenuItem *menuItem;
+ NSString *title;
+ NSString *appName;
+
+ appName = getApplicationName();
+ appleMenu = [[NSMenu alloc] initWithTitle:@""];
+
+ /* Add menu items */
+ title = [@"About " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+
+ [appleMenu addItem:[NSMenuItem separatorItem]];
+
+ title = [@"Hide " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
+
+ menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
+
+ [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
+
+ [appleMenu addItem:[NSMenuItem separatorItem]];
+
+ title = [@"Quit " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+
+
+ /* Put menu into the menubar */
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
+ [menuItem setSubmenu:appleMenu];
+ [[NSApp mainMenu] addItem:menuItem];
+
+ /* Tell the application object that this is now the application menu */
+ [NSApp setAppleMenu:appleMenu];
+
+ /* Finally give up our references to the objects */
+ [appleMenu release];
+ [menuItem release];
+}
+
+/* Create a window menu */
+static void setupWindowMenu(void)
+{
+ NSMenu *windowMenu;
+ NSMenuItem *windowMenuItem;
+ NSMenuItem *menuItem;
+
+ windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
+
+ /* "Minimize" item */
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
+ [windowMenu addItem:menuItem];
+ [menuItem release];
+
+ /* Put menu into the menubar */
+ windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
+ [windowMenuItem setSubmenu:windowMenu];
+ [[NSApp mainMenu] addItem:windowMenuItem];
+
+ /* Tell the application object that this is now the window menu */
+ [NSApp setWindowsMenu:windowMenu];
+
+ /* Finally give up our references to the objects */
+ [windowMenu release];
+ [windowMenuItem release];
+}
+
+/* Replacement for NSApplicationMain */
+static void CustomApplicationMain (int argc, char **argv)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ SDLMain *sdlMain;
+
+ /* Ensure the application object is initialised */
+ [NSApplication sharedApplication];
+
+#ifdef SDL_USE_CPS
+ {
+ CPSProcessSerNum PSN;
+ /* Tell the dock about us */
+ if (!CPSGetCurrentProcess(&PSN))
+ if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
+ if (!CPSSetFrontProcess(&PSN))
+ [NSApplication sharedApplication];
+ }
+#endif /* SDL_USE_CPS */
+
+ /* Set up the menubar */
+ [NSApp setMainMenu:[[NSMenu alloc] init]];
+ setApplicationMenu();
+ setupWindowMenu();
+
+ /* Create SDLMain and make it the app delegate */
+ sdlMain = [[SDLMain alloc] init];
+ [NSApp setDelegate:sdlMain];
+
+ /* Start the main event loop */
+ [NSApp run];
+
+ [sdlMain release];
+ [pool release];
+}
+
+#endif
+
+
+/*
+ * Catch document open requests...this lets us notice files when the app
+ * was launched by double-clicking a document, or when a document was
+ * dragged/dropped on the app's icon. You need to have a
+ * CFBundleDocumentsType section in your Info.plist to get this message,
+ * apparently.
+ *
+ * Files are added to gArgv, so to the app, they'll look like command line
+ * arguments. Previously, apps launched from the finder had nothing but
+ * an argv[0].
+ *
+ * This message may be received multiple times to open several docs on launch.
+ *
+ * This message is ignored once the app's mainline has been called.
+ */
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+{
+ const char *temparg;
+ size_t arglen;
+ char *arg;
+ char **newargv;
+
+ if (!gFinderLaunch) /* MacOS is passing command line args. */
+ return FALSE;
+
+ if (gCalledAppMainline) /* app has started, ignore this document. */
+ return FALSE;
+
+ temparg = [filename UTF8String];
+ arglen = SDL_strlen(temparg) + 1;
+ arg = (char *) SDL_malloc(arglen);
+ if (arg == NULL)
+ return FALSE;
+
+ newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
+ if (newargv == NULL)
+ {
+ SDL_free(arg);
+ return FALSE;
+ }
+ gArgv = newargv;
+
+ SDL_strlcpy(arg, temparg, arglen);
+ gArgv[gArgc++] = arg;
+ gArgv[gArgc] = NULL;
+ return TRUE;
+}
+
+
+/* Called when the internal event loop has just started running */
+- (void) applicationDidFinishLaunching: (NSNotification *) note
+{
+ int status;
+
+ /* Set the working directory to the .app's parent directory */
+ [self setupWorkingDirectory:gFinderLaunch];
+
+#if SDL_USE_NIB_FILE
+ /* Set the main menu to contain the real app name instead of "SDL App" */
+ [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
+#endif
+
+ /* Hand off to main application code */
+ gCalledAppMainline = TRUE;
+ status = SDL_main (gArgc, gArgv);
+
+ /* We're done, thank you for playing */
+ exit(status);
+}
+@end
+
+
+@implementation NSString (ReplaceSubString)
+
+- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
+{
+ unsigned int bufferSize;
+ unsigned int selfLen = [self length];
+ unsigned int aStringLen = [aString length];
+ unichar *buffer;
+ NSRange localRange;
+ NSString *result;
+
+ bufferSize = selfLen + aStringLen - aRange.length;
+ buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
+
+ /* Get first part into buffer */
+ localRange.location = 0;
+ localRange.length = aRange.location;
+ [self getCharacters:buffer range:localRange];
+
+ /* Get middle part into buffer */
+ localRange.location = 0;
+ localRange.length = aStringLen;
+ [aString getCharacters:(buffer+aRange.location) range:localRange];
+
+ /* Get last part into buffer */
+ localRange.location = aRange.location + aRange.length;
+ localRange.length = selfLen - localRange.location;
+ [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
+
+ /* Build output string */
+ result = [NSString stringWithCharacters:buffer length:bufferSize];
+
+ NSDeallocateMemoryPages(buffer, bufferSize);
+
+ return result;
+}
+
+@end
+
+
+
+#ifdef main
+# undef main
+#endif
+
+
+/* Main entry point to executable - should *not* be SDL_main! */
+int main (int argc, char **argv)
+{
+ /* Copy the arguments into a global variable */
+ /* This is passed if we are launched by double-clicking */
+ if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
+ gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
+ gArgv[0] = argv[0];
+ gArgv[1] = NULL;
+ gArgc = 1;
+ gFinderLaunch = YES;
+ } else {
+ int i;
+ gArgc = argc;
+ gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
+ for (i = 0; i <= argc; i++)
+ gArgv[i] = argv[i];
+ gFinderLaunch = NO;
+ }
+
+#if SDL_USE_NIB_FILE
+ NSApplicationMain (argc, argv);
+#else
+ CustomApplicationMain (argc, argv);
+#endif
+ return 0;
+}
+
#include "program.h"
#include <vector>
#include <string.h>
+#include <stdio.h>
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
using namespace std;
}
while (token != NULL);
- char ** arguments = new char*[args.size()+2];
- for (unsigned int i=0; i < args.size(); ++i)
- arguments[i] = args[i];
-
+ char ** arguments = NULL;
+ if (args.size() > 0)
+ {
+ arguments = new char*[args.size()];
+ for (unsigned int i=0; i < args.size(); ++i)
+ arguments[i] = args[i];
+ }
//See if file exists and is executable...
if (access(executablePath, X_OK) != 0)
{
if (access(executablePath, X_OK) == 0) //Check we STILL have permissions to start the file
+ {
execv(executablePath,arguments); ///Replace process with desired executable
-
+ }
+ perror("execv error:\n");
fprintf(stderr, "Program::Program - Could not run program \"%s\"!\n", executablePath);
exit(EXIT_FAILURE); //We will probably have to terminate the whole program if this happens
}
if (!Running() || timeout == 0)
return false;
+ struct timeval tv;
+ fd_set readfds;
+
+ tv.tv_sec = (int)(timeout);
+ tv.tv_usec = (timeout - (double)((int)timeout)) * 1000000;
+
+ int fd = fileno(input);
+
+ FD_ZERO(&readfds);
+ FD_SET(fd, &readfds);
+
+ select(fd+1, &readfds, NULL, NULL, &tv);
+
+ if (!FD_ISSET(fd, &readfds))
+ return false; //Timed out
+ //fprintf(stderr, "Got message!\n");
+ for (char c = fgetc(input); c != '\n' && (int)(c) != EOF; c = fgetc(input))
+ {
+ //fprintf(stderr, "%c", c);
+ buffer += c;
+ }
+ //fprintf(stderr, "%s\n", buffer.c_str());
+ return true;
+
+ /* Old way, using threads, which apparently is terrible
assert(&buffer != NULL);
GetterThread getterThread(input, buffer);
assert(&(getterThread.buffer) != NULL);
if (buffer.size() == 1 && buffer[0] == EOF)
return false;
return true;
-
+ */
}
switch (colour)
{
case RED:
- return Graphics::Colour(1,0,0);
+ return Graphics::Colour(1.0,0,0);
break;
case BLUE:
- return Graphics::Colour(0,0,1);
+ #ifdef __MACOSX__ //Horrible HACK to make pieces green on Mac OSX, because Blue doesn't exist on this operating system.
+ return Graphics::Colour(0,1.0,0);
+ #else
+ return Graphics::Colour(0,0,1.0);
+ #endif //__MACOSX__
break;
case NONE:
return Graphics::Colour(0.5,0.5,0.5);
set term png size 640,480
set output "scores.png"
-set xtics 1
-set ytics 1
+#set xtics 1
+#set ytics 1
set xrange [1:]
set xlabel "Games Played"
set ylabel "Score"
#Score dictionary - Tuple is of the form: (end score, other score, other result) where end is the player on whose turn the result occurs, other is the other player, other result indicates what to record the outcome as for the other player.
-scores = {"VICTORY":(3,1, "DEFEAT"), "DEFEAT":(1,3, "VICTORY"), "SURRENDER":(1,3, "VICTORY"), "DRAW":(2,2, "DRAW"), "DRAW_DEFAULT":(1,1, "DRAW_DEFAULT"), "ILLEGAL":(-1,2, "DEFAULT"), "DEFAULT":(2,-1, "ILLEGAL"), "BOTH_ILLEGAL":(-1,-1, "BOTH_ILLEGAL"), "INTERNAL_ERROR":(0,0, "INTERNAL_ERROR"), "BAD_SETUP":(0,0,"BAD_SETUP")}
+scores = {"VICTORY":(3,1, "DEFEAT"), "DEFEAT":(1,3, "VICTORY"), "SURRENDER":(0,3, "VICTORY"), "DRAW":(2,2, "DRAW"), "DRAW_DEFAULT":(1,1, "DRAW_DEFAULT"), "ILLEGAL":(-1,2, "DEFAULT"), "DEFAULT":(2,-1, "ILLEGAL"), "BOTH_ILLEGAL":(-1,-1, "BOTH_ILLEGAL"), "INTERNAL_ERROR":(0,0, "INTERNAL_ERROR"), "BAD_SETUP":(0,0,"BAD_SETUP")}
#Verbose - print lots of useless stuff about what you are doing (kind of like matches talking on irc...)
set term png size 640,480
set output "[NAME].png"
-set xtics 1
-set ytics 1
+#set xtics 1
+#set ytics 1
set xrange [1:]
set xlabel "Games Played"
set ylabel "Score"
GAME RULES
- Each player controls up to 40 pieces on the Board. The pieces are represented by the following characters:
+ Each player controls 40 pieces on the Board. The pieces are represented by the following characters:
Piece Name Rank Number Abilities
1 Marshal 1 1 Dies if attacked by Spy
Pieces may only move one square horizontally or vertically unless otherwise stated.
Pieces may not move through squares occupied by allied pieces, or Obstacle (+) pieces.
Pieces may move into squares occupied by Enemy Pieces (#), in which case the piece with the lower rank (higher number) is destroyed.
+ If the moved piece (attacker) has the lower rank, the stationary piece (defender) does _not_ move into the attacker's square.
Each player's pieces are hidden from the other player. When two pieces encounter each other, the ranks will be revealed.
The objective is to either destroy all enemy pieces except the Bombs and Flag, or to capture the Flag.
- Since 20/12 Bombs reflect the traditional rules; they are only destroyed by Miners.
+ Since 20/12/2011 Bombs reflect the traditional rules; they are only destroyed by Miners.
In previous versions contact of an attacker other than a Miner with a Bomb destroyed the Bomb as well as the attacking piece.
+
+ Since 9/04/2012 An AI must place ALL 40 pieces listed above, or its setup will be declared illegal
- ATTACKER_RANK and DEFENDER_RANK are the ranks of the attacking and defending piece respectively
- The moved piece attacked an opponent piece, and both pieces were destroyed: "BOTHDIE $ATTACKER_RANK $DEFENDER_RANK"
- ATTACKER_RANK and DEFENDER_RANK are the ranks of the attacking and defending piece respectively
+ - Game ended due to the attacker capturing a flag: "VICTORY_FLAG"
+ - Game ended due to the destruction of a player's last mobile piece (either attacker or defender): "
ROW1 -> ROW10 - The state of the board will be printed
- Each line represents a row on the board, from the top downwards
---------------------------------------------------
Synopsis:
---------------------------------------------------
- >> QUIT [RESULT]
+ >> QUIT [$RESULT]
---------------------------------------------------
Explanation:
---------------------------------------------------
Human players are not subject to the timeout restriction.
---------------------------------------------------
Please see the information on the -T switch, and the "End Game" section above.
+
+ 5. Resignation
+ ---------------------------------------------------
+ Description:
+ ---------------------------------------------------
+ Instead of making a move, an AI program may resign.
+ ---------------------------------------------------
+ Synopsis:
+ ---------------------------------------------------
+ << SURRENDER
+ >> QUIT SURRENDER
+ ---------------------------------------------------
+ Explanation:
+ ---------------------------------------------------
+ ---------------------------------------------------
EXIT/OUTPUT
irc://irc.ucc.asn.au #progcomp
THIS PAGE LAST UPDATED
- 3/03/12 by Sam Moore
+ 09/04/12 by Sam Moore
<body>
-<h1> Quick Details</h1>
-<h2> git </h2>
-<p> The git repository is listed on <a href="http://git.ucc.asn.au/"/>The UCC git page</a> as "progcomp2012.git" </p>
-<p> <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>Direct Link Here</a></p>
+ <h1> UCC::Progcomp 2012 </h1>
+ <p> <b> Note: </b> This page has been updated to minimise frustration. </p>
+
+
+ <p> First, login to a linux clubroom machine, that actually works. Machines to avoid include all of them. </p>
+ <p> Next, open a terminal and do this: </p>
+ <ol>
+ <li> ssh -X motsugo </li>
+ <li> cd /away/ucc/username </li>
+ <li> git clone git://git.ucc.asn.au/progcomp2012.git </li>
+ <li> cd progcomp2012/judge/manager </li>
+ <li> ./stratego -g -b @human ../../agents/vixen/vixen.py </li>
+ </ol>
+ <p> Now play a game. </p>
+ <p> Now: </p>
+ <ol>
+ <li> mkdir ../../agents/my_ai </li>
+ <li> cp ../../agents/basic_python/* ../../agents/my_ai/ </li>
+ <li> mv ../../agents/my_ai/basic_python.py ../../agents/my_ai/my_ai.py </li>
+ </ol>
+ <p> Now, open gedit, and open the file "progcomp2012/agents/my_ai/my_ai.py </p>
+ <p> Write an AI. Test it with: "./stratego -g -b @human ../../agents/my_ai/my_ai.py" </p>
+ <p> Also test with "./stratego -g ../../agents/my_ai/my_ai.py ../../agents/vixen/vixen.py" </p>
+ <p> Keep doing this until you win. </p>
+
+ <h1> DO NOT </h1>
+ <ol>
+ <li> Attempt to use Windows </li>
+ <li> Attempt to compile the manager program for Mac </li>
+ <li> Attempt to compile the manager program for Windows </li>
+ <li> Attempt to get OpenGL working on any computer. </li>
+ <li> Attempt to get SDL working on any computer. </li>
+ <li> Attempt to implement the protocol from scratch unless your name is John Hodge. </li>
+ </ol>
+
+ <h3> More information: </h3>
+ <p> Visit the <a href = oldindex.html>old page</a> </p>
-<h2> Mailing List </h2>
-<p> We will use the same mailing list as last year (<a href="http://lists.ucc.gu.uwa.edu.au/mailman/listinfo/progcomp"/>progcomp</a>). </p>
-
-<h2> irc channel </h2>
-<p> There is a #progcomp irc channel on the ucc irc server (irc.ucc.asn.au) where you can ask questions, and someone might even answer them! </p>
-
-<h1> Stratego </h1>
-<p> <a href="http://www.edcollins.com/stratego/"/>This site</a> explains what Stratego is. </p>
-
-<h1> Programming Competition </h1>
-<p> Create an AI to play Stratego. </p>
-<p> Programs are written independently and interface through stdin/stdout with a manager program, which queries them on setup and moves. </p>
-
-<h3> The Manager Program </h3>
-<p> The manager program provides the protocol for two seperate AI to play a game of stratego. It has the imaginative name of 'stratego', but I will probably refer to it as 'the manager program' or 'stratego' with absolutely no consistency. </p>
-<p> It also aims to assist with AI design by providing options for graphical or terminal output and saving/reading games from files </p>
-<p> </p>
-<p> Human players are also supported, although the interface is minimal, as this feature is meant for testing. </p>
-<p> If you just want to play a game, without having to write your own AI, try <a href="http://www.probe.imersatz.com/"/>Probe</a> </p>
-
-<h4> Windows Support </h4>
-<p> Windows is not supported at this stage. </p>
-<p> Why? Because windows doesn't have fork, or pthread, which I used to write the program because they work on linux, and I use debian. </p>
-
-<h4> Bug reports </h4>
-<p> Please report bugs to matches@ with a detailed description, and if possible, the output of gdb, valgrind, or both :) </p>
-<h5> Known Bugs </h5>
-<ol>
- <li> Ash reported a segfault upon every program start, running under Ubuntu. I can't replicate this bug, and don't have any other information. </li>
-</ol>
-
-<h4> Screenshot </h4>
-<img border="0" src="screenshot.png" alt="Graphical output of 'stratego' manager program." title="Graphical output of 'stratego' manager program. Options '-g' for graphics and '-b' to hide Blue pieces that have not taken part in combat yet. Red and Blue are both linked to the 'asmodeus' AI. Taken with scrot on 7/12/11." width="327" height="344" />
-
-<h3> Protocol </h3>
-<p> For the sake of simplicity and keeping things in one place, the protocol is now entirely described in the <a href="doc/manager_manual.txt"/>manual page</a> of the manager program. All updates to the protocol will be reflected in that file. </p>
-
-<p> Major updates to the manager program or protocol will be accompanied by an email to the mailing list. However, it is probably a good idea to clone the git repository, and regularly pull from it. </p>
-
-<p> <b> Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>
-
-<h2> Scoring and Results </h2>
-<p> The competition will be a round robin, with every AI playing six (6) games against each possible opponent. A points system is used to score each AI, 3 points for a Win, 2 for a Draw, 1 for a Loss or -1 for an Illegal response (counts as a Win for the opponent). </p>
-<p> The winning AI will be the AI with the highest score after all games have been played. In the event of a tied score, the two highest scoring AI's will play one more round consisting of three games. If the scores are still tied, the official outcome will be a Draw. </p>
-<p> When the competition officially runs, results will appear <a href="results"/>here</a>. There may (or may not) be test results there now. </p> <p>
-
-<h2> Rounds and Events </h2>
-<ul>
- <li> 10th March 2012 - Progcomp Day - Sam will be in the UCC clubroom to explain stuff and help people </li>
- <li> ?? - Preliminary Round 1 - Gives entrants a chance to test their AI against others. Not worth any points. </li>
- <li> ?? - Preliminary Round 2 - Scores less than 0 are not counted. Scores above 0 are weighted by 0.1 </li>
- <li> 14th May 2012 - Round 1 - The main event. </li>
- <li> ?? - Winner and prize announcement - The creator of the AI with the highest score is the winner </li>
-</ul>
-
-<h2> Sample AI Programs </h2>
-<p> Several sample AI programs are currently available. The sample programs can be downloaded from the <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository </a>
-<p> <b> Warning: </b> No guarantees are provided about the functioning of these programs. It is your own responsibility to ensure that your submission obeys the protocol correctly. If you have based your program off a sample, please double check that it obeys the protocol. </p>
-<h2> Submissions </h2>
-<p> You must submit the full source code, and build instructions or makefile(s) for your program. </p>
-<p> Also include the name of the executable or script, the name of the AI, your name, and optionally a description of your AI and its tactics. </p>
-<p> Please email matches@ if you have a submission. </p>
-<p> <b> Code which attempts to comprimise the host machine, or interfere either directly or indirectly with the functioning of other programs will be disqualified. </b> </p>
-
-<h2> Dates </h2>
-<p> The competition is now officially open. Submissions will be accepted until midday, Monday the 14th of May, 2012. Results will be announced as soon as they are available (depending on the number of entries it may take several days to simulate the competition). </p>
-
-<h2> Clarifications </h2>
-<ul>
- <li> We are using the newer rules described <a href="http://www.edcollins.com/stratego/stratego-rules-later.htm"/>here</a>. </li>
- <li> Scouts may move multiple spaces and attack in the same turn (in some versions they cannot). </li>
- <li> Bombs remain in place until destroyed by a Miner (some versions incorporate "single-use" Bombs). </li>
- <li> Victory is possible by either capturing the enemy Flag, or destroying all mobile enemy pieces.
- AI programs do not have to "surrender" (as stated in the rules) if they have no mobile pieces. The manager program should end the game (if it does not, please report the bug)! </li>
- <li> The newest versions of the physical board game reverse the numbers of the ranks (10 is the Marshal, 1 is the Spy). Our system uses the original numbering (1 is the Marshal, 9 is the Scout and s is the Spy). </li>
-
- <li> You must always make a move. </li>
- <li> <b>Remember to unbuffer stdin/stdout!</b> </li>
-</ul>
-
-<h2> Questions? </h2>
-<p> <a href="faq.html"/>Frequently Asked Questions</a> </p>
-<p> Please email matches@ or post to #progcomp with any questions not on that page. </p>
-<p> <b>Last webpage update: 03/02/12</b></p>
</body>
-</html>
+<html>
--- /dev/null
+<html>
+<head>
+ <title>Stratego Based Programming Competition</title>
+</head>
+
+<body>
+
+<h1> Quick Details</h1>
+<h2> git </h2>
+<p> The git repository is listed on <a href="http://git.ucc.asn.au/"/>The UCC git page</a> as "progcomp2012.git" </p>
+<p> <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>Direct Link Here</a></p>
+
+<h2> Mailing List </h2>
+<p> We will use the same mailing list as last year (<a href="http://lists.ucc.gu.uwa.edu.au/mailman/listinfo/progcomp"/>progcomp</a>). </p>
+
+<h2> irc channel </h2>
+<p> There is a #progcomp irc channel on the ucc irc server (irc.ucc.asn.au) where you can ask questions, and someone might even answer them! </p>
+
+<h1> Stratego </h1>
+<p> <a href="http://www.edcollins.com/stratego/"/>This site</a> explains what Stratego is. </p>
+
+<h1> Programming Competition </h1>
+<p> Create an AI to play Stratego. </p>
+<p> Programs are written independently and interface through stdin/stdout with a manager program, which queries them on setup and moves. </p>
+
+<h3> The Manager Program </h3>
+<p> The manager program provides the protocol for two seperate AI to play a game of stratego. It has the imaginative name of 'stratego', but I will probably refer to it as 'the manager program' or 'stratego' with absolutely no consistency. </p>
+<p> It also aims to assist with AI design by providing options for graphical or terminal output and saving/reading games from files </p>
+<p> </p>
+<p> Human players are also supported, although the interface is minimal, as this feature is meant for testing. </p>
+<p> If you just want to play a game, without having to write your own AI, try <a href="http://www.probe.imersatz.com/"/>Probe</a> </p>
+
+<h4> Windows Support </h4>
+<p> Windows is not supported at this stage. </p>
+<p> Why? Because windows doesn't have fork, or pthread, which I used to write the program because they work on linux, and I use debian. </p>
+
+<h4> Bug reports </h4>
+<p> Please report bugs to matches@ with a detailed description, and if possible, the output of gdb, valgrind, or both :) </p>
+<h5> Known Bugs </h5>
+<ol>
+ <li> Ash reported a segfault upon every program start, running under Ubuntu. I can't replicate this bug, and don't have any other information. </li>
+</ol>
+
+<h4> Screenshot </h4>
+<img border="0" src="screenshot.png" alt="Graphical output of 'stratego' manager program." title="Graphical output of 'stratego' manager program. Options '-g' for graphics and '-b' to hide Blue pieces that have not taken part in combat yet. Red and Blue are both linked to the 'asmodeus' AI. Taken with scrot on 7/12/11." width="327" height="344" />
+
+<h3> Protocol </h3>
+<p> For the sake of simplicity and keeping things in one place, the protocol is now entirely described in the <a href="doc/manager_manual.txt"/>manual page</a> of the manager program. All updates to the protocol will be reflected in that file. </p>
+
+<p> Major updates to the manager program or protocol will be accompanied by an email to the mailing list. However, it is probably a good idea to clone the git repository, and regularly pull from it. </p>
+
+<p> <b> Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>
+
+<h2> Scoring and Results </h2>
+<p> The competition will be a round robin, with every AI playing six (6) games against each possible opponent. A points system is used to score each AI, 3 points for a Win, 2 for a Draw, 1 for a Loss or -1 for an Illegal response (counts as a Win for the opponent). </p>
+<p> The winning AI will be the AI with the highest score after all games have been played. In the event of a tied score, the two highest scoring AI's will play one more round consisting of three games. If the scores are still tied, the official outcome will be a Draw. </p>
+<p> When the competition officially runs, results will appear <a href="results"/>here</a>. There may (or may not) be test results there now. </p> <p>
+
+<h2> Rounds and Events </h2>
+<ul>
+ <li> 10th March 2012 - Progcomp Day - Sam will be in the UCC clubroom to explain stuff and help people </li>
+ <li> 28th April 2012 - Preliminary Round 1 </li>
+ <li> 5th May 2012 - Preliminary Round 2</li>
+ <li> 14th May 2012 - Finals - The main event. </li>
+ <li> ?? - Winner and prize announcement - The creator of the AI with the highest score is the winner </li>
+</ul>
+<p> The scores for the preliminary rounds will contribute to 10% (each) of the final score. Scores less than zero in the preliminary rounds will not be counted. </p>
+<p> The finals will be worth the remaining 80% of the scores. </p>
+<p> Check out <a href="http://www.ucc.asn.au/infobase/events/"/>The UCC Events Page</a> where this and other interesting things are listed! </p>
+
+<h2> Sample AI Programs </h2>
+<p> Several sample AI programs are currently available. The sample programs can be downloaded from the <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository </a>
+<p> <b> Warning: </b> No guarantees are provided about the functioning of these programs. It is your own responsibility to ensure that your submission obeys the protocol correctly. If you have based your program off a sample, please double check that it obeys the protocol. </p>
+<h2> Submissions </h2>
+<p> You must submit the full source code, and build instructions or makefile(s) for your program. </p>
+<p> Also include the name of the executable or script, the name of the AI, your name, and optionally a description of your AI and its tactics. </p>
+<p> Please email matches@ if you have a submission. </p>
+<p> <b> Code which attempts to comprimise the host machine, or interfere either directly or indirectly with the functioning of other programs will be disqualified. </b> </p>
+
+<h2> Dates </h2>
+<p> The competition is now officially open. Submissions will be accepted until midday, Monday the 14th of May, 2012. Results will be announced as soon as they are available (depending on the number of entries it may take several days to simulate the competition). </p>
+
+<h2> Clarifications </h2>
+<ul>
+ <li> We are using the newer rules described <a href="http://www.edcollins.com/stratego/stratego-rules-later.htm"/>here</a>. </li>
+ <li> When a piece "attacks" an enemy piece by moving onto its square, and is defeated, the defending piece will not move into the attacker's square. </li>
+ <li> Scouts may move multiple spaces and attack in the same turn (in some versions they cannot). </li>
+ <li> Bombs remain in place until destroyed by a Miner (some versions incorporate "single-use" Bombs). </li>
+ <li> Victory is possible by either capturing the enemy Flag, or destroying all mobile enemy pieces.
+ AI programs do not have to "surrender" (as stated in the rules) if they have no mobile pieces. The manager program should end the game (if it does not, please report the bug)! </li>
+ <li> The newest versions of the physical board game reverse the numbers of the ranks (10 is the Marshal, 1 is the Spy). Our system uses the original numbering (1 is the Marshal, 9 is the Scout and s is the Spy). </li>
+
+ <li> You must always make a move. </li>
+ <li> You can surrender with "SURRENDER" </li>
+ <li> <b>Remember to unbuffer stdin/stdout!</b> </li>
+</ul>
+
+<h2> Questions? </h2>
+<p> <a href="faq.html"/>Frequently Asked Questions</a> </p>
+<p> Please email matches@ or post to #progcomp with any questions not on that page. </p>
+<p> <b>Last webpage update: 09/04/12</b></p>
+</body>
+
+</html>