New Dell laptop with Windows 7

My old HP laptop finally gave up the ghost and totally refused to startup. I had been expecting this for a while as some time ago it badly overheated and various sub-systems have been failing since then. The soundcard failed first followed by the wired network port and finally the DVD drive.

As a replacement I ordered a Dell 15R with a Core i3 processor. Not the best machine in the world but totally suited for my laptop use cases. The machine came with Windows 7 and I am going to use this for general tasks; Internet, e-mail, documents etc. I have created an Ubuntu 10.10 VM under VirtualBox for those software development tasks that Windows just can handle.

So far I am liking Windows 7 on the Dell, it is pretty, stable and fast. I have moved to the taskbar to the left of the screen as this makes best use of the wide ascpect radio of the display. With the taskbar at the bottom the screen felt very cramped vertically but with it at the side there is still plenty of space horisontally. I have downloaded some very nice visual themes from the Microsoft site; Lightening and Blue Water are particular favorites.

I have only had the machine for a few days but so far so good.

Python Adventure Game – Finished

I have now finished my Python Adventure Game by adding some puzzles and a win algorithm. Its a very simple game but was great fun to write.

Source code is below.

#
# Barry's simple adventure game
#
 
# Room data indexs
SHORT_DESC = 0
LONG_DESC = 1
N_EXIT = 2
S_EXIT = 3
E_EXIT = 4
W_EXIT = 5
U_EXIT = 6
D_EXIT = 7
OBJECT = 8
 
# Room Data
rooms = [
['dummy'],
['the entrance', 'the entrance to a rather large looking cave', 2, 0, 0, 0, 0, 0, ''], # 1
['a coridor', 'a coridor that stretches off to the North', 3, 1, 0, 0, 0, 0, 'Lamp'], #2
['a round room', 'a round room with many exits', 7, 2, 4, 0, 20, 6, ''], #3
['a crawlway', 'a narrow east / west crawlway', 0, 0, 5, 3, 0, 0, ''], #4
['a low cave', 'a low dead end cave', 0, 0, 0, 4, 0, 0, 'Knife'], #5
['a well', 'a deep well with no way out', 0, 0, 0, 0, 0, 0, ''], #6
['a crystal cave', 'a beautifull cave with crystal walls', 8, 3, 9, 0, 0, 0, ''], #7
['an alcove', 'a small alcove in the cave wall', 0, 7, 0, 0, 0, 0, ''], #8
['a passage', 'a long east / west passage', 0, 0, 10, 7, 0, 0, ''], #9
['an anteroom', 'a richly decorated anteroom', 13, 11, 12, 9, 0, 0, ''], #10
['a wardrobe', 'a large wardrobe with space for lots of clothes', 10, 0, 0, 0, 0, 0, 'Key'], #11
['the throne room', 'a very large room with a golden throne on a dais', 0, 0, 0, 10, 0, 0, 'Crown'], #12
['the view room', 'a cave with a small hole giving a view along a green valley', 0, 10, 14, 0, 0, 0, ''], #13
['the guard room', 'a room with chairs and a table that looks like it was used as a guard room', 0, 0, 15, 13, 0, 0, ''], #14
['the ballroom', ' a magnificent ballroom with purple and gold walls', 0, 17, 18, 14, 16, 0, ''], #15
['the organ loft', 'a small room containing the controls for a large pipe organ', 0, 0, 0, 0, 0, 15, ''], #16
['the vault', 'a small airtight vault with shelves around the sides', 15, 0, 0, 0, 0, 0, 'Diamond'], #17
['the dining room', 'a long room with a huge dining table and chairs', 0, 0, 19, 15, 0, 0, ''], #18
['the kitchen', 'a large dusty kitchen', 0, 0, 0, 18, 0, 0, ''], #19
['a gallery', 'a high gallery leading off in a number of directions', 24, 22, 23, 21, 0, 3, ''], #20
['the waverfall cave', 'a large cave with a dark lake and a waterfall at the far end', 0, 0, 20, 0, 0, 0, ''], #21
['the echo cave', 'a small cave where sound echoes all around', 20, 0, 0, 0, 0, 0, ''], #22
['the assasin room', 'a small room bare room', 0, 0, 25, 20, 0, 0, 'a dead Masked Man'], #23
['a dark cave', 'a dark cave', 24, 24, 20, 24, 24, 24, ''], #24
['the exit', 'the exit of the cave', 0, 0, 0, 23, 0, 0, ''] #25
]
 
objects = ['dummy']
visits = [0]
for room in range(1, rooms.__len__()):
    objects.append(rooms[room][OBJECT])
    visits.append(0)
 
current_room = 1
visits[current_room] = 1
 
inventory = []
 
battery = 100
 
# Code
 
def describe_room(room):
    print
    if visits[room] > 1:
        print 'You are in ' + rooms[room][SHORT_DESC]
    else:
        print 'You are in ' + rooms[room][LONG_DESC]
    print
    if rooms[room][N_EXIT] != 0:
        print 'There is an exit to the North'
    if rooms[room][S_EXIT] != 0:
        print 'There is an exit to the South'
    if rooms[room][E_EXIT] != 0:
        print 'There is an exit to the East'
    if rooms[room][W_EXIT] != 0:
        print 'There is an exit to the West'
    if rooms[room][U_EXIT] != 0:
        print 'There is an exit leading upwards'
    if rooms[room][D_EXIT] != 0:
        print 'There is an exit leading downwards'
    if objects[room] != '':
        print
        print 'There is a ' + objects[room] + ' here'
    print
 
def move(exit):
    global current_room
    if rooms[current_room][exit] != 0:
        # Can't enter the vault without the key
        if ((current_room == 15) and (rooms[current_room][exit] == 17)):
            if 'Key' in inventory:
                print
                print
                print "You use the key to open the door to the vault"
                current_room = rooms[current_room][exit]
                visits[current_room] += 1
            else:
                print
                print
                print "You can't open the heavy door but it does have a key hole"
        else:
            current_room = rooms[current_room][exit]
            visits[current_room] += 1
    else:
        print
        print
        print '>>> There is no exit in that direction'
 
def north():
    move(N_EXIT)
 
def south():
    move(S_EXIT)
 
def east():
    move(E_EXIT)
 
def west():
    move(W_EXIT)
 
def up():
    move(U_EXIT)
 
def down():
    move(D_EXIT)
 
def get():
    if objects[current_room] == command.split()[1]:
        objects[current_room] = ''
        inventory.append(command.split()[1])
    else:
        print
        print "There is not a " + command.split()[1] + " here"
 
def drop():
    if command.split()[1] in inventory:
        inventory.remove(command.split()[1])
        objects[current_room] = command.split()[1]
    else:
        print
        print "You are not carrying a " + command.split()[1]
 
def inv():
    print("Inventory: ")
    for item in inventory:
        print item
 
commands = {
'north' : north,
'n' : north,
'south' : south,
's' : south,
'east' : east,
'e' : east,
'west' : west,
'w' : west,
'up' : up,
'u' : up,
'down' : down,
'd' : down,
'get' : get,
'inventory' : inv,
'inv' : inv,
'drop' : drop
}
 
# Main game loop
exit = False
while (not exit):
    print
    print
    describe_room(current_room)
    command = raw_input( "What do you want to do: " )
    if command != "":
        command_name = command.split()[0]
    else:
        command_name = "none"
    if command_name in commands.keys():
        commands[command_name]()
    else:
        print
        print
        print '>>> I don\'t understand that'
    # Check lamp
    if 'Lamp' in inventory:
        battery = battery - 1
        if battery == 50:
            print
            print
            print "The battery in your lamp is half used"
        else:
            if battery == 25:
                print
                print
                print "The battery in your lamp is three quarters used"
            else:
                if battery == 10:
                    print
                    print
                    print "The battery in your lamp is almost exhausted"
                else:
                    if battery == 0:
                        print
                        print "Your lamp has failed"
                        print "You fell in a pit and died!!"
                        print
                        exit = True
    else:
        if current_room == 3:
            print
            print
            print "It's dark here, you should find a light source or you might get hurt"
        else:
            if current_room > 3:
                print
                print "You fell in a pit and died!!"
                print
                exit = True
    # Assasin puzzle
    if current_room == 23:
        if 'Knife' in inventory:
            print
            print
            print "You killed a masked man with the knife you were carrying, well done"
        else:
            print
            print "A masked man killed you, you should have looked for a weapon!"
            print
            exit = True
    # Win check
    if current_room == 25:
        if (('Crown' in inventory) and ('Diamond' in inventory)):
            print
            print "Well done, you found all of the treasure"
            print
            exit = True
        else:
            print
            print "There is more treasure to find, go back and keep looking"
            print

Python Adventure Game

As well as the space invaders game mentioned in an earlier post I thought that I would also implement a textual adventure for the nostalgia value.

I sketched the map of the game on paper as shown below.

Map 1

Map 2

And then implemented the data structure in python.

# Room data indexes
SHORT_DESC = 0
LONG_DESC = 1
N_EXIT = 2
S_EXIT = 3
E_EXIT = 4
W_EXIT = 5
U_EXIT = 6
D_EXIT = 7
OBJECT = 8
 
# Room Data
rooms = [
['dummy'],
['the entrance', 'the entrance to a rather large looking cave', 2, 0, 0, 0, 0, 0, ''], # 1
['a corridor', 'a corridor that stretches off to the North', 3, 1, 0, 0, 0, 0, 'Lamp'], #2
['a round room', 'a round room with many exits', 7, 2, 4, 0, 20, 6, ''], #3
['a crawlway', 'a narrow east / west crawlway', 0, 0, 5, 3, 0, 0, ''], #4
['a low cave', 'a low dead end cave', 0, 0, 0, 4, 0, 0, 'Knife'], #5
['a well', 'a deep well with no way out', 0, 0, 0, 0, 0, 0, ''], #6
['a crystal cave', 'a beautiful cave with crystal walls', 8, 3, 9, 0, 0, 0, ''], #7
['an alcove', 'a small alcove in the cave wall', 0, 7, 0, 0, 0, 0, ''], #8
['a passage', 'a long east / west passage', 0, 0, 10, 7, 0, 0, ''], #9
['an anteroom', 'a richly decorated anteroom', 13, 11, 12, 9, 0, 0, ''], #10
['a wardrobe', 'a large wardrobe with space for lots of clothes', 10, 0, 0, 0, 0, 0, 'Key'], #11
['the throne room', 'a very large room with a golden throne on a dais', 0, 0, 0, 10, 0, 0, 'Crown'], #12
['the view room', 'a cave with a small hole giving a view along a green valley', 0, 10, 14, 0, 0, 0, ''], #13
['the guard room', 'a room with chairs and a table that looks like it was used as a guard room', 0, 0, 15, 13, 0, 0, ''], #14
['the ballroom', ' a magnificent ballroom with purple and gold walls', 0, 17, 18, 14, 16, 0, ''], #15
['the organ loft', 'a small room containing the controls for a large pipe organ', 0, 0, 0, 0, 0, 15, ''], #16
['the vault', 'a small airtight vault with shelves around the sides', 15, 0, 0, 0, 0, 0, 'Bag of Money'], #17
['the dining room', 'a long room with a huge dining table and chairs', 0, 0, 19, 15, 0, 0, ''], #18
['the kitchen', 'a large dusty kitchen', 0, 0, 0, 18, 0, 0, ''], #19
['a gallery', 'a high gallery leading off in a number of directions', 24, 22, 23, 21, 0, 0, ''], #20
['the waterfall cave', 'a large cave with a dark lake and a waterfall at the far end', 0, 0, 20, 0, 0, 0, ''], #21
['the echo cave', 'a small cave where sound echoes all around', 20, 0, 0, 0, 0, 0, ''], #22
['the assassin room', 'a small room bare room', 0, 0, 25, 20, 0, 0, 'Masked Man'], #23
['a dark cave', 'a dark cave', 24, 24, 20, 24, 24, 24, ''], #24
['the exit', 'the exit of the cave', 0, 0, 0, 23, 0, 0, ''] #25
]

The game is now mostly working. Only the puzzles left to implement.

PDAs over the years

I have been thinking about the number of PDAs (Personal Digital Assistant) that I have owned over the years. I started to put a list together and here are the ones that I can remember.

Psion 2 – LZ64
Psion Series 3
Psion Series 3a
Psion Series 5
Handspring Visor
Palm m505
Sony CLIÉ
Palm Tungsten T5
HTC Touch – Windows Mobile
HTC Hero – Android 1.5

There are a number of distinct phases in the above list. First the three evolutionary Psion ranges, PalmOs, Windows Mobile and finally Android. I look back with fondness to these old machines but I do not want to thing about the ammount of money I have spent on them!

Squeak 4.1

Squeak 4.1 was released this week. After all of the problems with the community splitting after the Pharo fork, Squeak appears to be back on track. Squeak 4.0 was a licence clean release without any new functionality but 4.1 includes all of the updates that were made during the re-licencing process.

Hightlights include a new look and feel based on the Newspeak UI, new anti-aliased fonts, the closure enabled compiler from Cog, core library improvements and modularity advances. More details can be found on www.squeak.org.

I hope that I can find the time to check it out more fully soon.

Open University

I will have less time for my own programming projects for the next few months because I have started a new Open University course. I felt that I had done enough maths after two courses and so now I am doing a software one, M255 – Object-oriented programming with Java.

This will be the first time that I have been formally taught object-oriented programming or Java. Should be interesting!

Todo list in the cloud

As I have said before I have been using “Life Balance” and “My Life Organised” to handle my todo list. Both of these are very good but have the limitation that they are only available on certian platforms. My Todo list must be available both on my PC (for ease of data entry and review) and my PDA (for when I am out and about). I originally used LB on PC and Palm but had to change to MLO when I changed to using my Windows Mobile phone as my PDA as there is not an LB version for WM.

Now I am changing my mobile phone and do not want to be limited in choice by my Todo application. I also use both Windows and Linux on various PCs and finding an application that runs natively on multiple platforms is not that easy. For these reasons I decided to use an on-line Todo service. After looking arround at the various options I decided to go with Toodledo. I have now stopped using MLO and so far Toodledo is doing everything that I need.

I am a little worried that my todo list is now in the cloud and outages could cause me to be unable to see my data. However there are some ways around this. I have brought the Toodledo native application for my iPod Touch, this syncs with the web version and keeps a copy of my data on the iPod. I also export my todo list regularly as XML and back this up on my network. For the future these is discussion of a Gears version of Toodledo, this would be good but we will have to wait and see.

All in all Toodledo should serve my needs until my own GTD application is ready 🙂

BjbGtd project on Kenai

In order to keep my life in order I have for many years used a task management system based on Getting Things Done (GTD) by David Allen. Initially I used a system called Life Balance on PC and Palm then moved to My Life Organised on PC and Windows Mobile.

I like the way that both of these systems work but as a software guy I have always thought “I can do that!”. So now I am putting my money where my mouth is and have started my own open source GTD project. Initially I am implementing a library to handle the GTD data items (Tasks, Contexts, etc.), this will be followed by desktop, mobile and, maybe, web applications that all use the library.

The library is called BjbGtdLib, is written in Java using NetBeans and is hosted on Kenai.

Go take a look!

Internet on the move

In these days of cloud computing it is getting to the stage where it is not possible to do even the simplest things without an internet connection. All of our data is “in the cloud” rather than on individual computers. This is a good thing in my case as I have a number of devices (laptop, netbook, phone etc.) that I use at various times and need to have access to my information.

To help with this situation I have taken two actions, the first is to signup for mobile broadband for he first time and the second is to increase the monthly data limit on my phone. I have been impressed with mobile broadband, plug the dongle into the laptop or netbook and away you go. The speed is good when there is 3G coverage and so far it has been very reliable. Bandwidth is obviously limited but should be fine for what I need. Most of my access will still be at home or at work with the mobile broadband just for when travelling and when on holiday. I have 1Gig a month on the mobile broadband and 250Meg a month (up from 4Meg) for the phone. I can now access my data, surf, e-mail, blog, etc. from wherever I happen to be without worrying too much about hitting limits or extra charges.

The information age is a wonderful thing!

UNR on the Acer Aspire One

Yesterday I finally took the plunge and installed the Ubuntu Netbook Remix (UNR) on my Aspire One. I had been thinking about changing from the default Linpus distro for a while. Linpus works fine but being based on Fedora 8 it is not exactly cutting-edge!

One users on the net gave varying reports of the performance of UNR on the One, some had few problems while others appeared to have to do a lot of work just to get basic functionality. I brought my One to use, not to spend lots of time tinkering and so held back on changing for a while. Yesterday I brought a copy of the UK Linux magazine “Linux Format” and they had an article about UNR on the Aspire One. If a mainstream magazine was using UNR on the One with no problems then it time me to go for it!

I downloaded the latest Jaunty UNR image and copied it to a USB stick. Booting into live mode allowed me to play with the new distro and confirm that it worked OK before overwriting Linpus with a full UNR install. For the install I kept the partition structure that Linpus had used (ext2, 7Gig for / and 1Gig for swap) on the internal SSD and put /home on my 16Gig SD card, again using ext2. Shortly afterwards I had my new distro up and running.

UNR looks great and works well so far. Wireless worked out of the box. The only problems I have seen is that the wireless status LEDs do not work and the right hand memory card slot does not appear to be able to hot swap cards (I read that it works OK if a card is in the slot at boot time but have not checked this).

I am typing this post on the One and I am happy that I now have Ubuntu on my netbook.