So it’s bye bye to Portent.org, my five year old blog on interesting things. I’m not sure what will happen as I’ve sold it, the domain name and the twitter hashtag.
Continuing in a very creative mood, I’ve today setup Writers Q & A, a website for people to post questions and answers on writing and writers. The intention is to have something similar to the programmers Q & A website stackoverflow.com, but for writers.
Although I’m a part time technical writer on About.com, I’ve dabbled with fiction (and sci-fi) writing over the years and really want to develop it more; it’s an itch i have to scratch but it’s in my metaphorical back where I can’t reach it. Writers.im is a small step towards that goal. I figure if I give a little I get a little! So it’s completely free, no ads. It’s an experiment which if it fails costs me very little.
One of the interesting things I’ve been doing there is running the Rock, Scissors and Paper (RSP) contest– it’s free and open to anyone and new players can join anytime between now and Christmas. It’s not the easiest to let developers use all three languages to write bots to play RSP but I managed it.
Each week, every bot in the contest plays every other bot in a 100 hand match. All wins are totalled up and that determines the ranking.
What I did was develop a C# Winforms application that uses a dll for each bot. I’ve done the hard bit and provided a full skeleton dll for C, C++ and C# that anyone can download and flesh out; just fill in the function bodies, the move logic goes in the GetMove() function. I wrote a C# wrapper for the C and C++ bots which wraps the dll calls in a class- it looks like this:
public class bot
public const int botnum = 1;
const string dll = “c:\ongoing\dlls\skeleton1.dll”;
CallingConvention = CallingConvention.Cdecl)]
public static extern string GetBotName(); // returns name of your Bot
CallingConvention = CallingConvention.Cdecl,CharSet=CharSet.Ansi)]
public static extern char
[MarshalAs(UnmanagedType.LPStr)]String S2); // return move
.. others trimmed for shortness
Note the marshalling attributes – the dlls use cdecl, it’s ansi chars (8 bit as C# uses Unicode) and the strings are passed as lpstr. A string in C is just an array of 8 bit chars.
This function GetMove passes in the previous hands (in this match against one bot) so you can see what your bot played and what the opponent played. After each week I publish the results and a file containing all bots moves- eg this was the match between bot 1 and 5. 1 won 29 times, 5 won 33. Below this are the strings which I’ve trimmed to fit this.
1 v 5 29 33
You can see the full file this came from: Week 6 results It’s just a text file, generated by the application.
So if you fancy entering- remember it’s free just follow this link:
Rock, Scissors and Paper Contest