Friday, April 28, 2006

Collecting my thoughts...

Didn't work the whole day yesterday. Couldn't figure out a simple way to figure out visibility of a cell. I looked at it from both points of view, but still couldn't think of an easy way out.

Then I thought, why not simple draw a straight line? The line-drawing algorithm occurred to me. I searched for Bresenham, and found this. Now I've written a function, which calculates visibility of a cell with respect to the another, completely ignoring cells which come in the way partially. Have to repeat this for all cells within max-range for bot to get good view of the countryside.

How am I representing bot perception of terrain? There are various kinds of terrain - explored/unexplored, passable/unpassable, visible/invisible etc. Anyway here follows the first few steps of the bot:

Basic Algo

* First thing to do would be calculate visibility matrix of surrounding area
* From that matrix, all visible cells, will be deemed explored
* A heuristic function will determine a target cell (explored) within this range (or within all the explored area...yet to be decided). This function should take into account the height of the cells too (since greater height will obviously help see more cells).
* Distance Transform will be performed taking all unexplored cells as impassable (taking worst case)
* Shortest path to target cell will be calculated. If found then bot will use the path to get to that cell, marking all cells on the way as visited. If path is not found then bot will try and move in the default direction of the target one cell at a time and re-run all the previous steps.

To be noted

* Cells once visited will need to have higher cost/heuristic value to discourage repeated visitations.
* Range one as mentioned before, is equivalent to FirstAgent and will be run as this.

Basically work is needed primarily on bot algo. Have to BBS Milda's program too to show that I haven't wasted my time completely with terrain generation. Till I figure something else out, or face steeper terrain...

0 Comments:

Post a Comment

<< Home