Thursday, April 30, 2009

Battle for Wesnoth: Kid-Friendly

artwork from Battle for Wesnoth, modified by JTP

Introduction

Skip intro

The Battle for Wesnoth--consistently ranked at the top of open-source games--is a really extraordinary strategy game that also happens to be free. On the surface it doesn't seem that special: it doesn't feature any stunning graphics and it is turn-based, so it is much more contemplative than action-packed. Why is it so great? Well, you really need to play it a while to understand, but the main things are:
  1. Very interesting strategy component - sort of feels like playing a higher-level Risk game or a slower turn-based Rise of Nations. To win you have to deal effectively with day/night, terrain, attack/defense, recruitment, character development, health etc. There are enough components to keep things interesting but not so many to be overwhelming.
  2. Engaging storylines - compelling single (and even some multi-user) campaigns.
  3. Character development - Characters can be developed somewhat (i.e, raise levels) which provides some familiarity (and hence attachment) to them but this is limited to only a few levels which prevents this aspect from overshadowing the game's strategy component.
  4. Good AI - the computer doesn't really make dumb moves, you either have to outsmart or overpower the enemy to win.
  5. Visually beautiful - I mentioned that the graphics are 2D, but even though they are simple, they are quite engaging. Much of the artwork is really great.
  6. Good music - in a classical-esque tradition.
  7. Free.
  8. Extendable - it isn't very difficult to create your own game or campaign.

Kid-friendly graphics


I have a lot of young boys who happen to really like this game. For a game set in a fantasy world completely realized with community contributed artwork, Wesnoth is remarkably kid-friendly. While there is nothing approaching pornography in it, there are a handful of portraits and units that are not attired as modestly as could be hoped. Most of the ones I've tidied up really didn't need it much, but since I was at it...

The beauty of open-source is that the software (in this case the images) can be modified to suit one's own tastes. I took liberty to touch up a few pictures, trimmed some others and wrote a script that will replace them in one click. The replacement artwork is rough around the edges, but it gets the job done (see my conglomerate image above).

How to run wesnoth-kid-friendly


This assumes you are on Windows (instructions are included in the zip file for other OS's):
  1. Install Battle for Wesnoth - ideally in the default location so my script can find it.
  2. Install the one-click ruby installer. (go the section "Ruby on Windows" and click on the "Ruby One-Click Installer link")
  3. Download my zip file. (this contains kid-friendly up artwork and a script to copy them into place).
  4. Unzip it.
  5. Click on wesnoth-kid-friendly.rb (NOTE: this writes over the old images. Of course, you can always reinstall it if you don't like what I've done)
By default, I scan typical linux and windows directories for a Battle for Wesnoth directory. If the script isn't finding your installation, you can run the program on the commandline with the path to the Wesnoth directory given as the only argument. Or email me with the path of your directory and I'll add it to the script.

Tuesday, April 28, 2009

Keyboard Shortcuts in Gnome, KDE, wmii, or whatever

Ubuntu Jaunty Jackelope put keyboard shortcuts in their proper place (disabling those in metacity and putting them in 'Keyboard Shortcuts'). However, when opening a gnome terminal from this shortcut, you have to explicitly tell it to start in your home directory or it will start in '/'

System->Preferences->KeyboardShortcuts  then [+Add]

gnome-terminal --geometry 80x52 --working-directory $HOME

I like to set up my keyboard shortcuts with a script since I like to use them on whatever computer I'm on. I did this before with gconftool2 and that worked fine, but now a person has to set them in a different location in a different way... which got me thinking that it would be nice to set keyboard shortcuts in a cross-desktop (KDE, Gnome, wmii, whatever) kind of way.

Solution: xbindkeys

sudo apt-get install xbindkeys

Make a file called '.xbindkeysrc' in your home directory with something like this in it:

"gvim"
control+alt + g
"nautilus"
control+alt + n
"firefox -new-window http://gmail.com"
control+alt + e
"nautilus"
control+alt + h
"firefox"
control+alt + f
"gnome-terminal --geometry 80x40"
control+alt + t
"rhythmbox"
control+alt + m

now you can turn on the shortcuts with the simple command 'xbindkeys', but we'd really like for them to be turned on once when we login. Turns out cross-desktop startup is not very uniform but I think the proper way to do this (cross-desktop) is to do this:

Make sure you have a directory called '.config/autostart'. Then add a file to it called 'xbindkeys.desktop' with content along these lines:

[Desktop Entry]
Type=Application
Name=XBindKeys
Exec=xbindkeys
Icon=system-run
Comment=
Name[en_US]=XBindKeys
Comment[en_US]=
X-GNOME-Autostart-enabled=true

This is what happens in Gnome when you add an entry in System->Preferences->StartupApplications.

Tuesday, April 14, 2009

Installing Storey's edge microarray software on Ubuntu

It takes a few steps to install this (Intrepid Ibex, Ubuntu 8.10), but here's how I got it working (we'll see if there are any bugs):

edge website


  1. Install R

  2. sudo aptitude install r-base

  3. Download and unpack the source file:

  4. linux src page
  5. Install impute

  6. Download the above link and install with something like this:
    sudo R CMD INSTALL packages/impute_1.0-5.tar.gz

  7. prepare the compiling environment

  8. sudo aptitude install g++-4.2 gfortran-4.2 tetex-base
    # (also might need tetex-extras ...)
    sudo rm /usr/bin/g++ # just removes the soft link
    sudo ln -s /usr/bin/g++4.2 /usr/bin/g++
    sudo rm /bin/sh # just a link to /bin/dash
    sudo ln -s /bin/bash /bin/sh

  9. Compile the sucker

  10. cd src ; make ; make install

    The make install command just copies the .so files up a directory
  11. Run the software

  12. R

    Then from within R started at the base of the package:
    source("edge.r")
    edge()

  13. Restore the original environment

  14. sudo rm /usr/bin/g++
    sudo ln -s /usr/bin/g++4.3 /usr/bin/g++
    sudo rm /bin/sh
    sudo ln -s /bin/dash /bin/sh

Parametric and non-parametric t-testing

If your data are distributed normally, the t-test can help you determine if the means of your two samples are greater than or less than each other (one-tailed) or just plain different from each other (two-tailed). These examples are for paired samples, to make them not paired just delete the "paired=TRUE" statement altogether, default is unpaired.

We'll use the same data throughout:
x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)

When using your own data you just need them in vectors (as shown).

One-tailed
t.test(x,y,paired=TRUE,alternative="greater")
t.test(x,y,paired=TRUE,alternative="less")

Two-tailed
t.test(x,y,paired=TRUE)

What if your data are not normal? The non-parametric Wilcoxon test will do the trick. The Wilcoxon rank-sum test is for independent samples (unpaired). The Wilcoxon signed rank test is for paired samples.

wilcox.test(x, y, paired = TRUE)

Who is R?

After several years of using R to do various tasks from simple t-tests to much larger data sets I think I finally understand who R is.

R is like the computers of yesteryear, it does what you tell it, and only what you tell it, period. If you want more than the minimal amount of output, you have to ask for it. But it also has a bit of an attitude, for example, instead of outputting the type 3 sums of squares in ANOVA like virtually every other statistical package, it outputs the type 1 sums of squares by default. Why you might ask? The reason is because they want you to first think about what type of sums of squares you want, so by default they give you the one that isn't the most commonly used one. Hence R has a steep learning curve, which after several years I am still trying to surmount.

Enough talk, time for some code in the next post.

Saturday, April 11, 2009

Instant switching: compiz (gtk), emerald, metacity

In various places these are incorrectly listed. At least as of Intrepid Ibex, here's how to switch between window managers... still trying to figure this out...
metacity --replace
emerald --replace
compiz-decorator --replace
compiz # to start things up for compiz

Oh, but when I try it out I'm getting some problems. In theory ... Just put each of these lines in a custom application launcher on your panel (and maybe put those in a single drawer)