Farmville Bot – The beginning.

I’ve been playing Farmville recently on Facebook. The concept is simple, you plant things then harvest them for experience points and money. You then use the money you made to plow the fields and buy seed to do it all over again.

I’ve seen  some of my friends level really quickly and don’t have time to sit around and play the game all day so I figured it would be an interesting challange to write a bot to play the game for me. In the past I’ve used SCAR Divi in the past to write a bot for Puzzle Pirates so I think I try writing a bot for Farmville and post the results and possible the code.

Update about ‘Error from Debugger: Unknown packet reply: “timeout” to environment packet.’ from Xcode

I previously posted about an error I was seeing in the Xcode console when trying to run an application I was working building on an actual iPhone. I believe I have figured out what was causing the problem, if not at least I’ve managed to make it stop happening so I can go back to testing on a real device now.

It seems that the problem had something to do with a ‘#’ in either ‘#AppName_Prefix.pch’ or ‘#AppName.xcodeproj’. I renamed the Prefix header and the xcodeproject file and updated the project to reflect the new name of the prefix header then a build -> clean and voilà everything seems to be working again.

opensim – Easy access to iPhone Simulator Applications

I’ve been doing some development for the iPhone lately and came across a post by Craig Hockenberry where he give out a nice little bash script to make working with the iPhone simulator easier.

I’ve been using that script for a few months now and have added alot to it and think I should give back. I’ve packaged it up with a nice readme, posted it up on github and released it under the GPL.

Usage:

usage: /Users/trcjr/bin/opensim [ <app_name> | updateLinks <link_dir> [ Preferences | Documents | <cmd> <file> ]
ex: /Users/trcjr/bin/opensim updateLinks ~/iPhoneSimulatorApps
Creats symlinks for all installed apps in ~/iPhoneSimulatorApps
Note: <link_dir> must already exist.
ex: /Users/trcjr/bin/opensim SomeApp Preferences
Opens the Preferences folder
ex: /Users/trcjr/bin/opensim SomeApp Documents
Opens the Documents folder
ex: /Users/trcjr/bin/opensim SomeApp sqlite3 some_sqlite_database.sqlite
Opens runs sqlite3 with the full path to some_sqlite_database.sqlite as its first arguement

The README:

Opensim is a shell script that makes accessing applications on the iPhone
simulator a breeze.

Based on opensim by Craig Hockenberry
http://furbo.org/2009/03/03/open-sesame/

Examples.

opensim SomeApp Preferences
Opens the Preferences folder for SomeApp.
( ~/Library/Application Support/iPhone Simulator/User/Applications/<GUID>/SomeApp.app/Preferences )

opensim SomeApp Documents
Opens the Documents folder for SomeApp
( ~/Library/Application Support/iPhone Simulator/User/Applications/<GUID>/SomeApp.app/Documents )

opensim SomeApp sqlite3 some_sqlite_database.sqlite
Opens runs sqlite3 with the full path to some_sqlite_database.sqlite as its
first argument.
( sqlite3 ~/Library/Application Support/iPhone
Simulator/User/Applications/<GUID>/SomeApp.app/Documents/some_sqlite_database.sqlite )

Note:
If you have more than one file with the same name in two different
directories, ie db.sqlite in Documents/ and db.sqlite in SomeApp.app/
you would need to specify it by doing something like:
opensim SomeApp sqlite3 app/db.sqlite
This would open SomeApp.app/db.sqlite
opensim SomeApp sqlite3 Documents/db.sqlite
This would open SomeApp.app/Documents/db.sqlite

opensim updateLinks ~/iPhoneSimulatorApps
Creats symlinks for all installed apps in ~/iPhoneSimulatorApps
Note: <link_dir> must already exist.

Converting Poker Stars Play Money Logs to Real Money

I wanted to use Poker Tracker to keep track of my stats when playing at the play money tables of Poker Stars. Poker Tracker doesn’t support the play money tables.

I wrote some Perl to convert the the lots from the play money format into the real money format.

#!/usr/bin/perl
use strict;
use Cwd;
use File::Find;
 
my $some_dir = "Z:\\HandHistory";
my $startDir = &Cwd::cwd();
find(\&processFile, $some_dir);
exit;
 
sub processFile {
    shift;
    return if not /\.txt$/;
    my $inFileName = $_;
    my $infile = "$startDir/$File::Find::name";
    my $outfile = "$startDir/outHands/$inFileName.$$.converted.txt";
    open (inFILE, "<$infile") or die "can't open in file!: #$infile# ($!)";
    open (outFILE, ">$outfile") or die "can't open out file!:#$outfile# ($!)";
    my @players;
    while(<inFILE>) {
        chomp;
        @players = () if (s/^(PokerStars Game .*\()(\d+)\/(\d*)(\).*)$/\1\$\2.00\/\$\3.00\4/);
        push(@players, $1) if (/^Seat [\d+]: (.*) \(\d+ in chips\)/);
        foreach my $key (@players) {
            my $value = $key;
            $value =~ s/\s+/_/;
            ($value = $1) =~ s/($1)/_\1/ if ($key =~ /^(\d+)$/);
            s/$key/$value/;
        }
        s/([\( ])(\d+)([\) \.])/\1\$\2.00\3/g;
        s/\(Play Money\) //g;
 
        s/^\s+//;
        s/\s+$//;
        print outFILE "$_\n";
    }
    close(inFILE);
    close(outFILE);
}