forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually fix rare anthill placement errors (CleverRaven#51611)
The previous attempt to fix the rare anthill placement errors did not work. I now know this was due to a simple typo, but tracking down the issue took a lot of refactoring. That refactoring improved the code, so I'm including it here. Changes include: * The previous fix was that new unresolved joins that might conflict with postponed joins would themselves be automatically postponed. We have now reversed this logic so the postponed joins are restored. This allows another chance for the current phase to satisfy the joins, now that might be possible. * Postponed joins now need to have their positions indexed for efficient access, so I factored out that indexing capability into a new struct indexed_joins. * Removed the list of orphaned joins. They should no longer ever occur. * Added a bunch of calls to a consistency_check function that verifies the class invariants (except it's disabled for now, with the code left in case it's useful for future debugging). * The order of unresolved joins used to depend on their addresses in memory, which made the tests non-reproducible. Change that to be deterministic. * Add unit test which places ~100k anthills to more easily observe placement errors. * Improve the debugging output for failed placements to make it easier to see what happened (add phase boundary markers and capitalize FAILED).
- Loading branch information
Showing
4 changed files
with
241 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"type": "overmap_special", | ||
"id": "test_anthill", | ||
"subtype": "mutable", | ||
"locations": [ "subterranean_empty" ], | ||
"city_distance": [ 10, -1 ], | ||
"occurrences": [ 80, 100 ], | ||
"flags": [ "ANT", "UNIQUE", "CLASSIC", "WILDERNESS" ], | ||
"check_for_locations": [ | ||
[ [ 0, 0, 0 ], [ "land" ] ], | ||
[ [ 0, 0, -1 ], [ "subterranean_empty" ] ], | ||
[ [ 1, 0, -1 ], [ "subterranean_empty" ] ], | ||
[ [ 0, 1, -1 ], [ "subterranean_empty" ] ], | ||
[ [ -1, 0, -1 ], [ "subterranean_empty" ] ], | ||
[ [ 0, -1, -1 ], [ "subterranean_empty" ] ] | ||
], | ||
"joins": [ "surface_to_tunnel", "tunnel_to_tunnel" ], | ||
"overmaps": { | ||
"surface": { "overmap": "anthill_north", "below": "surface_to_tunnel", "locations": [ "land" ] }, | ||
"below_entrance": { | ||
"overmap": "ants_nesw", | ||
"above": "surface_to_tunnel", | ||
"north": "tunnel_to_tunnel", | ||
"east": "tunnel_to_tunnel", | ||
"south": "tunnel_to_tunnel", | ||
"west": "tunnel_to_tunnel" | ||
}, | ||
"crossroads": { | ||
"overmap": "ants_nesw", | ||
"north": "tunnel_to_tunnel", | ||
"east": "tunnel_to_tunnel", | ||
"south": "tunnel_to_tunnel", | ||
"west": "tunnel_to_tunnel" | ||
}, | ||
"tee": { "overmap": "ants_nes", "north": "tunnel_to_tunnel", "east": "tunnel_to_tunnel", "south": "tunnel_to_tunnel" }, | ||
"straight_tunnel": { "overmap": "ants_ns", "north": "tunnel_to_tunnel", "south": "tunnel_to_tunnel" }, | ||
"corner": { "overmap": "ants_ne", "north": "tunnel_to_tunnel", "east": "tunnel_to_tunnel" }, | ||
"dead_end": { "overmap": "ants_end_south", "north": "tunnel_to_tunnel" } | ||
}, | ||
"root": "surface", | ||
"phases": [ | ||
[ { "overmap": "below_entrance", "max": 1 } ], | ||
[ | ||
{ "overmap": "straight_tunnel", "max": 20 }, | ||
{ "overmap": "corner", "max": 5 }, | ||
{ "overmap": "tee", "max": 10 } | ||
], | ||
[ | ||
{ "overmap": "dead_end", "weight": 2000 }, | ||
{ "overmap": "straight_tunnel", "weight": 100 }, | ||
{ "overmap": "corner", "weight": 100 }, | ||
{ "overmap": "tee", "weight": 10 }, | ||
{ "overmap": "crossroads", "weight": 1 } | ||
] | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.