Transition from geek to luser

I’ve been becoming more aware of the fact that I spend more time fixing my home computer than doing productive stuff on it. This in days gone by was not an issue, but I’m really getting sick of Windows doing the funniest of things. I’ll admit that I have not been inspired to cough up the money to upgrade from 2000 to XP, but I probably should (If only for Media Player version 10). Maybe I’ll wait for Vista and get a new computer to run it at the same time. The latest round of really odd behaviour is that each time I log out, my user profile was deleted, and upon next login I’d be presented with a clean user profile, very annoying. Also at times the Administrator could not delete/move files that were created by my user account, which just violates the principle of logging in as Admin.

I suspect this came about because ~2 months ago I re-installed the machine to sort out the difference between my user account and the Admin account. For about 4 years (on NT also) I had been using the Administrator account as my everyday account. Made setting up software easy, but I knew it was wrong. On the original 2000 install about 6 months ago I created a Simeon users account and started using it. Not all my apps were happy to now run as Simeon. So I moved all my important files/data onto my second HDD and reformatted/installed 2000 on the first. Both disk were NTFS, but only one was reformatted, and I changed the system name, so the second disk had files owned by some “person” that is did not know. So I ended up fighting the volume quite a bit, taking ownership etc. For a few weeks this seems to all work, but things that didn’t work were Microsoft Update and other apps still were not always happy. So last night I got sick of losing my profile and reinstalled the system.

This time I backed up every thing to the first disk. Formatted the second disk to Fat32, copied all the backup data onto the second disk. Reinstalled on the first then merged/sorted the data/files. Other than been up till 4am (take that Mayo) I’ve almost completed the install. I’ve had no user profile issues, Windows Update works a treat.

At the same time I’ve decided to stop using The Bat! as my email client and try Thunderbird. It would seem the sensible thing to-do as I refuse to go near Outlook Express.

There is still another evenings work checking apps are happy and reinstalling things like Office, Media Player, Messenger, RSS Bandit.

Sometimes it would be nice if it just worked. And it’s at this point in my though process that I realised I’ve become someone who just want to get stuff done, and I don’t really care for the sake of caring any more.

AJAX Blogversation

Tim from the New Zealand .Net User Group has put up a blogversation about uses of AJAX to enhance his shopping cart software. So I’ve never done any AJAX development let alone ASP.Net development. Any how, while not shopping carts a place I think that could really get some again from AJAX is real estate sites. They are painful.

The first area I think that would get the best again is searching. Avoiding the complete screen re-draws on country selection and again when you enter your region. But that’s the obvious place. The next improvement is dynamic search result size. Normal the search page lets you select the suburb/s, room count, price min/max. Now if as I adjust each one I see how many matches/entries this will be I can adjust my search. This would allow you to gage the price hotspot for a suburb/area. Heck you could even start streaming the textual details after a small delay, and also stream the pictures as a lower priority stream.

Bandwidth management is also something I could imagine could be managed in an AJAX style managed way (user driven or just dynamic). The client side code could evaluate the download time, (even have a UI widget for pipe size) then change how data is sent. I say this one because I have dial-up at home, and waiting for high resolution pictures to load (watch the sky load) to get to the middle of the picture and decide I dislike the view, verses have a low resolution picture, and wanting to see better detail. Even a low resolution b/w picture would give to a good idea. Sort of how Google Earth works (even though that is a client side app)

So not really sure if that relates to a shop, I would love to find a real estate site that was not brain dead. While a real-estate magazine has bad search and low number of pictures, the scan rate is really nice and fast, so I’m not sure how you can allow the quality random access on a web site. I’ll have to think some more on this…

The Price of Printing Digital Photos

Michaela and I had stockpiled a years worth of digital photos that we wanted to print. After spending an evening reviewing the 2 gigs of pictures (~1000 pictures). We then reviewed how to get them printed.

We have used FrogPrint in the past, and have no issues with there service. Having a dial-up connection I was not interested in uploading 280Mb to their site. You can send them a CD but I wasn’t interesting in paying to send the CD and then paying to get the photos back. More of a point is their price is $0.60 (100+ run) per picture.

The local Warehouse I only have to pay $0.3729 on a 24 exposure film. Their digital printing can be done the infinitely crappy Kodak picture maker, or on the same machine that is used for normal film. I could not find online there digital print price, but last time I was there it was also around the $0.60 mark. I’ve used this service for one off print enlargements, paying ~$2.00 for a 10 x 8 picture was wonderful as it took longer to chose the frame than get the print done. But still the price difference doesn’t seemed justified when it’s the same machine used to print the photo’s, and yes a technician might have to do a little more, but they are managing the machine anyway, so I’m not really sure there is a justifiable cost increase.

The winner on the day however was digitalmax with their $0.38 per print price (via the $20 prepay card). The best part was we could take our CD of pictures to the local pharmacy, and get the pictures back the next day with no shipping cost incurred, and we only need to pay for the number of picture we had printed at the $0.38 price.

One point to note is that we had 70 of our photo’s take at 5M pixel (6inch x 4.5inch) and the rest at the 3:2 (6inch x 4inch) format. So the 70 larger pictures where printed onto smaller paper (13 x 10cm or 5.3 x 4inch) so that the images were not cropped. This happened due to the instructions been “one of each”. When talking to the print company (not sure who they actually were) the guy said to use “all at 6x4” and then the pictures will be auto-cropped. This would have looked better in our photo album. To give the print guy credit he did say they could reprint them, for free was not explicitly mentioned, but I’ll assume it otherwise the comment was pointless. We didn’t take them up on this, but we will more precise next time.

So my real point is: why does it cost 57% extra to print from a digital media source to the same photo paper as does when processing a film. Processing the film cannot be free, so the price difference is even more. I just feel like I’m getting milked, and I don’t like it. Sure there is cost in having a web front, and the cost a normal shop has will be absorbed/shared across all product sales, but it still seems a high premium to be paying.

digitalmax have a service with a price point that I’d expect, and a willingness to be helpful. So I know where I’ll be going in the future.

Programming Challenges Problems

Here’s the list the 21 problems I’ve solved on the Programming Challenges site.
If any ATR people have solved more I’ll have to start solving them again…

110101 The 3n+1 problem
110102 Minesweeper
110103 The Trip
110106 Interpreter
110107 Check The Check
110108 Australian Voting
110201 Jolly Jumpers
110202 Poker Hands
110203 Hartals
110207 Contest Scoreboard
110301 WERTYU
110306 File Fragmentation
110308 Fmt
110404 Longest Nap
110405 Shoemaker’s Problem
110406 CDVII
110504 Ones
110805 Tug of War
110903 The Tourist Guide
111302 Rope Crisis in Ropeland !
111308 How Big Is It?

The problems I can’t/haven’t solved and would love to hear of solutions for are

110104 LC-Display (edit 2008: now solved)
110206 Erdos Numbers (edit 2010: now solved)
110208 Yahtzee (edit 2010: now solved)
110307 Doublets
110801 Little Bishops
110804 Servicing Stations
111002 The Necklace

[Edit 2010] I have a newer, complete list here

Competition Programming

The art of know all the required tricks, and just “getting” the problem, and writing the solution. I have so much to learn.

I entered TopCoder SRM 258, and end with a zero score for the second time. But this time at least I submitted a problem that I thought worked. My score is was not too affect this time and I’m still in Division I. I plan to turn the slope of this graph around.

The first problem was calculating the interest rate given the start price, monthly payment and number of months. I’ve done a lot of self discovery in the finance area driving by our (Michaela and me) desire to purchasing a house. The problem reminded me of my book of formula’s so much I couldn’t get over it and just write a program to solve this problem. So after the event was over last night I worked on it. I almost had it solved correctly, but the way I was generating the correct interest rate was ugly (it just required a binary search due to the limit of 0% to 100% stated in the problem) and the exit conditions. The latter was a bigger issue. The problem stated 1e-9 precision, so I comparing the money owning at the end of the term to 1e-9 not the interest rate. So using the binary search also solves that problem.

The second problem was a compression problem. The problem that got my code rejected was a challenge of “ASD”. Although the problem stated the input was from 1 to 50, I had thought that the two compression keys needed to be unique, thus my inner loop would not use the same key as the outer loop. There was also a problem where my inner loop was from 0 to n-1 not n as it should have been. But looking at other peoples solutions I worked out that one correct way was to use Dynamic Programming, which I had been reading about that morning. So failing to spot the change to use it make me feel a little silly, but boy, from now on, DP is going to be on my check list.

The third problem was a really hard DP problem. Work out the probability of each play (1-4) winning a game of snakes and ladders (though they used a different name). That just messed with my head. But the people that did get it had very compressed but elegant solutions. Another learning opportunity.

Anyway the first two problems were opened, read, coded, tested in 5 minutes by the best people, so I’m just thinking they really grok there comp sci algorithm courses.

TopCoder - Single Round Match 257

Well, I just completed the TopCoder SRM 257, and I didn’t even get one problem solved.

The first problem was find the minimum error ( difference ) for a weighted average.
You used 5 weights, with a sum 1.0, that last bit (sum of 1.0) I forgot, so spent the whole time trying to workout why my result was different from the example. Also the run time was too long for the bigger dataset. Not till coding phase was over and I started reading other people solutions did I see my error. GRRRR. So I’m not sure how badly it will affect my ranking, but I’m think its going to hurt. Maybe I’ll get put into the second division, which will be easier, but not as much fun as playing with the big boys in Div I.

So tonight instead of doing game development, I’m going to solve the other two problems that I didn’t even start.

Programming Challenges

Was reading Marks July 15 post, and remembered about my Programming Challenges time. Back in November 2004 I found the site, and start solving the problems. I shared the site with the people at ATR and some internal competition started. The site also had a phpBB attached, where people would ask questions and nobody would answer. So I decided to be the person that at lest acknowledge the persons question even if I did not know the answer. Most questions could be answered by repeating the answer given the day before. I am not sure if it was the new user base that just didn’t understand the concept of search before ask. The more annoying thing was there were problems with the problems, like solutions that worked on the bigger UVA site. The sites phpBB was pulled done earlier this year due to it been hacked, and has not been replaced. The site admins never answered any questions, so it would appear to just be a pretty version of the UVA site, to help sell their book. I’ll admit the site gave you the error output when you code fails to compile which UVA does not. The small problem set also makes the site less intimidating.

While the phpBB was still active I was discussing the above problems another coder, who suggested TopCoder, describing it as having good feedback, and the chance to win money. So I promptly signed up there and never did anything about it.

So last week I entered my first algorithm competition, man it was fun. It was a session sponsored by the NSA, so they had a few people in the chat room for an hour before the competition. The competition it’s self was fun. The third problem was simpler than I first thought so I wasted a lot of time thinking I couldn’t do it. Then added extra code that wasn’t needed. So now I’m in Division I, and the problems look a lot hard. You start in Division II when you are unranked. I’m keen to compete in the next competition that happens in my time zone on the 8th. This one has cash prizes, but I’m not expecting to get any. Here the my TopCoder profile in case you feeling competitive ATR people.

Curse of the Azure Bonds Project

So I thought I’d write a little about my current development project. It is a port to the .Net platform of the SSI classic “Curse of the Azure Bonds” (which I refer to as coab, but I guess there really should be a t in there). This project started in February of this year when I decided to work on Coab instead of Pool of Radiance (the first in the SSI AD&D series).

So I used the ever trusty IDA Pro from Hex Rays to open the game up, but like a lot of games from this period, the game was compress/encrypted. I got bored of trying to manual decode it, so I used the very helpful debug.exe to decode the game for me. After single stepping through the decompression code a few times, I wanted to dump the ram image of the game. I could not workout the syntax for the write to file command, so I dumped memory to screen. Dump to screen would only do 64K sections, so I needed to change the DI register. This ended up been done by altering the code about to be executed to alter the DI register as required. I wrote all the required commands into a text file so I could redirect this into debugger, and redirect the output to a file. This then gave me an ASCII file of the memory dump. I wrote a C++ program to parse the file and write a bin file. I then loaded this into IDA using the same offset as the original program was loaded at by debug.exe.

One of the things I’d noticed in all this was the way debug.exe loaded the game (16 bit DOS) was different to how IDA loads it. IDA loaded it verbatim and debug.exe removed one byte and altered the next.

Anyway with the uncompressed image now in IDA, I spent a week rebuilding the segment table that the game used. I then found my IDA scripts I had written back in 2000 while working on Pool of Radiance and used them to load the overlay file, and correctly re-write the jump tables etc. The first problem I found was that the scripts that I had were not the last version I had developed when working on PoR due to back-up issues, so I spent a week rewriting the scripts. I also fine tuned how they did there work. Once I did that I started to decode the functions, but soon noticed the library functions were all unmarked due to the flirt engine not have been run. So I load the original decoded bin file again and found out how to force the flirt engine to run. I saved off the changes. Somewhere in there I either applied the changes to the work in progress, or just started again with the flirt version, ether way, I started making progress on decoding the game.

This carried on for about a month in total, when I noticed that even though I’d dump 192K of the decoded game memory, I only had ~70K of it in IDA, I then double check the dump procedure, and the ASCII to bin program. In the end the problem lay in ASCII to bin program as I’d put a limit in there for testing (~4000 lines) that was stopping parsing before the end of file was reached. So I re-parsed the ASCII file. Then I wrote a IDA script to import the missing file at the correct point, and extend the segments to deal with it. The original problem was that the data segment was half missing. With this resolved more of data look-ups in the code made sense.

Another month passed, and I now had a pretty good understanding of the game structures used by the game. The biggest problems were the verbosity of the assembly code. So around May I start writing a C# program to translate the assembly code into C#. The first thing I did was create files from the segments. There were about 50 memory segments in the game due to the overlay memory management system. Then I got function blocks parsed and correct C# replacements. I then worked on parsing the parameters, and local variables. All the rest of the assembly was written in as comments.

At this time there was\ ~110K lines of assembly to translate. I started from scratch a few times due to errors in the translator, but I ended up getting good at writing Visual Studio regex to match the asm. In reality the fact the original game was un-optimised Pascal was quite nice. Structure access and assignments are done the same each and every time. The one thing that is very annoying about it been Pascal based is the base 1 arrays. Because the global data segment would have a single address used as a byte, and as a word array, and you need to sort the two usage’s out. This is one place IDA is (or I should say was as I’m using a older version) not to great at.

It is now August and there are only 24,485 lines of assembly left in the code. There are ~2.5K errors to deal with, mainly steaming from parameter mismatch, and C#’s overly picky maths rules. But it’s a work in progress. I’m really enjoying working on it.

IMGUI Design

I’ve been reading Book of Hook for a while now, and a few weeks ago on the Game Development forum he posted a link to his friends site Molly Rocket where Casey had a cool video of his immediate mode graphical user interface. Having been spending the last few weeks bashing me head against gotcha’s in RMGUI’s (.Net Winforms) I could see the value in building UI’s this way. Not for apps like we have here at work, but for real-time stuff it makes a lot of sense. So anyway, it helped me by putting some names to idea’s that were in my head, and describe different ways of doing stuff. It also allowed to see area’s where our current code could have issues, due to the nature of the UI model.

All-in-all very much the classic way stuff was done in the old days before windows, but cool to pull it back off the self to see where it’s still applicable to modem development.