I dont know if anyone remembers, but last year about may/june time, i was working on a micromouse. things didn't go so well at the competition, but i have been having another go and things are looking much better now in the fact that my mouse now works!
The main issue with it now is that it runs very slowely when trying to do the bellman flood fill algorithm.
I was wondering if anyone can see any way that I could shorten this loop whilst performing the same function. this loop may have to be run over 100 times when it gets to the middle of a maze, so even shaving a few microseconds here and there will make a huge difference to the overal time taken
The loop goes through an array of 256 and checks that each cell has a value which is one more than its lowest neibouring cell. there is alot more information about this at: http://micromouse.cannock.ac.uk/maze/solving.htm
Here is the code:
If anyone needs anymore details let me know. I am not sure really how much background anyone would need to be able to suggest improvements.
The main issue with it now is that it runs very slowely when trying to do the bellman flood fill algorithm.
I was wondering if anyone can see any way that I could shorten this loop whilst performing the same function. this loop may have to be run over 100 times when it gets to the middle of a maze, so even shaving a few microseconds here and there will make a huge difference to the overal time taken
The loop goes through an array of 256 and checks that each cell has a value which is one more than its lowest neibouring cell. there is alot more information about this at: http://micromouse.cannock.ac.uk/maze/solving.htm
Here is the code:
Code:
for FloodP = $00 to $FF
'get flood data
hi2cin FloodP,(FloodD)
Temp2 = FloodD
'get wall data for the current cell
read FloodP,WallD
Temp1 = WallD & $01 'North
if Temp1 = 0 then
let WallP = FloodP + 16 'point north
hi2cin WallP,(Temp1) 'read the flood value
if Temp1 < FloodD then
let FloodD = Temp1 + 1
endif
endif
Temp1 = WallD & $04 'East
if Temp1 = 0 then
let WallP = FloodP + 1
hi2cin WallP,(Temp1) 'read the flood value
if Temp1 < FloodD then
let FloodD = Temp1 + 1
endif
endif
Temp1 = WallD & $10 'South
if Temp1 = 0 then
let WallP = FloodP - 16
hi2cin WallP,(Temp1) 'read the flood value
if Temp1 < FloodD then
let FloodD = Temp1 + 1
endif
endif
Temp1 = WallD & $40 'west
if Temp1 = 0 then
let WallP = FloodP - 1
hi2cin WallP,(Temp1) 'read the flood value
if Temp1 < FloodD then
let FloodD = Temp1 + 1
endif
endif
hi2cout FloodP,(FloodD)'write the number which is one bigger than the nearest cell
if Temp2 != FloodD then: Let Change = 1: endif
next 'go and look a