2006-01-21

Drools: Experimenting with «Jackal» game.

There is an old child's table game. Here http://zhurnal.lib.ru/g/glebowa_u_w/statja1.shtml an inspiration introduction can be read. Unfortunately, I have not found detail description of the game rules in the internet, but this is not so important — now I'm interested in its small subset:

The game takes place on a field consisting from 11x11 small square cells with turned over images. A player can sail his ship to any field edge and put ashore a sailor. A cell is turned over (is the image was hidden) as the sailor stand at it. Further actions depend on the cell image. I will not describe all cell types, I'll tell about 3 types, one of which roused me to program this game.

1. Empty cell — nothing happens
2. Arrow — a sailor automatically moves to a cell which the arrow is pointing at.
3. Reflection — a sailor moves to a cell, which is symmetric to its initial state.

For example:

2 3'
1 -> @ 4 1'
3 2'

where numbers are empty cells, «@» is the reflection card, well, the arrow is the arrow.

Sailor comed from cell 1 moved by the arrow to the reflection cells, which moves him to the cell 1'. Similarly for 2-2' and 3-3'. This is all rules for this cell kind, which were familiar to me, the rest special cases should be invented ;) . Since everybody has different ideas, the rules shold be programed so that they can be easyly changed later.

Here is my variant:
1. Arrows are not reflected, i. e. even if a sailor passed several arrows during the moving to a reflection cell, his further moving is symmetrical to the last empty cell.
2. But after the reflection further reflections will be relative to the result of the first one. E. g. when coming from cell 4 to the reflection cell, the sailor will be moved to the arrow, which will be reflected this time, and the sailor will be back at 4.
3. And a little exception — a sailor reflected to the reflection second time, will be reflected related to the same cell as first time.

It seems to be enough rules for this time. You can already see that this game is not like many other children's table games with fixed map representable as plane graph.

In the beginning I wanted just to set all rules and associated actions by using some rule-based engine. But I've discovered that the game field is not plane oriented graph, though it can be represented as 3-D graph. Each path containing a reflection cell can be passed through vertices located at some level. Thereby, if desired, any existing engine of a plane table game can be adapted to «Jackal» without considerable problems.

But to solve the problem of conversion Jackal field to graph I decided to try Drools engine.

2006-01-19

Link after link...

My GUIbuilding googling turned into rule-based engines googling which gradually turned into studying one of them. Mostly it was provoked by beautiful design and the presence of «Tutorials and examples» section at http://www.drools.org.

Now my task is to write it all down in order to remember the new information and, besides, to be able to recollect this in case of need.

I suppose, it will be about four posts in one and a half screen :)

Subtotals can be sumed up just now:

1) Concentration on a task is amazing, the main thing is do not forget constatly repeat the mantra: «everithing is a fact, I can operate facts only». If to use such an approach, most inefficient solutions are fall away. And you can wink at memory overhead.

2) «Rete network + OOP» is equivalent to «a fish + a bicycle». Probably, I will not rush to assert that rete + OOP is useless, it's only advantage is easy integration with existing systems. But during development it's only prevent thinking. IMHO duck typing is a good compromise in this case.

2006-01-14

Links: a story of a small optimization

Here and here is told how a profiler sometimes may help. Who could have imagined that it is possible to reduce program run time from 78 minutes to... 5 seconds

2006-01-10

Programming: GUI - new concepts

Yep.. Eclipse guys are not behind new trends - JFace Data Binding. In Eclipse 3.2 will be analogue of Cocoa Controller Layer.