Sunday, 8 May 2011

Programming: Java text board game

Gor, it must be getting on for a year, since I uploaded that game what I wrote in Perl to SourceForge, you can download it from here if you're into that sort of thing. Its a bit like the programs I used to type in from Amstrad Action or Amstrad Computer User.
Anyhoo, I've now ported it across in Java, and tidied it up a bit, making the code a bit more concise. Its taken me a while because I didn't actually know how to program in Java, luckily I managed to borrow this book from my girlfriend's sister.

Its all right, not too confusing, I'm not even halfway though but I've got enough of it in me to port perl to java.

The basic premise of the game is kind of like checkers, apart from you add one new piece to the board every turn and the stacks explode. Actually, its only like checkers in that its played on a 8x8 board and you can stack pieces, other than that, its like in games like Doom or Halo where you can blow up oil drums and they set of nearby oil drums in a chain reaction.

It must have been back in 1993 when a friend showed me a version of the game on his Acorn Archimedes, and then a few months later I was going through all my old ACU magazines typing in all listings and ended up with the same game. I hadn't see it since so I figured I could create my own version on modern computers.

For a player versus player game, it game works like this basically


The main difference I found between perl and Java was that in the latter you have to is statically typed whilst the former is dynamically typed. I think that means you have to define what sort of data all the variables are, whether they're integers or strings and so on. Also, with things like arrays you have to state how long they are before you use them, rather than just adding stuff into an array whenever you want. And lastly getting user input from the keyboard is a little bit more different in java than in perl. It took me about a week to figure it out.

Anyhoo, once I'd nailed all that it was easy. The gameboard is a great three dimensional integer array, 10x10, but it ignores the border squares and uses one layer for each player. You play a turn, it checks whether there's any 'explosions', explodes them and then checks again until its exhausted its explosives, then the next player takes a turn. This repeats until one player or the another has been annihilated or someone quits.

Then for playing against the computer it does the same thing but substitutes in a routine for chosing where to play. It builds itself a little list of what grid squares do the most damage, which are most aggressive, or which are safest, and then randomly selects the most appropriate.

Games take around twenty minutes to play, or maybe 200 turns. I've managed to win in 140 turns, which I guess is the closest thing to a high-score at this stage.

If you want to play, or just peer at my well leet coding, you can download the source code from this page.

ChainOfWar is the java version
plainofwec is the perl version

You'll need to compile the code to get it to work. If you don't know what that means, then you ought to have a long hard think about what you want to get out of life. Do you want to be a creator or a consumer? Do you personally want to leave the world a better place than how you found it. Do you want to grow as a person, or just wallow until dementia hits.

Anyhoo, I have a plan. Whilst this it just a command-line/text based version of the game, I'm going to use java's gridbag class to do a windows version that ought to be a bit more fun to play, then I'd going to do some kind of web applet version so you can play it online. Then, I know, crazy, I reckon its just the same learning curve to do an android and iPhone version that I can sell and become one of these millionaires.

Friday, 6 May 2011

Plants and stuff: Mostly pommes

I was convinced I'd been sold a pudding by Tesco in this apple tree named Huey Lewis, but it looks like I've been proved wrong.

For weeks he looked just like a dead stick planted in the ground, showing no signs of life whatsoever, except for a few spiders who'd taken up home in his branches. But I was having a potter round the garden after work, when I thought I saw something on Huey.

My eyes did no deceive me, Huey Lewis is starting to bud!

Little green buggers, and not just one or two, but loads of them all over his branches. Even coming out of the bits I thought were broken, dangling limbs. There's life in old Huey yet.

He's veritably bristling with life, like the wee embryonic leafy dudes can't wait to get out there and start photosynthesizing. I might be optimistic expecting fruit this year, but at least he's no dead and I'm so excited to see his buds.

Anyhoo, so there I was, buzzing round the garden, trying to remember the words to Huey's namesake's Power of Love, and doing a spot of weeding, when I saw this little guy.



He's called Ian, he's a potato plant. I'd forgotten I'd planted potatoes. It must have been a few months ago, there were some dodgy ones at the back of the fridge, you know the potatoes with tentacles that make Jaclyn scream. I thought, rather than chuck them, I'd stick them in the ground and hope for the best.

See, cos the soil is so poor, I didn't think they'd do anything, but no, this little chap is just creeping above ground.

Admittedly at first I thought he was a weed, so I have him a light tug, usually cos weeds are peely wally chaps they just come out, but Ian, he's got a lot going on underground, so I'm going to leave him be.

Tuesday, 3 May 2011

Moaning about: Reed Job Index

I have discovered a marvellous thing, The Reed Job Index

Its a bit of the reed.co.uk recruitment website where they track the total number of job vacancies listed, and provide information by region, sector and also salary levels, showing what sort of jobs they have more or fewer vacancies for. Its updated monthly, and they produce an annual infographic.
You know how I love graphs and infographics, I think its great. Its so easy to read, digest and process. Their information all goes back to December 2009, sixteen months ago.

They do a brilliant job of handling the data, far better than I could do by myself.

Regular readers of my online ramblings might have discovered that my previous blog has mysteriously vanished. Some conspiracy theorists would put this down my disregard of injunctions and superinjunctions when blogging about political and legal matters, others may think its some kind of fault with blogspot, or maybe I've made it private and not invited them cos I hate them, or maybe for extreme theorists, I've died. None of this is the case. What actually happened was that I deleted it, cos that's the reckless and crazy kind of guy that I am. You knew that already, right?

An unfortunate side effect of deleting my blog is that now I can't go back and check when I started tracking the number of jobs from the Reed.co.uk website on a ruddy great google docs spreadsheet, and creating rubbish Excel graphs and summaries of the UK's job market. I vaguely remember posting stuff back in early 2009, and then writing update blogposts every month or so whilst I wallowed in unemployment and depression, searching for some way I could become a productive and creative member of society, earning my way in the world, applying for jobs in internet PR and Marketing and anything that would combine my love of spreadsheets and graphs with gainful employment.

According to Reed.co.uk, "The Reed JobIndex has quickly become a respected measure of the state of the UK's job market, being widely reported across the national news media.", they have a long list of press coverage from organisations like the Bloomberg, the Independent and BBC.

I feel a tiny bit bitter that my pioneering work demonstrating the possibilities and the public interest in such data, doing much the same thing as the Job Index but months earlier, has been ripped off with no credit given.

Maybe Chief Executive James Reed is sat in his office off Chancery Lane in London, glorious blue skies outside, he wishes he was out in Lincoln Fields eating ice cream. He glances at the mounds of work, looking at his hourly updates, or the minutes from meetings, he sees that the Reed Job Index has gotten some more mainstream coverage.

He presses the button for his secretary, "Liz, who was it who came up with the Reed Job Index idea?" he asks.

"I'm not sure Jimbo, I think it was that odd one in Marketing who doesn't usually do any work, just reads blogs and checks website traffic" she replies.

"Well give them a pay rise anyway, they deserve it."

"Sure thing Jimbo!"


There's probably a financial value for the Reed JobIndex, and I'm going to carry the thought that some small percentage of that is owed to me.

Sadly, due to me rashly deleting my old blog, I have no way to prove anything. Its all but a twinkle in my eye, a splash on the bathroom floor.

Well, there is of course the google cache, which is a metaphorical discarded tissue, by the side of the bed.

Monday, 2 May 2011

Fitness Regime: Spring 2011- kicking Winter's ass

Weel, my most recent fitness regime is going great. By some feat of technology I still have my spreadsheet from my last tranche of cross-trainer addiction, so its easy enough to add another few columns and track my progress against how I did a few months back.

We acquired a small cross trainer about a year ago, its a bit rattly compared to the ones you get in proper gyms, and the electronics are a bit basic, but its good enough for my purposes even if I do have to oil it up with WD40 every two days.

Back around Christmas I felt I was getting a bit fat, the reflection in the mirror had more jowls than I remember and the way my stomach spilled over my belt was a little sickening. So I got on the cross trainer.

My strategy would have two main tactics:-
Aim to exercise every single day
Every day do a little more than the day before, either faster or further


See, I reckon to really lose weight and get fit, its not enough to occasionally go to the gym, or while away an hour or so with a stroll. No, you've got to push yourself, not to the peak of human perfection, Lynford Christie, Zola Budd, Daly Thompson, Usain Bolt, better than everyone else in the world, just a little better than you were yesterday. That's all its takes.

Followers of my internet ramblings may remember the tumblr what I started back in January, Fat Ill and Ancient, that kind of petered out after around 40 days. I grew bored, or caught a cold or just didn't feel like exercising for a few days and by the time I'd skipped three days, the dream was over.

Now, some way into April, I noticed those jowls returning and my belly had no definition or recognisable muscles, so I hopped back on the cross trainer and started again.

That was about three weeks ago. Now look at this graph.

This graph shows that compared to day 20 of January's fitness regime, I've gone about 40km further. Admittedly crosstrainer kilometres don't map jogging kilometres very well, but I've done 50% more than I did fourth months ago.

Not only that but back in winter, it took me thirty-five days to build up the stamina to do the great 25km distance in one day, whilst this time round I've built up the stamina in half the time.

Not only is my distance better, but check out this graph.

This graph shows the average speed for each session. I don't know about you but I can clearly see that this time round, I'm going a lot faster than I was last time. I'm averaging 21.5km/h, compared to 20.5km/h last time.

I rule, I so kick the ass of my three months younger self. If I had some kind of time machine, and went back three months, and by some convoluted chain of events challenged myself to crosstraining race, I would so win. In your face 32 year old me, cos 32.5 is where its at. YEAH!

But I hear you ask, what does this mean in more visual terms?

It means, the first inklings of a six pack.

Ladies, steady yourselves.

Sunday, 1 May 2011

Plants and stuff: An comprehensive introduction

Yeah, so, like, I'm growing plants at the flat. We acquired a multipack of seeds from possibly Wilkinsons on the high Street and planted them in compost in these dinky little pot things on the windowsill.

They take a lot of love and attention, well, watering and occasionally turning them round so they don't grow all lop-sided. For the sake of bloggery I've named them all.

This is Tim, Chris and Chris Tomato. They're doing quite well, the rest of their pot brethren have already been transplanted to bigger pots.

These are the Jockrock Tomatos, named after a website I used to frequent. They're doing okay, strapping great chaps, half of them have gone on to bigger and better things.

These are Franklin and the Power Pack Tomatos, named after some back up story from the Thundercats Marvel UK comic back in the day, they're teeny tiny, Franklin is the tall chap in the bottom left.

These are the Reinforcements from Cybertron Tomatos. They're going to grow up to be complete monsters, world beware.

Could be basil, I'm not sure, they haven't really grown much in the past week, I blame thems not being tall enough to get any sunlight from over the edge of their pot, so its their own fault really.

Nearby on a table in one of those propagator things we have a vast assembly of beetroot.

They're just starting to get a grip on this whole being a plant thing, they only put in an appearance above ground a few days ago, no distinct personalities have emerged yet.

In the bathroom, we've set up a staging area for plants that are too big for the windowsill, but not quite grown up enough for the outside world. I'm hoping to toughen them up on a diet of piss-drips and shower condensation, that'll turn them into real plants, like me!

This is the Baron Tomato, you don't mess with him.

I dunno what these are, I didn't plant them. Some kind of vegetable perhaps, just gonna have to wait and see what they turn into.

These are Nick and Chris Tomato, they're brothers.

This is Amelia Tomato, she's pretty cool in her own way.

These are Sarah and Susan Cucumber, they have a load of sisters who are hanging around outside, but we're going to keep these two inside for another week or so.

This is the Anorak vegetable assembly, named after a messageboard I used to frequent. Lettuces and onions apparently, although they're a bit peely wally the now, a bit more love and attention and water and sunlight and maybe they'll get their act together as vegetables. The long stringy things are the onions, but I don't see how they're going to become more onion-like.

And this mob is the Bowlie collective of tomatos, natch.

Out on the fire escape, we're blocking out fire escape route with some of the more hardly of our plants in a small array of pots.


This is Colin Rhubarb, he's not looking very well, he's only been out here for two days and hasn't really done much with his time.

This is Deborah Chives, she's lovely. Already we've been giving her a trim and eating her leaves with our salad and cheese. She's got this yummy oniony flavour just like chives. And she still loves us, I can tell cos of the flowers. We did go through a rough patch with her, we weren't watering Debs as much as we should have done, it was my fault really. I still feel bad about it, but we're okay now.


This is Louise Mint, she's yummy too, branches and leaves tumbling all over her pot like a malestrom of minty goodness. I think I used some of her leaves in this lamb marinade I made the other week, but other than that we don't use her leaves half as much as we ought to.


Nina Raspberry ain't growing so well. Out where I work, next to a sewerage works there's all these brambleberries and stuff and they love growing, you can't stop them, but their cousin Nina Raspberry, she's hardly grown at all in the last two months.

This is Rosemary Rosemary, she's a rosemary plant. She goes quite well with lamb too, or if I'm feeling bored and no one's around I just snarf one of her branches.


These are Sarah, Tabatha and Pauline, they are coriander, sage and basil respectively. The Coriander is doing well, the basil less so, poor Pauline.

Down in the actual gardeny bit of our garden, the soil is really poor quality. I think there used to be a patio on one side, so it all sand and stones and on the other side, its really dusty and the neighbourhood cats have been pooping there for years so the soils really acidic.

We're slowly sorting it out, I've got a midden for kitchen waste slowly composting away, and we're digging up and sieving the more compacted bits. Really hardy plants can just about survive in the grown, the medium hardy plants are going into a polythene tunnel of love, but most of the tomato and cucumber windowsill alumni are going into growbags and big plant pots.

This is Redtree Stolenfromwerk, he's a red tree-like plant thing that I stole from work. He seems all right in the ground, he hasn't grown much in the last month, but he doesn't look like he's died either, so I guess he's doing okay.

This is Huey Lewis the apple tree, I bought him for £7 from Tesco a few weeks back, I thought it was a bargain.

This one time 28 years ago, I tried to grow an apple tree from seed. I went quite well, upgrade from yoghurt pot to small plant pot to large plant pot over two or three years. I remember it got really tall, about five foot, and then somehow I lost it or forgot about it.

Anyhoo, this thing I got from Tesco was about five foot of apple tree, a dry stick with a small rootball at one end, Huey Lewis. I planted him in a fair sized pot, I give him love and affection, keep him watered and in the sunshine and well, he's still just a dry stick. I keep thinking that there's bits of new growth, or his bark looks less dry and more healthy, but I'm just fooling myself.

This is the Dying Bathroom tree, he's been with us for a long time. He used to stay in the living room when we lived in Wembley and was happy there, but when we came to Walthamstow, we moved him into the bathroom. The new climate upset him a little so we thought we'd put him outside to get more fresh air and sunlight, but that made all his leaves go brown so we brought him inside again. After a month or so in the bathroom, the season had turned so we are trying him outside again, but I reckon he's a lost cause.

This is Kristin Gooseberry, she's a bit of a lush.



These three chaps are called Neville Johnson, Paul Johnson and Phil Johnson, they're tomatos, they live in a growbag together. I think I might have been a bit premature putting them in the growbag, as they haven't grown much since the move. In fact Neville has developed these freckles.
I'm a little bit concerned, but there's not much I can do. Neville's going to have to soldier along and sort himself out.



Next to the Johnson brothers we have Carlos, Cecil and Colin Cucumber, they're brothers too and also live in a growbag, but its a different brand to the Johnsons. I think there's a little neighbourly animosity between them, but they also seem to be suffering from being outside, although the Cucumbers do get a little more sunshine.

This is Paul Pumpkin, he lives in a polythene tunnel of love because we were scared that the cats would have a go at him when we first moved him outside. Paul is actually planted in the soil on the former patio side. He's doing okay, gets plenty of sunshine, and we keep him watered, but he's not exactly thriving.

These tomatos are Huey, Dewey, Andy and Louie, they share Paul Pumpkin's polythene tunnel of love. They've only been in that soil for a few days, I think the sunshine is doing wonders for them, it'll be interesting to see how they get on compared to their growbag brethren.

Shares and Stuff: A brief introduction

Yeah, so right, cos I'm all grown up now, I thought I'd invest some of my wealth in the stock market, or slightly more specifically, buying shares.

It was a rather pleasant surprise to find that the HSBC, who I've banked with for a number of years, have a share investy account thing which is really easy to set up. Just a few clickety clicks and a patient wait for the paperwork to go through, and I have an InvestDirect sharedealing account. This would enable me to buy and sell shares.

Now all I had to do was find some share to buy.

I've found that the easiest way to find companies to invest in and to track share prices is with Google Finance. To start with you search for companies, it tells you the share price and similar companies. What you want to do is find companies that you think are going to do well.

A brief sojourne...
Twenty or so years ago my mum was getting into the buying shares game and asked my advice, I suggested a company called Virtuality Group Plc, who in the early nineties pioneered virtual reality arcade games. I thought, this is the company of the future, Mother, invest now.

How could they fail? I mean, c'mon, VIRTUAL REALITY!! Sadly, they didn't become the new Microsoft, the new Nintendo, Apple or Google. And as home computer processing power increased, their products became pretty much pointless.

Sorry Mother, you asked the wrong twelve year old for stock market advice.


This time round I thought a bit less imaginatively, Royal Bank of Scotland (LON:RBS), for their shares fell about 95% in the credit crunch and subsequent government bailout, from almost £7.00 to 19p a share. Imagine if you had £10,000 tied up in them in 2007, that would be worth about £300, after the crash. You'd be ruined. But my thinking is that the company is much undervalued now, sure they were a bit over-priced before the crash, but their low price now is more a symptom of investors not wanting to touch them with a barge pole rather than an honest valuation of the company. Get the shares now whilst they're cheap, and give them a year or two and I reckon you'd easily recoup.

Another company that caught my eye was Halfords (LON:HFD), the bike and car parts superstore. We are in a recession, everyone's skint, but we still need summer holidays and the sun is shining. So, instead of jetting off to Malaga, folk are going to be driving to Mallaig. If I'm right then in the middle of the summer Halfords is going to be booming, and I could make a profit.

A third company is Kenmare (LON:KMR), they mine in Mozambique, and since May 2010, their shares have more quadrupled, going from 9p to 40p. £10,000 invested this time last year would be £40,000. I reckon they haven't peaked yet, and once their new mine starts churning out whatever magic metals they can find, then the sky's the limit.

So, I've bought myself shares in all these companies, only £250 in each, and the £12.95 commission on each transaction. But, I hear you ask, where do I get this money from? Well, I'm skint, so this money has come out of my overdraft. Its magic money plucked out of the air. But that's okay, its only if their value falls that anyone loses money.

A week passed. I got scared that Royal Bank of Scotland was going to crash again so I sold my share in them at a loss and bought more in Kenmare.

That was probably a mistake too, they were doing their annual salary negotiations with the workforce in Mozambique, and the workers went on strike and shut the mine down.

No matter, the weather's been good and Halfords shares have gone up by about 10% since I bought them. Wehay!