Indiana Poker Programming Contest Computers Playing Poker

21Jun/100

Errors when running bots

I've found out that there have been a few oversights in the "writing a bot" instructions.

Java's classpath

First and foremost, the instructions neglected the importance of setting Java's classpath. As you might already know, Java searches all of the paths in the $CLASSPATH variable for the classes you reference via "import" statements. Importing com.indianapokerbot.bot.PokerClient in NetBeans without also referencing IndianaPokerBot.jar at runtime would cause Java to fail with a message like

bash-3.2$ java -cp MyBot.jar MyBot 127.0.0.1 9001
Exception in thread "main" java.lang.NoClassDefFoundError: com/indianapokerbot/bot/PokerClient
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        ...

Unfortunately, for every level of abstraction beyond that, you'd get less and less helpful messages. Running startme.sh might only give Exception in thread "main" java.lang.NoClassDefFoundError: MyBot. If you ran a match using matchConstructor.py, you might only see this in GlassFrog's log:

user@indiana$ ./run.sh
...
Executing bot command: "/path/to/startme.bat 127.0.0.1 9001" from /path/to/
AAAIPPlayer PLAYERONE hit timeout
Removing Room: MYROOM from active list

which is utterly unhelpful.

We have three solutions:

  1. The simplest thing to do is to add IndianaPokerBot.jar to the classpath at runtime by changing startme.sh to say java -cp "/path/to/IndianaPokerBot.jar;MyBot.jar" MyBot $1 $2.
  2. A potentially more convenient method but more invasive method is to permanently set your system $CLASSPATH variable to include IndianaPokerBot.jar, saving you the effort of adding it to every startme.sh script you write. Adding the line CLASSPATH=$CLASSPATH:/path/to/IndianaPokerBot.jar to ~/.bash_profile would do the trick.
  3. The easiest solution would be to skip the classpath madness altogether and copy the contents of IndianaPokerBot/src/ to your own project's src directory. If you do, you also won't need to set external libraries for your project.

Executable permissions

The instructions also neglected to mention that scripts need to, by nature, be marked as executable or else Unix will refuse to run it. If you see errors like java.io.IOException: Cannot run program ...: error=13, Permission denied, run chmod +x startme.sh on the script and it should work.

The instructions have been updated. If you still have issues, please contact us.

Filed under: Help No Comments
22May/100

2010 Contest Information Now Online

It's here! The rules, software, and documentation you'll need for the 2010 Indiana Poker Programming Contest are now online.  You should probably read the rules first, and then read each of the three parts of the documentation.  The documentation will get you started with using ACPC's poker server and writing your own poker bots.

The Annual Computer Poker Competition server was released only days ago, so it's been a challenge to get it customized and documented for you.  We'll be expanding the amount of sample code and documentation in the next few weeks so that it'll be easier to hit the ground running.  The ACPC software is also very new, so we'll notify you of updates upstream as we hear about them.

We hope that you can get comfortable with the software fairly quickly, leaving you the rest of the summer until August 14 to focus on the logic of the bot itself.  As always, if you have any questions or find any mistakes in our code or documentation, contact us using the contact form and we'll reply quickly.  If you haven't already, sign up for email updates of these announcements using the form on the right-hand menu.

Good luck!