chrss (chess by rss) update 21

November 26th, 2007

Another update to chrss.

  • tweaked front page layout to make it clearer and show different options depending on if you are logged in or not
  • addition of a help section (with backend CMS for myself to add content to it).

At the moment the help section is not directly linked from the front page of chrss. I need to get some more content in there and figure out where best to link it.

When developing in your spare time automated tests are your best friend

November 22nd, 2007

Well I just finished fixing a bug in chrss and it’s made me very glad that I’ve been using automated tests.

The bug looked like it might be very tricky to track down and I feared that it might get messy. In the end it proved to be a slight edge case I’d not catered for and was pretty easy to fix.

First I quickly tracked down the stack-trace in my logs:


  File "/home2/lilspikey/webapps/chrss2/chrss/controllers/game.py", line 226, in move
    game.make_move(game.turn,move)
  File "/home2/lilspikey/webapps/chrss2/chrss/model.py", line 239, in make_move
    self._record_move(chess_game,color,move)
  File "/home2/lilspikey/webapps/chrss2/chrss/model.py", line 202, in _record_move
    incheck=chess_game.in_mate()
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 213, in in_mate
    return self._board.calc_mate(self.game_state)
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 915, in calc_mate
    can_move=self.any_legal_moves(game_state)
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 990, in any_legal_moves
    legal=self.legal_moves(game_state,pos)
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 984, in legal_moves
    return self._filter_check_moves(game_state,moves)
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 1029, in _filter_check_moves
    board.move_piece(move) # make the move
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 1103, in move_piece
    moved_piece,taken_piece,castled,enpassant,updated_positions=self._calc_move(move)
  File "/home2/lilspikey/webapps/chrss2/chrss/chess2.py", line 1081, in _calc_move
    raise ValueError("illegal castling move")
ValueError: illegal castling move

Next step was to create a unit test to replay the moves from the game with the problem. Once I’d got it failing in the same way, I discovered a bug in my logic that meant rooks captured without moving would not update the “castling status” for that side. This led to falsely generating castling moves that weren’t possible and thus the failure in the stack trace (some defensive coding to stop this kind of thing). In this game in particular white’s queen-side rook had been captured without moving and my chess module was reporting that the king could still castle queen-side!

After getting it to work I now had a nice automated regression test for that bug. I also took the time to add a unit test for the actual function that I changed.

Brilliant stuff. Now I can be extra certain that bug is fixed and will stay fixed, as those tests will get run every time I run my test suite. I’m working on chrss in my spare time, so this is really important to me. I really don’t have time to spend manually testing and verifying that _everything_ works.

The more testing I can automate the less testing I have to do. Which means I’ve got more time for adding features or else playing games of chess!

Developing your £5 app

November 17th, 2007

Last Saturday as part of the Brighton Digital Festival Ian and I held the £5app day at the offices of Sensible Development.

Ian has a fairly in-depth write-up on his blog of the whole day.

I shall be providing a brief summary of “Developing your £5 app”. Neil and I led a discussion/presentation on how to develop software in your spare time.

I’d prepared only about 30 minutes worth of material, but the discussion proved very constructive and we quite happily managed to talk for well over an hour.

I provided some talking points for roughly three areas of development:

  • Getting going - the very first things to consider
  • Sticking at it - how to keep on going once you’ve got started
  • Scaling up - planning for the future and/or success

Possibly the longest part ended up being discussing the pros and cons of language choice. This is the kind of thing that can often end in flamewars on the internet, but things remained quite cordial. General consensus being that a more “dynamic” language may well give you can edge when developing, but you may well have other issues to deal with instead. The case in point being PHP vs. Lisp. Lisp is a much more powerful language than PHP, but PHP is very easy to deploy on a web-server. Whereas with Lisp you are largely speaking on your own. The middle ground of, for example, Python or Ruby, seemed to represent a sweet spot in terms of ease of development, without being too unusual to make hosting a major difficulty.

One other interesting consideration was how to go from being a single developer working in your spare time to a team of people. Neil, who has plenty of experience with this sort of thing, provided the succinct answer that “growing a team is hard”. However he believed that if things were done “right” early on when starting out small, it made life a lot easier at the other scale of development.

All in all I think the “Developing your £5 app” went well. As usual not a lot of preparation happened before hand (I’d been too busy with work and organising the £5app day itself), but I often find that can work quite well. Definitely helps keep things from seeming too inflexible.

Cherry Blossom Tree

November 15th, 2007

img_4760.jpg

Cherry blossom tree
Quite a satisfying way
to finish this day

chrss (chess by rss) update 20

November 6th, 2007
  • Updated the user registration process, so hopefully it’s a bit friendlier
  • Users now have a chance to resend their activation email if they have trouble activating their account
  • Tweaked filters for games on user’s page:
    • “active” - games that it’s your turn in or have had a move in the last 30 days
    • “waiting” - un-finished games that aren’t active
    • “finished”
    • “all”

Also improved the code coverage some more.

On a side note there is a preliminary mobile version of chrss available now. However I wouldn’t recommend it for regular use, as making a move currently involves a _huge_ drop down menu. Less than ideal. Still it can be handy for checking whether anyone has move. I’ve got some plans on improving the usability in the future, so check back later to see how it’s doing.