Personal Note: I will admit, I dislike water maps and could probably do more research on them. However, from the current state of the AI, it’s not perfect. (There was an attempt and respect it but, it fails badly.) I just want to get this out of the way. Anyway…
I want to suggest something that I thought about how to at least, make it easier to manage. Something along the lines of this:
island-count-array: Counts the total ‘islands’ on the map terrain and indexes them. This would be an array. (maybe check via beaches area for terrain?) It would also have the following data on them…
edit: You should be able to find a “closed/connected” loop of area via beach to be considered an island. In the case of a corner of map island, you will have to just have a start/ending point. (non closed.)
center-x-y/beach-x-y-array: Gets the island center location. (may not always be possible if snake-like. Although, it’s better than nothing. At the worst case scenario, grab another array of x,y beach terrains for possible landing locations.)
owned-by: who is currently on this island. Either a neutral island or player owned. (You may want a non-cheating version of this too but, that is your choice.)
once these values are known/usable, it should be in theory, much easier to manage landing on lands. (Not perfect but, a good starting point.)
You would probably want a newer functions like:
edit: Let’s see… what would be some facts…
FACT: island-neutral-controlled Island-Index Boolean
FACT: island-player-controlled Island-Index Boolean
FACT: island-is-valid Island-Index Boolean (if -1 or 0, none available.)
ACTION: get-island-count Goal Value (you need to know this since its random.)
ACTION: get-first-neutral-island Goal Value (first one. or use DUC.) *
ACTION: get-next-neutral-island Goal Value (gets next index until end of array. loop back to start if needed. or use DUC.)
ACTION: get-first-player-island Goal Value *
ACTION: get-next-player-island Goal Value
ACTION: get-player-specific-island Player-Number Goal Value
edit: ACTION: get-specific-island Island-Index Goal Value
ACTION: build-on-Island Island-Index Villager-Instance Building
ACTION: migrate-to-island Island-Index Object-Type/Class Center-or-Beach (or maybe have a new load/unload action?)
edit: ACTION: get-island-x-y-location Island-Index Goal Value (x/y pairs.)
Note: * Technically, this is redundant since ‘next’ should be enough.
(will need some transport instances arguments and what to load onto this ship or use DUC for first available one? an optional center/beach location explained above. Maybe have a loop that tries to unload at each beach array terrain until it success? A bit crude but, it should work. if it does not, just give up.)
edit: After thinking about it a bit more, you might want to have a “army/group on island” as well… So, you are not transporting the same army/group to the new location…
Just an idea/theory. If you have any other ideas, feel free to suggest.
edit: here is a simple example visually. index starts with 0.
Yellow: Detected “Island” via beach terrain. (beach-x-y-array)
Red: Detected “Island Center” from Yellow. (center-x-y)
Edit: For each “Yellow Island” detected, the “Red Island” will be increased by 1 as you expect. Yellow will always start at 0 per Red Island.
