telengard
Member
I have all this info already in a separate file for each board! This is an excellent idea. Although I feel like I'd still have to parse the line to determine which hexes are intersected. Although this could (and now I'm thinking should) be pre-calculated. It's always the same for a single mapboard!And here's another optimization that could give big savings, depending on what's on the board.
Build an index such that for any hex on the board, you can quickly get a list of every hex pair whose LOS goes through that hex. It will take some time to build, but since it's independent of the board being analyzed, you only have to do it once.
Identify hexes on the board that are 100% obstacle e.g. interior building and woods hexes (maybe VASL has this information already?), and using the index created above, you now have a list of hex pairs where it's impossible for there to be a clear LOS. Imagine what that could do for board 52
I haven't tackled hedge/bocage yet (are those terrain types even in SK?). I've added full concealment so I imagine my engine will slowly add parts of regular ASL. I definitely want to add Snipers to my AI engine.You could even extend this idea to be able to look up hex pairs whose LOS goes through a given hex-side - this lets you quickly discard any hex pairs that have a LOS that cross a wall or hedge or bocage (assuming non-adjacency).
This could also include interior building/woods hexsides e.g. in the diagram below, a LOS that crosses the interior U2-U3 hexside cannot possibly be clear (assuming non-adjacency).
View attachment 22370
But you would need to be able to identify such interior hexsides quickly.
You might also be able to do a similar trick for hexes that are 100% non-obstacle (e.g. open ground, maybe with a bit of road) - if the LOS enters such a hex, you don't need to check all the LOS pixels in that hex, you can just skip to where the LOS leaves the hex, and continue checking from there.
The idea about using the list to skip hexes is good, ESPECIALLY for open ground as there are usually a lot of those.
I need to mull all of these ideas over. Some are very simple to implement, some will take a bit of work.