<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mat&#039;s blog</title>
	<atom:link href="http://matmoore.co.uk/code/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://matmoore.co.uk/code</link>
	<description>???</description>
	<lastBuildDate>Sun, 25 Jul 2010 10:09:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>No control over 2G/3G in Android API</title>
		<link>http://matmoore.co.uk/code/?p=80</link>
		<comments>http://matmoore.co.uk/code/?p=80#comments</comments>
		<pubDate>Sun, 25 Jul 2010 10:09:29 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://matmoore.co.uk/code/?p=80</guid>
		<description><![CDATA[On phones which use google&#8217;s android OS, there&#8217;s a little checkbox buried in the settings menu, &#8220;Use only 2G networks&#8221; which turns off 3G. I use this all the time because of the huge impact 3G has on battery life; however, it&#8217;s really annoying to keep having to go into the menu, switch it on, [...]]]></description>
			<content:encoded><![CDATA[<p>On phones which use google&#8217;s android OS, there&#8217;s a little checkbox buried in the settings menu, &#8220;Use only 2G networks&#8221; which turns off 3G. I use this all the time because of the huge impact 3G has on battery life; however, it&#8217;s really annoying to keep having to go into the menu, switch it on, then go back and switch it off again when I&#8217;m done using the internet (especially on my sluggish T-Mobile Pulse).</p>
<p>I had the idea of creating my own app which would switch on 3G for a set amount of time only. By integrating this with the fantastic <a href="http://www.twofortyfouram.com/">Locale</a> application it would also be possible to automatically trigger this by shaking the phone or something cool like that. I had it all planned out, except for one minor detail: how to actually toggle the setting. You&#8217;d think this would be pretty simple, seeing as plenty of other useful settings are exposed through the API, but no, the fascists at google <a href="http://stackoverflow.com/questions/2260189/android-3g-2g-control-api">do not allow it</a>! </p>
<p>So now, when I am left helpless and alone as my anthropomorphised battery breathes it&#8217;s final breath, I will remember this day with a tear in my eye, and I will never forgive the murderers who cruelly condemned this poor innocent battery to death. So much for &#8220;don&#8217;t be evil&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=80</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Planet simulator and Goserver</title>
		<link>http://matmoore.co.uk/code/?p=67</link>
		<comments>http://matmoore.co.uk/code/?p=67#comments</comments>
		<pubDate>Fri, 01 Jan 2010 17:52:50 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[astronomy]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[unfinished]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://matmoore.co.uk/code/?p=67</guid>
		<description><![CDATA[In an effort to revive this blog and start posting regularly I&#8217;ve decided to post some things I made ages ago which I haven&#8217;t posted online before. The first is a solar system simulator that demonstrates Kepler&#8217;s laws of planetary motion: kepler.tar (source) This originated as part of a multiplayer space shooter game I worked [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to revive this blog and start posting regularly I&#8217;ve decided to post some things I made ages ago which I haven&#8217;t posted online before. </p>
<p>The first is a solar system simulator that demonstrates <a href="http://en.wikipedia.org/wiki/Keplers_laws">Kepler&#8217;s laws of planetary motion</a>:</p>
<p><a href='http://matmoore.co.uk/code/?attachment_id=68' rel='attachment wp-att-68'>kepler.tar (source)</a></p>
<p>This originated as part of a multiplayer space shooter game I worked on with <a href="http://bencoder.com/">Bencoder</a>, which was never completed (mainly because we couldn&#8217;t decide how the game was supposed to work). We wanted planets which would move, but would be consistent across the network. Keplerian orbits allowed us to predict the state of the system at any given time, while still being realistic enough to satisfy my nerdiness. This is basically the map editor I wrote for the game. I think it was my first C++ application and my first GUI application (using Qt). As a result, the code is a horrible mess and it&#8217;s a bit buggy, but it&#8217;s quite fun to play around with.</p>
<p>Features:</p>
<ul>
<li>construct systems of suns, moons and planets</li>
<li>customize the image shown for each one with user created content</li>
<li>modify the size, mass and position of the objects</li>
<li>modify the ellipticity and direction of the orbits</li>
<li>view an animation of the system in real time</li>
</ul>
<p>Note: since the planets only interact with one other object, the system will behave a bit weirdly when the orbital paths intersect or are close to each other.</p>
<p>The other thing I made (this was a bit more recent) is a turn based go server in ruby on rails. It&#8217;s unfinished at the moment, but I have it running <a href="http://matmoore.co.uk/goserver">here</a> if you want to take a look. I was using this project to try and learn rails, but I think I may have picked something a bit too ambitious. There was a problem I couldn&#8217;t figure out with the images sometimes not loading and I eventually gave up on it. I learned a lot from it though, and I really like rails for web development, even though it&#8217;s a lot of hassle to set up on my website compared to PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=67</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating grids to use as go boards</title>
		<link>http://matmoore.co.uk/code/?p=64</link>
		<comments>http://matmoore.co.uk/code/?p=64#comments</comments>
		<pubDate>Tue, 29 Dec 2009 23:42:53 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://matmoore.co.uk/code/?p=64</guid>
		<description><![CDATA[So I decided to go back to my python go game I started many months ago. I have several other things I want to work on, most of which also involve go, but for some reason this interests me the most at the moment, and I haven&#8217;t done any python programming in a while so [...]]]></description>
			<content:encoded><![CDATA[<p>So I decided to go back to my python go game I started many months ago. I have several other things I want to work on, most of which also involve go, but for some reason this interests me the most at the moment, and I haven&#8217;t done any python programming in a while so I&#8217;m going to put them on hold. </p>
<p>One of the main things I wanted to do with the game was to allow for playing on many different types of board, rather than limit it to the boring old 19&#215;19 square kind, so I&#8217;ve written a module with several different classes which can be used to create board objects. </p>
<p>The rules of go are very simple, and are pretty much independent of the board shape. To work out what happens to the rest of the board when you place a stone, all you really need to know is how the points are connected to each other and where all the stones are. This means that an arbitrary graph can be used as the go board and what the board actually looks like is irrelevant. You can easily play go on 3D structures such as diamond structures or invent some strange irregular shape if you want. This makes it pretty easy to seperate the board structure from the game logic.</p>
<p>I&#8217;ve decided to limit myself to regular structures for the time being, and have stuck to 2 dimensions as I&#8217;m too lazy to mess around with 3D visualizations. I&#8217;ve implemented  a regular rectangular board a board which allows the edges to be wrapped pacman style, which can be used to simulate playing on a the surface of a cylinder or torus (donut shape).  To test it works ok I&#8217;ve whipped up a simple view in pygame which shows the neighbours of each point when you click on it. </p>
<p>The next step is to rewrite my go game around this module and create a usable gui for it.</p>
<pre name="code" class="python">
'''Classes for modelling the goboard itself, i.e. an arrangement of points with lines connecting them. No game logic is included.
Grid/lattice coordinates should all be integers'''
from itertools import izip
import sys

#Move this somewhere else later
class Observable:
    '''Implement observer pattern'''

    def __init__(self):
        self.listeners = []

    def register_listener(self, listener):
        self.listeners.append(listener) #this object has synasthaesia

    def remove_listener(self, listener):
        self.listeners.remove(listener)

    def notify(self, *args):
        for i in self.listeners:
            if args:
                i(args)
            else:
                i()

class Grid(Observable):
    '''A representation of a 2D grid with each point holding some value.
    Stores the relative location of each point and the lines connecting them.
    Lattice is a list of points representing the lattice structure the grid is based around.
    Basis is a tuple of coordinates of the grid points relative to the lattice points.
    Connections is a list of 4-tuples of the form (x1,y1,x2,y2) indicating how points in the basis are connected'''

    def __init__(self, lattice, basis, connections, default_value=0):
        '''Store points and connections'''
        Observable.__init__(self)
        self.points = {}
        self.connections = {}

        for lx,ly in lattice.items():

            #Add the points by superimposing the basis onto each lattice point
            for b in basis:
                bx, by = b
                self.points[(lx+bx, ly+by)] = default_value
                self.connections[(lx+bx, ly+by)] = []

        #Now connect the points
        for lx,ly in lattice.items():

            try:
                for c in connections:
                    cx1, cy1, cx2, cy2 = c
                    a = (lx+cx1, ly+cy1)
                    b = (lx+cx2, ly+cy2)
                    if a in self.points and b in self.points:
                        self.connections[a].append(b)
                        self.connections[b].append(a)
                    else:
                        print 'Missing points for connection '+str(a)+'-'+str(b)
                        if a not in self.points: print a
                        if b not in self.points: print b
            except KeyError:
                raise Exception('Invalid connections')

    def neighbours(self, x, y):
        try:
            return self.connections[(x,y)]
        except KeyError:
            raise Exception('Bad grid coordinates')

    def set_point(self, x, y, val):
        try:
            self.points[(x,y)] = val
            self.notify() #notify observers on changes
        except KeyError:
            raise Exception('Bad grid coordinates')

class RectangularGrid(Grid):
    '''A rectangular grid. Aspect ratio should be a natural number (horizontal spacing >= vertical spacing)'''

    def __init__(self, width, height, aspect_ratio=1):
        aspect_ratio = int(aspect_ratio) #no floats please!
        lattice = RectangularLattice(width, height, aspect_ratio)
        basis = ((0, 0),)
        connections = ((0, 0, 1, 0), (0, 0, 0, 1))
        Grid.__init__(self, lattice, basis, connections)

class FoldedGrid(RectangularGrid):
    '''A rectangular grid where sides connect with each other.
    Joins is a list of tuples indicating which sides are joined, where each of the two values can be N, E, S or W
    Reverse_joins is the same except there is also a twist, so one side can map to another side reversed (or the same side)'''

    def __init__(self, width, height, aspect_ratio, joins = [], reverse_joins = []):
        RectangularGrid.__init__(self, width, height, aspect_ratio)

        #Lists of coordinates making up each side
        east = []
        west = []
        north = []
        south = []

        #East/West coordinates
        x1 = 0
        x2 = (width - 1) * aspect_ratio
        for i in range(height):
            east.append((x1, i))
            west.append((x2, i))

        #North/South coordinates
        y1 = 0
        y2 = height - 1
        for i in range(width):
            i *= aspect_ratio
            north.append((i, y1))
            south.append((i, y2))

        sides = {'E':east, 'W':west, 'N':north, 'S':south}

        #Make the extra connections
        try:
            for sideA, sideB in joins:
                #Zip the two sides together to get a tuple of tuples (coordinates) for each connected pair
                for c1, c2 in izip(sides[sideA], sides[sideB]):
                    self.connections[c1].append(c2)
                    self.connections[c2].append(c1)

            for sideA, sideB in reverse_joins:
                #This time the second side is reversed!
                for c1, c2 in izip(sides[sideA], reversed(sides[sideB])):
                    print str(c1) + '-' + str(c2)
                    self.connections[c1].append(c2)
                    self.connections[c2].append(c1)

        except KeyError:
            raise Exception('Invalid value for join or reverse_join')

class RectangularLattice:
    '''List of coordinates of points arranged in a grid'''

    def __init__(self, width, height, aspect_ratio, scale=1):
        aspect_ratio = int(aspect_ratio) #no floats please
        self.points = []
        for i in range(width):
            for j in range(height):
                j *= aspect_ratio
                self.points.append((i,j))

    def items(self):
        for i in self.points:
            yield i

class GridViewPygame:
    '''Draw grids using pygame'''

    def __init__(self, grid, surface, scale=None, rotation=0, zoom_to_fit=False, join_connected=False, highlight_connected=True):
        grid_width = max([x for x,y in grid.points])
        grid_height = max([y for x,y in grid.points])
        width = surface.get_width()
        height = surface.get_height()

        if zoom_to_fit:
            scale = min(width/float(grid_width), height/float(grid_height))
        elif scale is None:
            scale = 1

        self.scale = scale
        self.grid = grid
        self.surface = surface
        self.grid.register_listener(self.draw)
        self.highlighted = None

        self.highlight_connected = highlight_connected
        self.join_connected = join_connected

    def draw(self, *args):
        '''Draw the grid'''
        print 'redrawing'
        scale = self.scale
        self.surface.fill((255,255,255))

        for p in self.grid.points:
            x,y = p
            x *= scale
            y *= scale
            if (p == self.highlighted):
                pygame.draw.circle(self.surface, (0,0,255), (x,y), 3)
            else:
                pygame.draw.circle(self.surface, (0,0,0), (x,y), 2)

        #This actually draws the line for each connection twice but never mind
        if self.join_connected:
            for a,bs in self.grid.connections.items():
                for b in bs:
                    ax,ay = a
                    bx,by = b
                    ax *= scale
                    ay *= scale
                    bx *= scale
                    by *= scale
                    if (a == self.highlighted or b == self.highlighted):
                        pygame.draw.line(self.surface, (0,0,255), (ax,ay), (bx,by))
                    else:
                        pygame.draw.line(self.surface, (0,0,0), (ax,ay), (bx,by))

        if self.highlight_connected and self.highlighted:
            for x,y in self.grid.connections[self.highlighted]:
                x *= scale
                y *= scale
                pygame.draw.circle(self.surface, (0,255,0), (x,y), 2)

        pygame.display.flip()

    def board_to_grid(self, pos):
        '''Convert view coordinates to grid ones'''
        x,y = pos
        x = int(round(x/self.scale))
        y = int(round(y/self.scale))
        return (x,y)

    def onClick(self, pos):
        '''Highlight the nearest point'''
        pos = self.board_to_grid(pos)
        print pos
        self.highlighted = pos
        self.draw(False,True)

if __name__ == '__main__':

    #Initialize pygame
    import pygame
    pygame.init()
    from pygame.locals import *
    screen = pygame.display.set_mode((800, 600))

    #Create grid
#    grid = RectangularGrid(19,19)
    grid = FoldedGrid(19,19,1,[('N','S'),('E','W')])
#    grid = FoldedGrid(19,19,1,[],[('N','S'),('E','W')])
    view = GridViewPygame(grid, screen, zoom_to_fit=True)
    view.draw()

    #Handle events
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == MOUSEBUTTONDOWN:
                view.onClick(pygame.mouse.get_pos())
</pre>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=64</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One day game (continued)</title>
		<link>http://matmoore.co.uk/code/?p=50</link>
		<comments>http://matmoore.co.uk/code/?p=50#comments</comments>
		<pubDate>Fri, 05 Jun 2009 19:12:37 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[One day games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=50</guid>
		<description><![CDATA[Game 1 ended up being a huge failure. I think the main reason for this was a lack of experience in game development in general, and a poor choice of programming language, which I didn&#8217;t really know how to use properly when I started (flash/actionscript). As a result I wasted a lot of time trying [...]]]></description>
			<content:encoded><![CDATA[<p>Game 1 ended up being a huge failure. I think the main reason for this was a lack of experience in game development in general, and a poor choice of programming language, which I didn&#8217;t really know how to use properly when I started (flash/actionscript). As a result I wasted a lot of time trying to learn stuff and wasn&#8217;t able to put together anything playable within the time span I set myself.</p>
<p>Trying to come up with good ideas in so short a time was challenging, but I think I did have some workable ideas. While the obvious interpretation of &#8220;space&#8221; is a broad enough theme in itself, I decided to explore other meanings rather than immediately settling for some kind of spaceship game. Some of the ideas I had -</p>
<ul>
<li>An abstract game where the player manipulates empty space somehow, by rearranging or destroying things</li>
<li>A tetris variant</li>
<li>Human expansion has left the solar system overcrowded and you have to destroy things to make space, possibly related to the Vogons in h2g2 (reflecting the theme in two ways)</li>
<li>Something related to recycling and consumerism (not enough space for all the garbage we produce?)</li>
<li>Any kind of space in the mathematical sense</li>
<li>Something related to the concept of personal space. e.g. avoiding other commuters on a crowded train (I rejected this but kept the general idea for my final game)</li>
</ul>
<p>The idea I went with was a game in which you have to maintain a certain amount of space around you to survive. The player is a boy who is trying to avoid catching &#8220;cooties&#8221; from girls who run at the player from offscreen. Also the player is armed with a baseball bat. </p>
<p>This is as far as I got:<br />
<a href='http://happyfantasyland.com/code/?attachment_id=51' rel='attachment wp-att-51'>Failed game</a></p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=50</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>24 hour game</title>
		<link>http://matmoore.co.uk/code/?p=45</link>
		<comments>http://matmoore.co.uk/code/?p=45#comments</comments>
		<pubDate>Thu, 04 Jun 2009 18:30:44 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[One day games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[space]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=45</guid>
		<description><![CDATA[This will be the first of hopefully many small games. Me and my friend Ben will both be attempting to design and make fun, playable games within a one day time frame. Each time, there will be a theme chosen at the start by one of us (the theme chooser will change each time) which [...]]]></description>
			<content:encoded><![CDATA[<p>This will be the first of hopefully many small games. Me and my friend <a href="http://bencoder.com/gameaday/">Ben</a> will both be attempting to design and make fun, playable games within a one day time frame. Each time, there will be a theme chosen at the start by one of us (the theme chooser will change each time) which both the games will have to fit in with. At the end, people will be able to vote on which is the best over at Ben&#8217;s blog.</p>
<p>The theme this time is &#8220;space&#8221; (chosen by Ben) and the challenge ends at <del datetime="2009-06-05T15:26:13+00:00">19.00</del> 23.59 UTC+1 tommorow (5th of june).</p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=45</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tesselating hexagons and Go</title>
		<link>http://matmoore.co.uk/code/?p=39</link>
		<comments>http://matmoore.co.uk/code/?p=39#comments</comments>
		<pubDate>Tue, 03 Mar 2009 13:12:36 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[postscript]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=39</guid>
		<description><![CDATA[These handy go board templates have enlightened to me to the awesomeness of postscript, so I decided to have a go at creating my own. It&#8217;s a hexagonal go board. Stones have either 3 (playing on the intersections) or 6 (playing inside the hexagons) liberties instead of the usual 4. I have yet to try [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://micans.org/goboards/">These handy go board templates</a> have enlightened to me to the awesomeness of postscript, so I decided to have a go at creating my own.</p>
<p>It&#8217;s a hexagonal go board. Stones have either 3 (playing on the intersections) or 6 (playing inside the hexagons) liberties instead of the usual 4. I have yet to try it out, but apparently having less liberties makes the game more tactical, as its a lot easier to capture stones. See <a href="http://homepages.di.fc.ul.pt/~jpn/gv/boards.htm">here</a> for some more info on different board variations.</p>
<p>You can download it as <a href='http://happyfantasyland.com/code/wp-content/uploads/2009/03/hexagonal.pdf'>pdf</a> or <a href='http://happyfantasyland.com/code/wp-content/uploads/2009/03/hexagonal.ps'>postscript</a> (both are A4 sized)</p>
<p>Also seeing as how I&#8217;m probably not going to be working on my go program for a while I&#8217;ve uploaded the code for that <a href='http://happyfantasyland.com/code/wp-content/uploads/2009/03/go.zip'>here</a>.<br />
I haven&#8217;t tested it on other computers at all but it should work as long as you have python and wxpython (for the GUI) installed. The GUI is pretty crappy at the moment as it only supports 9&#215;9 games but the text version is a bit more flexible. Also theres no way of playing against a computer or internet person yet.</p>
<p>run it with<br />
python run.py<br />
or<br />
python run_gui.py</p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=39</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Go</title>
		<link>http://matmoore.co.uk/code/?p=33</link>
		<comments>http://matmoore.co.uk/code/?p=33#comments</comments>
		<pubDate>Thu, 04 Dec 2008 23:16:52 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=33</guid>
		<description><![CDATA[I&#8217;ve gotten really into Go lately, so I decided to make my own Go app. I&#8217;m not really planning to accomplish anything useful, seeing as there&#8217;s a lot of good software already out there, so features will be added if and when I feel like it. I&#8217;ve written a few classes for it now&#8230; you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten really into <a href="http://en.wikipedia.org/wiki/Go_(game)">Go</a> lately, so I decided to make my own Go app. I&#8217;m not really planning to accomplish anything useful, seeing as there&#8217;s a lot of good software already out there, so features will be added if and when I feel like it.</p>
<p>I&#8217;ve written a few classes for it now&#8230; you can play stones and it will try to work out if the move is legal and remove captured stones, which seems to work but probably doesn&#8217;t. I&#8217;ll test it properly later. I&#8217;m going to make a text only interface first, then add a gui once I&#8217;ve got it working properly.</p>
<p>*edit* made the text interface for playing a 2 player game on the same computer. Everything is working but it doesn&#8217;t calculate the score yet.<br />
<div id="attachment_37" class="wp-caption alignnone" style="width: 266px"><a href="http://happyfantasyland.com/code/wp-content/uploads/2008/12/gogame.png"><img src="http://happyfantasyland.com/code/wp-content/uploads/2008/12/gogame-256x300.png" alt="Go game" title="gogame" width="256" height="300" class="size-medium wp-image-37" /></a><p class="wp-caption-text">Go game</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Super simple blog using text files</title>
		<link>http://matmoore.co.uk/code/?p=31</link>
		<comments>http://matmoore.co.uk/code/?p=31#comments</comments>
		<pubDate>Sat, 18 Oct 2008 21:39:24 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[procrastination]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=31</guid>
		<description><![CDATA[Here&#8217;s something I made in php to run a blog without a database. The posts are written in text files and the filename contains the post number and date. I wanted something I could put on my webspace at university that would allow me to keep a diary of everything I do for my final [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s something I made in php to run a blog without a database. The posts are written in text files and the filename contains the post number and date. I wanted something I could put on my webspace at university that would allow me to keep a diary of everything I do for my final year project. </p>
<p>Features:<br />
Umm&#8230; it has permalinks or you can view recent posts 10 at a time. And it automagically inserts the html for paragraphs for you. That&#8217;s pretty much it.</p>
<p><a href='http://happyfantasyland.com/code/wp-content/uploads/2008/10/simpleblog2.zip'>Simple blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yeah.</title>
		<link>http://matmoore.co.uk/code/?p=24</link>
		<comments>http://matmoore.co.uk/code/?p=24#comments</comments>
		<pubDate>Fri, 26 Sep 2008 21:37:51 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[abuse of the english language]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=24</guid>
		<description><![CDATA[I was curious about which words I say the most when talking on msn so I decided to write a quick python script to find out: import re,os,string logdir = "/home/mat/.purple/logs/msn/[my email]" regex = re.compile("\(\d\d:\d\d:\d\d\) Mat: (.*)") info = {} def compareVal(a,b): """Compare a list of tuples using their 2nd value""" return b[1]-a[1] def removePunc(word): [...]]]></description>
			<content:encoded><![CDATA[<p>I was curious about which words I say the most when talking on msn so I decided to write a quick python script to find out:</p>
<pre name="code" class="python">import re,os,string
logdir = "/home/mat/.purple/logs/msn/[my email]"
regex = re.compile("\(\d\d:\d\d:\d\d\) Mat: (.*)")
info = {}

def compareVal(a,b):
	"""Compare a list of tuples using their 2nd value"""
	return b[1]-a[1]

def removePunc(word):
	"""Couldn't find an existing function for this, strip only removes characters from the ends <img src='http://matmoore.co.uk/code/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> """
	return "".join([i for i in word if i not in string.punctuation])

#go through all files in the subdirectories
for root, dirs, files in os.walk(logdir, topdown=True):
	for f in files:
		fullPath = os.path.join(root,f)
		text = open(fullPath)
		for line in text:
			m = regex.match(line)
			if m: #only look at stuff I've said
				words = m.group(1).split()
				words = [removePunc(i) for i in words] #remove punctuation
				words = [i for i in words if len(i)&gt;3] #filter out short words
				for word in words: #increment the frequency for this word
					if word in info: info[word] += 1
					else: info[word] = 1

li = info.items()
li.sort(compareVal) #sort by frequency (highest first)
for i in li:
	print "%s: %d" % i</pre>
<p>(It ignores anything with 3 letters or less)</p>
<p>The results were kind of boring. Here&#8217;s the top 10:<br />
yeah: 1984<br />
that: 1956<br />
have: 1565<br />
what: 1321<br />
<font color="red">like</font>: 1148<br />
just: 993<br />
dont: 937<br />
think: 870<br />
well: 832<br />
with: 722</p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PyWeek 7</title>
		<link>http://matmoore.co.uk/code/?p=22</link>
		<comments>http://matmoore.co.uk/code/?p=22#comments</comments>
		<pubDate>Mon, 15 Sep 2008 10:56:35 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyweek]]></category>

		<guid isPermaLink="false">http://happyfantasyland.com/code/?p=22</guid>
		<description><![CDATA[Last week I took part in pyweek, a week long programming contest where you have to write a game in python that fits a theme. The theme this time was &#8220;the length of a piece of string&#8221; and my entry can be found here. (You&#8217;ll need to have python and pygame installed to run it) [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I took part in pyweek, a week long programming contest where you have to write a game in python that fits a theme. </p>
<p>The theme this time was &#8220;the length of a piece of string&#8221; and my entry can be found <a href="http://www.pyweek.org/e/Mat/">here</a>. (You&#8217;ll need to have python and pygame installed to run it)</p>
<p>I haven&#8217;t played through all the other entries yet, but so far my favourite is <a href="http://www.pyweek.org/e/midnightsun/">Kite Story</a> (has a windows .exe as well as the python source) which involves wrapping things up in the string of your kite. It&#8217;s really well made, has lovely graphics and music and more importantly, it&#8217;s fun. I&#8217;m impressed. </p>
]]></content:encoded>
			<wfw:commentRss>http://matmoore.co.uk/code/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
