So I started coding again, I had to clean out the cruft and get things working the way they were meant to. There are a couple of different projects I am working on at the moment. AutoNant is Public Domain and ZoeTools is GPL. The sudoku code is loosely based on code of an unknown license (for now).
The first is a set of useful utility classes calle ZoeTools. It currently has three seperate assemblies: Algorithms.DancingLinks (a Knuth DLX implementation), Objects.LinkedMatrix (a matrix which is used by the previous assembly) and Tools.Hasher (a progressive file hasher, mainly for large files). They are designed to be stable and well-tested. If useful, I encourage you to use them in your projects.
The second is a meta-build-system. I like NAnt for building .Net projects and it is much nicer to use than autotools and make. However, it is also verbose and I was finding that I had to keep copy-and-pasting boiler-plate code. Since it is XML, I figured it would be easy to set up an XSLT-based system to create .build files from a minimal description. It did turn out awkward on the backend but on the front-end, all you have to do is create a short XML .autonant file and run it throught an XSLT processor. The trade-off is that your directory structure is standardized. There are various pros and cons for this setup but I like it. It relies heavily on symlinks though and would prove difficult on file systems which don't have symlink capability or which have awkward limited systems (such as Windows' NTFS). I would only recommend trying it out on a *nix box.
My programs are all made with development versions of Boo and Mono so you may have to grab them from SVN and build them yourself. If you install into /usr/local/, you will have to run "export MONO_GAC_PREFIX=/usr/local" so it can find the assemblies.
My first cleaning task was to change all the symlinks in the build/ and external/ directories to point to lower-case versions of their names. The reason for this is that when you checkout modules from SVN, they're in lower-case so this just makes it easier.
The next step was to tell AutoNant where to find the Boo.NAnt.Tasks.dll extension library. Unfortunately, Debian chooses not to include it in its packaging of Boo. Since I use the SVN version, it's not that big of a deal but still makes for an awkward oversight. If you download that file, just place it in /usr/lib/boo/ and all should be fine. I'm not entirely sure how I made it before telling NAnt where to find the file... What I did was add a
After that finally got setup, I was on my way and running... well, almost. It seems that one of Boo's "useful" modules was removed - Boo.Lang.Useful.IO.TextFile. This made it easy to read in a file without having to create a StreamReader. However, .Net 2.0 added a useful System.IO.File.ReadAllLines static method, which greatly shortens code to simply read in a small text file. The first example reads a line and prints it, continuing until no more lines can be read. The second reads in a text file into an List and then prints each item. So, the second actually processes the list twice but there are many cases in which the first method also processes it twice and so it's not so bad. For small files, I'm sure the effect is negligible.
.Net 1.1 (C#) | .Net 2.0 (C#) | .Net 2.0 (Boo) |
---|---|---|
using (StreamReader reader = File.OpenText ("test.txt")) { string input = null; while ((input = reader.ReadLine ()) != null) Console.WriteLine (input); } |
foreach (string input in File.ReadAllLines ("test.txt")) Console.WriteLine (input); |
for input in File.ReadAllLines ("test.txt"): print input |
If you would like to try out my programs, here's all you have to do:
- svn co http://autonant.googlecode.com/svn/trunk autonant
- svn co http://zoetools.googlecode.com/svn/trunk zoetools
- svn co http://sudokusolver-boo.googlecode.com/svn/trunk sudokusolver-boo
- cd sudokusolver-boo
- nant
- cd bin
- cp ../test/sudoku.txt .
- mono SudokuSolver.exe
Have fun and if you have any trouble, questions, ideas, etc, please comment!
1 comment:
he... i lost that on the frst or second line...
Post a Comment