A common riddle in the homework of A.I courses homework is this:
Given an NxN board, you need too arrange N queens such that no queen threatens any other queen.
Of course I write about it because I got this question in the homework of my Intro to A.I course.
The algorithm that solves this riddle efficently is a random and greedy:
Since there are N rows and N queens, there must be a queen in each column (why?),
so we put a queen in each row, but we also need to pick a row for each queen.
the idea is to randomize the rows at the begining, and then, in each iteration move one queen that reduces the number of threatened queens by a maximum.
We do it in each iteration, until the number if threatened queens reach 0, or we get to a situation where we can’t improve any more, because we had a bad start - so we start over, randomizing locations again, and doing the whole thing again, until the queens a safe spot.

The question was not algorithmic but implementational, the algorithm was desribed in the question very clearly, I only need to pick a language and implement it.
unlike my previous assignment, where I choose Prolog to implement Sudoku, which took a long time and brought questionable results, this time I decided to go for the home language - Java.
in about an hour it was written, except it didn’t work - sometimes the algorithm stuck in an infinite loop.
initially I printed the board to the console, but I quickly realized I wont get far this way:
its very hard to detect repeating patterns when they are printed as text, and its also hard to see if the queens threatens diagonaly.
I decided to do wheat I do well, and wrote a User interface that show a simulation of the algorithm, and with it I found and fixed the bugs.
I thought to myself, If I have got this far, I might as well invest some more and make it more useful:
I turned it into an Applet, to allow running it also in the browser, and added a few buttons to control the simultion.
this is the result:
Try to play with it, every time it gets stuck the background turns red and it randomize positions again.
Note that you can solve very big boards with it.
more things to notice are that there is a problem with small board (how small?) and that every time it gives a different solution because the start is random.
the applet is here, the code is included.


After many days and nights, its out!
FireStats 0.9-beta.

A word of caution to the brave user:
This is a real beta, unlike google’s beta, and as such, it has bugs.
some I know about, some I don’t - yet.

also, although I have put a lot of thought into the database structure, it may still change in the next version.
since this is a beta, you might be required to delete the firestats tables before the next install (losing the statistics you collected with it).
if you are uncomportable with it, you better wait for the stable release.

As usual, the FireStats home page contain all the details.

Although I decided not to continue developing Counterize2 in favor of FireStates (which - by the way - is progressing fine, a first version is expected soon), I received yesterday a bugfix from Greg.
The bug fix handle an issue with the dashboard display, and a problem with missing images in some of the graphs.
You can download the fix here.

FireStats is stating to take form, a new demo is available.
more info here.

After diving deeper into Counterize source, I decided to start my own statistics plugin project.
Its somewhat based on Counterize, but its an almost complete rewrite.
You can see a live demo here, comments and feedback are most welcomed.
Note that its a work in progress, this means that its will missing some obvious features, and that is not yet available for download.

Counterize2 version 1.0 is released.
fo more info, see the page on the sidebar.

First post in the english version of my blog.
I created this version mostly to be a platform for some programming projects I write, so don’t expect too many posts here.

« Previous Page