Thursday, July 31, 2008

Thoughts on test driven development

At the start of May. Simon and I redid the database layout for Sutekh, and, since then, have been working on fixing all the fallout of that. I recently spent a bunch of time working on finishing off some parts of the transition. Since we had a good idea of what the code should accomplish, I ended up doing most of this in a very test-driven fashion. Since most of my work is much more experimental in flavour, and doesn't thus doesn't lend itself to strongly test-driven development, it was an interesting exercise.

Some observations
  1. Having the test available is nice, especially given the number of interactions involved
  2. It tended to get sucked into "let just get this test working", and, as a result, the first version that successfully passed all the tests is a poster case for the difference between "working code" and "decent code". I'm still busy refactoring the code to amalgamate common bits, and there's still considerable work before the code is maintainable.
  3. I frequently erred towards being overly concerned with not breaking the tests. I ended up duplicating code unnecessarily in places as a result.
  4. Refactoring is made easier by the test, though.
  5. Largely as a result of 2, I don't actually have that good a mental map of the code, which feels rather weird. Spotting repetitions between the different code paths is thus quite time consuming.
  6. I do have quite a lot of confidence in the tests.
A fair bit of this list boils down differences in the manner in which code is produced. In my usual development model, by the time I'm satisfied that the code is doing what it should, I've spent a lot of time worrying about specific details and all sorts of implementation issues, and consequently, the code is vastly more polished. Here, because I was usually focused on short term gains, I have something which does what I want, but still needs considerable work before I'll regard it as complete. Also, as the list illustrates, I made the error of treating this as a bug-fixing exercise, rather than as development, so that's something I'll have to bear in mind in future. Point 5, though, is the real problem, though, and I'm not quite sure how to fix that, although things should hopefully be a lot better by the time I finish refactoring.

Still, despite my complaints about the resulting code, it did make the development a lot easier, and, for a part-time project, being able to deal with it in the smallish chunks of "let's get this test case working" did make it much easier to maintain momentum via visible results.

Wednesday, July 30, 2008

Stuff from the Day-job

So, after a couple of weeks of much intermittent panicking, we commissioned the latest version of the patient positioning system today. I feel rather chuffed about the whole thing at the moment, since it's always nice to see one's work used, but I could have done with a less stressful last two weeks.

Since the last version was commissioned (November 2006), several chances have been made. Most significantly, the control and drive systems for the chair were replaced. The improved electronics allows great accuracy, and the updated control system fixes the numerous problems with the old version. The vision system received polishing - various inefficiences were ironed out, and the code is generally much less fragile, and numerous bugs on the front-end were fixed. All in all, the new system represents a significant improvement, and is the result of lots of hard work by the MedRad development team.

As the panicking comment above suggests, the comissioning process did not run that smoothly, though. Things that went wrong varied include the serious - I had to rework and significantly simplify parts the lens distortion code due to issues with the repeatability of the results (trading theorical accuracy for practical reliability, which was the correct choice, but I will need to revisit and fix that code), the daft - a stupid error in the mathematical formulation, that all of us who looked at it missed completely, meant the final collimator rotation was only correct in the range 0 - π (Of course, the standard QA tests we used during the development phase only cover that range, so we didn't pick this up until quite late) and the standard - the spare box, which also needed to be updated booted fine, but completely failed to see it's frame-grabbers, so that had to be hastily rebuilt (leaving us short of additional spares for now), combined with all the usual last minute bug-fixes, but it is complete, and the accuracy figures do show a statistically significant improvement in the accuracy. Considering that the previous system was already accurate to within 0.5 mm, I'm pretty pleased with that.

Thursday, July 24, 2008

The Final

So, final table went better than I expected - I wasn't ousted, and got 1 VP.

Table setup was Mike bleeding Verolin bleeding Val bleeding me bleeding Dan, with Mike starting.

It was definitely a table of people's decks not working as designed - Val got off to a fast start, with enough stealth to avoid his fee stakes being blocked, and dropping an early Reckless to hit me for 5. I brought out Rodolfo, who fairly quickly lost his title due to 2 No Confidences being played, and Korah, while Dan brought out Joe 'Boot" Hill and Basir. Mike got an early Information Highway again, and was off and running quite fast. Both Dan & I were reluctant to bring out a 3rd minion, because we knew Mike would be playing recalled to the founder, but early on, I was able to generate enough stealth to successfully bleed Dan a few times. Verolin's deck never got going, as he ever drew a bleed modifier, and Val was quite happy to take bleeds for one.

So, by about an hour in, I had two minions out, and the powerbase Madrid, but only 8 pool, Dan had two minions, and a lot of pool, Mike had 4 minions, but was struggling a bit for pool, while Verolin was also starting to feel the pressure from Mike, with Val sitting quite pretty, largely tooled up, and quite a bit of pool. at this point, though, Val stated trying to balance the table, being worried that Mike would oust Verolin too quickly - this resulted in two Reckless's (called over a couple of turns), which, combined with a couple of bleeds by Rodolfo, left Dan within lunge range for me. I was struggling for stealth cards though, which delayed me somewhat - Verolin was duly ousted, and then I drew the stealth I needed to oust Dan - I played a Kine to which Val allowed to pass which reduced him to 1 pool, but I would have had enough bleed modifiers to oust him with the next bleed even without the Kine, but I did need the extra stealth card I drew to replace the Kine to be sure of getting past his Abbot.

At this point, I ran into a run of cards without any stealth, which meant I was unable to pressurise Mike, and Val run out of S:CE, so was unable to survive Mike's rushes, which left Val in trouble. I eventually drew stealth, and attempted to lunge, but was deflected onto Val, which ousted him (even without the determine, Mike could probably have untapped his Champion, but I was hoping to get lucky) - at that stage, the game timed out, but, since I would have been unable to survive Mike's rush actions, he would have been able to bleed me out fairly quickly had play continued.

Still, the deck worked pretty well - In this tournament, I could have used some Confusion of the Eye's or Poison Pills for additional vote defence, but it's probably not general enough in the Cape Town play environment to be worth adding. I usually had enough stealth in my hand (except for a funny run in the final), but the deck almost certainly doesn't generate enough stealth to beat a full-on wall deck. The combat defence is the major weakness, and, against imbued, the ineffectiveness of Coma is a major issue. More Mental Mazes is probably the way to go, but that does require successful blocks, can be hard to pull off, but, considering how badly the deck crashed and burnt last time I tried it in a tournament environment, 1.5 VP from the final table is a fair result.

Sunday, July 20, 2008

Saturday's Vampire tournament

I decided to give the Malkavian antitribu deck another run in a tournament - I tweaked the balance somewhat (I reluctantly removed Aristotle, since he tends to generate excessive table hate, and I replaced the confusions with more generic stealth cards). I managed a single VP with the deck, but, thanks to the scary efficiency of Val's anarch reckless agitation deck (1 table sweep, 1 near sweep), that was enough to qualify for Wednesday's final.

There were only 9 players, so the split was into two tables, one of 4, one of 5.

So, the rounds:
Round 1: I was bleeding Robert's guhuri farm deck bleeding Val's reckless agitation deck, bleeding Phillip's Aabbt deck, bleeding Garrick's Brujah equipment deck.

Robert started. I had a decent crypt draw, and was able to put decent pressure on Robert, but didn't draw enough bleed cards (I drew 1 kindred spirits in the game, and only 2 eye's of chaos's), so I was never quite able to finish him off. I erred badly in not stopping Val's Firebrand when I could have, which made it easier for Val to get the vote lock, and sweep the table. Phillip's deck got going, but wasn't fast, which left Val easily able to finish Phillip and Garrick in quick succession, before going on to sweep the table. Garrick's deck didn't really get going - he ended up spending a lot of time setting up with equipment, and a couple of bleeds by Phillip put him very much on the defensive, but he struggled to generate enough intercept. Robert didn't really get the full arm going, but a couple of well timed minion taps, and some other pool jiggling meant he survived my attacks - that he never blocked any of my actions also meant I was jamming on stealth cards a bit. Annoyingly, when I was ousted, the two of the next three cards in my deck were a Kindred Spirits and a Eye's of Chaos - given that I had stealth in my hand, and Robert was on only 4 pool at the time, had these cards come up a little earlier, I might well have been able to oust him.

The second table was Mike, playing an Imbued event deck , bleeding Verolin, playing and Akunanse deck, bleeding Dan, playing his Seraph multi-act Assamite deck, bleeding Marc, playing a Tzimisce bleed deck (no idea who started). The table timed out. Mike was on quite low pool, but Marc was never able to generate enough bleed to defeat the Imbued's farming. I'm not sure why Mike was unable to oust Verolin, since he was down to a single minion by the end of the game, and didn't seem to have much farm going, but the table indeed timed out.

Round 2:
Table 1: I was bleeding Phillip's deck, bleeding Mike, bleeding Robert. I started.

I didn't have an ideal crypt draw (two Dolphin Blacks, the General and Hannibal), and I drew a lot of Master's early on, so it took me a bit of time to get myself setup. Fortunately for me, both Phillip and Robert were bringing out 11 blood vampires (Sutekh and Eze respectively), so my slow start didn't really hurt me. Mike, on the other hand, drew an information highway in his opening hand, and, combined with the other acceleration tricks he had, had 4 minions out by the time Phillip brought out Sutekh. With Eze and Sutekh on the table, and Vox Senis down early, I didn't have the voter lock, but I was able to successfully whittle Phillip out - it was a close run thing though, as he had played the Kahabr towers the turn before I ousted him, and would almost certainly had burnt Sutekh for the 11 pool on his next turn. Thereafter, with the Unmasking down, I run into a drought of stealth cards, so wasn't able to put pressure on Mike, and with both Mike + Robert attacking me, I ended up losing minions fairly rapidly. Mike eventually ousted Robert, since timeout was looming, and then easily ousted me for the game win.

Since this game went close to timeout, I didn't see what happened on the second table - I know Verolin got 1 VP, which was apparently engineered by Val, and Val cleaned up the table thereafter.

So, reflections:
  • I probably need to add a couple of Barren's to the deck - when people aren't blocking, it's prone to jamming on stealth
  • The changed balance is better - despite the occasionally weird draws, I had fewer completely useless cards at any stage, and was generally able to go forward fairly well.
  • I need more Mental Maze's, since the Malk's remain crunchy in combat.
  • I still can't believe I only drew 1 Kindred Spirits in the first game - Sutekh's card draw probability calculator tells me that the odds of that are < class="blsp-spelling-corrected" id="SPELLING_ERROR_33">probability plugin, I'm naturally completely confident in the accuracy of the figure).
  • Outer Limits had shiny Twilight Rebellion boosters. I had little self control, and now have a number of shiny Twilight Rebellion boosters (next on the agenda: somehow secure some Fee Stakes, so I can actually use the nice shiny tech)
We'll see how the final goes on Wednesday