O(1) path-finding check #546
Comments
Per uploaded file Flood fill algorithm check |
Per uploaded file Check that we can go to a repair centre |
Zarel commented Looks good to me. After we commit this and the wall patch (and backport both to 2.2, hopefully), we should profile Warzone again and see how performance looks. |
Buginator commented Per, for the floodfill patch, correct me if I am wrong, but that needs to be done on map changes correct? If so, then in the campaign, we need to add the mapFloodFillContinents() when we get those lovely limbo & expand missions... or else, the map, and the flooded continents(ha!) would not be in sync. p.s, the baba's don't appreciate you flooding their lands! They got enough to worry about! ;) |
Per commented I think limbo will work fine, since the limbo maps are loaded from disk, but good point about the expand missions. It would probably work out fine in practice, though - the flood algorithm ignores scroll limits, so it will only give some trouble if the scroll limit cuts up continents, and the result will still not be worse than what it already is. But I'll see if I can think up a solution. |
Kreuvf commented
Therefore I think that not saving any such data in a map file/disk cache and instead calculating it when needed is a superior way of doing it. |
Zarel commented Replying to Warzone2100/old-trac-import#546 (comment:4):
...um, why is that data untrustworthy? We trust all the other data in the map file; why not the precalculated data? Especially since the precalculated data saves millions of microseconds.
...why not? At most, we do a checksum or something, which is much faster than several million microseconds.
It's negligible. Plus, I'm sure the data computes much slower than than it transfers.
...oh, come on, that's really negligible. We do a lot more error-prone changes for a lot less speed benefit all the time. |
Per changed status from |
Per changed owner from `` to |
Per commented Some ideas: The continent data can be saved in the map directory, so no consistency check needed. The size will be four bytes for each map node, ie a maximum of 256kb uncompressed. I think I would use two PNG images to store this info, say normalcontinent.png and hovercontinent.png, so it would be both compressed and easily viewed. We could precalculate this data for all default maps. |
Kreuvf commented Replying to Warzone2100/old-trac-import#546 (comment:5):
By the way: There are more trivial reasons for not saving stuff to disk/map files and therefore not trusting what's in those files: We changed internal formats often enough in the past (save-games, anyone?) and as far as I understand it save-game format is a permanent headache. Something very similar could happen to map-files, if you misuse them to store unnecessary (=untrustworthy) data in them.
My conclusion still is: Not only there is no need for storing that information permanently, doing so will give rise to further problems. |
Kreuvf commented Replying to Warzone2100/old-trac-import#546 (comment:6):
Replying to Warzone2100/old-trac-import#546 (comment:6):
Replying to Warzone2100/old-trac-import#546 (comment:6):
Maybe I am missing some important point(s) here, so I'd be glad if somebody stepped up to explain to me how this is supposed to work in a reliable manner. |
Per commented I do not understand the concern for verification. Nobody is going to change maps stored on the disk. Even in savegames, the map files themselves do not change. A map editor that understands our map format would have to know about all the files in a map directory, of course, but such an editor does not yet exist. |
Per set resolution to |
Per changed status from |
Per commented (In [7578]) Add an O(1) path-finding check function that tells us whether it is possible Use this function to make sure we do not try to return to repair to a repair |
Zarel commented Replying to Warzone2100/old-trac-import#546 (comment:7):
Sure, we can't be sure that they've been created by good users, but why do we need to be?
Oh, not this. It's pretty easy to tell if a format is compatible. That can be as simple as adding a version number counter into the save game format. I mean, our map format isn't convoluted like our savegame format is; it'd be moderately simple just to add another file, and check for its presence.
Why do we need to trust our map data? You still haven't established this. I proposed a checksum as a safeguard against accidental corruption. If someone wants to intentionally fiddle with our map files, let them. We have an open-source philosophy - if someone wants to mess with stuff, great. I don't see the problem here.
Yes, well, +2 seconds worth of map loading is pretty nontrivial. It should be avoided whenever possible. I meant that it's error-prone in the tautological sense: All code is "error-prone". Even bugfixes. And yet we keep on writing it.
What further problems? You've said nothing about any further problems except some vague commentary on trustworthiness. Replying to Warzone2100/old-trac-import#546 (comment:8):
Decompressing a PNG takes a trivial amount of time (far less than two seconds).
I think what you're not understanding is this: We don't need to be secure against attackers. You must realize, we are developing a game here, not, say, OpenSSL. What kind of attack are you afraid of? Here's a chart for you:
Malicious mappers can already crash the game, or if they want to be more subtle, screw with gateways, features on top of buildings, etc, etc. And as a community, we are small enough that we don't have people bored enough to do that. And even if we did, we'd get around it by not downloading their maps. That's how every game works. Emphasis on "malicious" - a simply incompetent map maker would be fine, since it's the underlying map editor that takes care of the continent data cache. |
Kreuvf commented Replying to Warzone2100/old-trac-import#546 (comment:11):
Just in case: This is my honest opinion. |
cybersphinx changed milestone from |
cybersphinx commented Milestone 3.0 deleted |
keyword_path-finding_AI
resolution_fixed
type_patch (an actual patch, not a request for one)
| by PerThe first patch adds an O(1) path-finding check function that tells us whether it is possible for a droid with a given propulsion type to go from position A to position B. It generates some static information on map load using a flood fill algorithm which takes some time (a bit under a second on my computer), so we may want to cache it on the disk, and later create it with a map editor.
The second patch uses this path check function to make sure we do not try to return to repair to a repair centre that we cannot reach. This is a random example picked to test the feature, there are many more issues like it.
Issue migrated from trac:546 at 2022-04-15 18:20:58 -0700
The text was updated successfully, but these errors were encountered: