Here’s the updated cgos.rb script. The main change is that the bots are chosen at random (instead of in the order specified).
#!/usr/bin/env ruby## Run bots one after the other on CGOS. The BOTS variable is an array# if directories of the bots. In each of these directory there has to# be an executable file called 'cgos.sh' that connects the bot to CGOS.# This executable is also required to set the sentinel file name to the# one given in the TERM variable below.require'optparse'# :bot :: The directory containing you cgos connection script# :script :: The name of the script (defaults to cgos.sh)# :games :: The number of games the bot should play in a rowBOTS=[{:bot=>"libEGO-AMAF-3"},{:bot=>"libEGO-AMAF-2"},{:bot=>"erlygo"},{:bot=>"libEGO-AMAF-2",:script=>"cgos19.sh"},{:bot=>"libEGO-AMAF-3",:script=>"cgos19.sh"},{:bot=>"erlygo",:script=>"cgos19.sh"}]# Sentinel filename to be used by CGOSTERM="stop.txt"$verbose=falseround=0total_games=0games=Hash.new{|h,k|h[k]=0}opts=OptionParser.newopts.on("-v","--verbose"){$verbose=true}opts.on("-s","--stop")doFile.new(TERM,"w")exitendopts.parse(ARGV)deftimeTime.now.strftime("%H:%M:%S")end# Clean up (if script wasn't terminated correctly)(BOTS+[{:bot=>"."}]).eachdo|bot|bot[:games]=1unlessbot[:games]bot[:script]="cgos.sh"unlessbot[:script]Dir.chdir(bot[:bot])doFile.delete(TERM)ifFile.exists?(TERM)endenduntil(File.exists?(TERM))round+=1if(round%5).zero?games.eachdo|k,v|puts"#{sprintf("%03d",v)} games for '#{k}'"endendbot=BOTS[rand(BOTS.length)]msg="[#{time}] Running '#{bot[:bot]}' (#{bot[:script]})"msg+=" for #{bot[:games]} games"putsmsglast_was_print=falseDir.chdir(bot[:bot])doIO.popen("./#{bot[:script]} 2>/dev/null")do|pipe|until(pipe.eof?)line=pipe.getsif$verboseputslineSTDOUT.flushendcaselinewhen /gameover/line=~/gameover\s+\d\d\d\d-\d\d-\d\d\s+(\S+)/print"\n"iflast_was_printputs"[#{time}] #{$1}"last_was_print=falsewhen /setup/File.new(TERM,"w")ifgames[bot[:bot]]>=(bot[:games]-1)games[bot[:bot]]+=1total_games+=1line=~/setup\s+.*?(\S+\(.*\)\s+\S+\(.*\))/print"\n"iflast_was_printstats="(game #{games[bot[:bot]]} of #{bot[:games]},"stats+="#{total_games} games in total)"puts"[#{time}] #{$1}#{stats}"last_was_print=falsewhen /info/unless$verboseprint"."STDOUT.flushlast_was_print=trueendendendendFile.delete(TERM)ifFile.exists?(TERM)endround+=1endFile.delete(TERM)
While playing around with libEGO and trying to see how far I can get with a simple “all-moves-as-first” Monte Carlo bot. I wrote many (well, three) different versions of the same bot and tested them against each other. Of course for a real test I had to use CGOS. But as I only have one computer that I also use for work I had to run the different bots one after the other. To automate that I wrote a small script that lets you run any number of bots in rotation on CGOS.
It’s a very simple script written in Ruby, so you’ll need to have that installed. For the rest see the comments at the beginning of the file.
#!/usr/bin/env ruby## Run bots one after the other on CGOS. The BOTS variable is an array# if directories of the bots. In each of these directory there has to# be an executable file called 'cgos.sh' that connects the bot to CGOS.# This executable is also required to set the sentinel file name to the# one given in the TERM variable below.# Number of games for each botGAMES=1# The bots that should playBOTS=["libEGO-AMAF","libEGO-AMAF-2","libEGO-AMAF-3"]# Sentinel filename to be used by CGOSTERM="stop.txt"round=0ifARGV.length>0andARGV.first=="stop"File.new(TERM,"w")exitend# Clean up (if script wasn't terminated correctly)(BOTS+["."]).eachdo|dir|Dir.chdirdoFile.delete(TERM)ifFile.exists?(TERM)endenduntil(File.exists?(TERM))dir=BOTS[round%BOTS.length]puts"[#{Time.now}] Round #{round+1}"puts"[#{Time.now}] Running '#{dir}' for #{GAMES} games"last_was_print=falseDir.chdir(dir)dogames=0IO.popen('./cgos.sh 2>/dev/null')do|pipe|until(pipe.eof?)line=pipe.getsifline=~/setup/games+=1File.new(TERM,"w")ifgames>=(GAMES-1)endcaselinewhen /gameover/line=~/gameover\s+\d\d\d\d-\d\d-\d\d\s+(\S+)/print"\n"iflast_was_printputs"[#{Time.now}] #{$1}"last_was_print=falsewhen /setup/line=~/setup\s+.*?(\S+\(.*\)\s+\S+\(.*\))/print"\n"iflast_was_printputs"[#{Time.now}] #{$1}"last_was_print=falsewhen /info/print"."STDOUT.flushlast_was_print=trueendendendFile.delete(TERM)endround+=1endFile.delete(TERM)
As Stephan Kämper already announced on his blog the European Ruby Konferenz will be held in Vienna, Austria on Saturday & Sunday 10th and 11th November 2007.
If you want to attend just add yourself to the wiki!
Vielleicht etwas spät, aber besser als nie. Ich bin gerade auf ein Blog Post von Frank Wettert gestoßen, der dazu auffordert ein Exemplar des Grundgesetzes an Wolfgang Schäuble zu schicken. Recht hat er. Meine Exemplare (3 Exemplare kostenlos vom Deutschen Bundestag zu erhalten) sind schon unterwegs. Sobald eure Exemplare bei euch angekommen sind bitte eines der Exemplare (vielleicht mit einem erklärenden Brief dazu) an folgende Adresse schicken:
Herr Dr. Wolfgang Schäuble
Bundesministerium des Innern
Alt-Moabit 101
D-10559 Berlin
Vielleicht hilft es ja seinen Überwachungswahn zu stoppen. Einen Versuch ist es zumindest wert.
I just tried to setup lighttpd (1.4.13) to run several sites side by side and run one of them on a different port. The following things should be noted:
server.prot
You can’t just set server.port. It’s a global variable a overwrites the previous ones.
$SERVER[“socket”] and $HTTP[“host”]
Using $SERVER["socket"] and $HTTP["host"] together doesn’t work. I tried to do the following:
But that doesn’t work! I ended up removing the $HTTP["host"] part. Which is not that nice as you can now access the site on port 5005 using all the other URLs defined in the config file!
I’m a regular listener of IT Conversations. But of course I don’t have the time to listen to all podcasts. And anyway there are many that I don’t even want to listen to. So, IT Conversations has a rating system and can give you recommendations. But for that to work you have to remember to go to their website to rate the shows you have listened to. Very cumbersome if you listen to the shows on your iPod somewhere in the wild. But it seems things might change as Phil Windley is asking if You Would Let IT Conversations See Your Podcast Ratings in iTunes?. Seems like a great idea to get some more out of the recommendation system.
The last weeks I’ve heard some podcasts with Dave Thomas and in passing he mentioned that Joe Armstrong is writing a book on Erlang for them.
I’ve been interested in Erlang for quite a while but didn’t find time to look into it. But now that Dave Thomas (nearly) announced the beta release of their book I’m really exited. Once I find the money for the book I’ll definitely give it a try.
Oh, in case you’re wondering where to find the book just go to Dave’s blog post where he mentions how to find the book. It’s not that hard!
Update (one hour later): Well, I couldn’t wait and ordered it anyway. I just had to capitalize on the strong Euro ;)