Archive for October, 2008

Ants Intro

Friday, October 10th, 2008

Inspired by the brave explorers that found their way into my kitchen via means unknown, I’ve been working on a simulation of ants with their actions being based on the pheremone trails they leave behind. Given that I could represent their decision making process with a simple table of values, I decided to use a genetic algorithm to refine the values over successive generations and attempt to breed better and better ants. I wrote up an initial design before I began coding, although I found some issues with it and have strayed somewhat as time has gone by.

As of writing this, I have covered most of the basic functionality necessary to prove the function of the simulator to myself. I have ants that run around and bring food back home, I use a version of a genetic algorithm to make future generations better than prior ones, and I have a visualizer that lets me see how the ants move and how the pheremones are distributed.

Speed is an issue, and it is a limiting factor in running larger simulations and having multiple teams of ants fight one another. In the name of making things run faster, I’m probably going to have to greatly simplify or entirely remove the code for diffusing pheremones across the map. More on this once I come up with a solution, but my initial method required touching every cell on the map 9 times, which just won’t do when I’m trying to run hundreds of thousands of iterations in a timely manner.

So as to provide historical context, I will link to the current revision of the repository. Several aspects of the code have grown beyond my original plans for them and everything needs a bit of a cleanup. As I address the deficiencies of various features I plan to write up the changes I made here.

Project Creation

Sunday, October 5th, 2008

After making a few tracs and subversion repos by hand and having to do all the little things that need setting up to make things run smoothly (remembering to give svn trunk/tags/branches directories, setting up trac authentication, etc.), I decided to make a little shell script to do most of it for me.

The script I wrote takes a name as its argument and makes a trac and a repository using that name and makes a linked pair with all the bits set the way I need them in my environment for basic functionality. The repository is accessible to anyone in group dev, and I am the only admin on the trac.

#!/bin/bash
 
if [ $# != 1 ]; then
    echo "Usage: $0 <project name>"
    exit 1
fi
 
PROJ=$1
SVNPATH=/var/svn/$PROJ
TRACPATH=/var/trac/$PROJ
 
echo "About to create svn/trac for project $PROJ."
echo "    svn: $SVNPATH"
echo "    trac: $TRACPATH"
echo "Press Ctrl-C to abort."
sleep 5
 
svnadmin create $SVNPATH
 
chown -R root:dev $SVNPATH
chmod -R g+ws $SVNPATH
 
svn mkdir -m "Directory layout" file://$SVNPATH/trunk file://$SVNPATH/branches file://$SVNPATH/tags
 
# initenv <projectname> <db> <repostype> <repospath>
trac-admin $TRACPATH initenv $PROJ sqlite:db/trac.db svn $SVNPATH
 
 
chmod g+w $TRACPATH/db
chmod g+w $TRACPATH/db/trac.db
 
cat >> $TRACPATH/conf/trac.ini <<EOF
[components]
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
trac.web.auth.loginmodule = disabled
 
[account-manager]
authentication_url = http://projects.ghostlords.com/login
password_file = /var/trac/htpasswd
password_store = HtPasswdStore
EOF
 
trac-admin $TRACPATH permission add jonathan TRAC_ADMIN

Things I might like to fix someday:

  1. I create duplicate sections in the trac.ini, although it appears to parse them OK.
  2. I’d like it to put a link on the wiki start page with the URL to the repository.