Arcen Forums

General Category => AI War II => AI War II - Modding => Topic started by: BadgerBadger on November 19, 2017, 08:46:29 PM

Title: Wormhole Disrupters
Post by: BadgerBadger on November 19, 2017, 08:46:29 PM
Random idea that just came to me for a different Minor Faction, similar to Nomad planets. Nomad planets will increase the wormholes between planets, giving new possiblities for transit. What about if there was a minor faction that would break wormhole connectivity for a period of time? Perhaps the given reason could be "ion storms" or something classic like that.

It seems like some tunings would make sense; not allowing it to break the connectivity of the network would probably be worthwhile (so you couldn't use it on a Snake map).

On a similar note, while Nomad Planets are definitely out for 1.0, is there logic in the game for having wormhole appear/disappear in game? I could imagine having the map selection algorithm pre-define some wormholes that will exist "sometimes" during the game.

I'm not sure if this is a good idea (having new connections appear seems cooler to me than having existing ones disappear, but the thought of not being able to reinforce half your empire does sound like the sort of thing the AI would love).
Title: Re: Wormhole Disrupters
Post by: keith.lamothe on November 20, 2017, 08:04:28 AM
Adding/removing wormholes in AIWC was a royal pain due to the very specific way they were handled (including the fact that originally they weren't even serialized to disk, the mapgen was just rerun for that stuff whenever you loaded).

In AIW2 it's much easier to add/remove wormholes.
For removal I'd use planet.GetWormholeTo(otherPlanet) , wormhole.Die() , planet.RemoveLinkTo(otherPlanet) .
For adding I'd use planet.AddLinkTo(otherPlanet), and then 2 sets of wormhole = GameEntity.CreateNew() (search external for SpecialEntityType.Wormhole to see how) followed by wormhole.LinkedPlanetIndex = planet.PlanetIndex .

You could probably even add planets, though not remove them (to "remove" you'd need to suppress them somehow, to avoid messing up index positions). Getting everything to play nicely with the modified map is a different kettle of fish, but should be doable.

First, as you said, breaking the graph is out. That would cause no end of problems. That said, you could add a compensating connection before removing the existing one, and that would let you do this on Snake. It would probably result in a map that gets progressively less snake-like, however. On that note, it would be kind of fun to have a map type that changes from, say, Concentric to Wheel over the course of the game, by moving stuff around and relinking. Or a maze type where the "labyrinth" gradually reconfigures itself. On the other hand, that sounds like a defensive nightmare. On the third hand, many AIWC players seem to enjoy nightmare difficulty ;)

Second, pathfinding needs to be notified:
1) If removing a wormhole, all units with a wormhole order to enter the planet on either side (or who are _on_ either planet and have a wormhole order going anywhere) would need to have their paths rerolled. Same as AIWC, not terrible, but needs to be done.
2) Whether adding or removing, RecomputePlanetDistances() needs to be called on the galaxy object. This rebuilds the cached lookup used by planet.GetHopsTo(otherPlanet), which is used for pathfinding costs.

Both of these would need to be done at a stable time between long-term-planning cycles (so the graph isn't changing while the AI thinks, etc), which basically means when I handle GameCommandType.HandleEndOfLongRangePlanningCycle (in core). So perhaps I should provide a HandleEndOfLongRangePlanningCycle() hook for conducts and factions to define in external, and it could be done there.

And theoretically that's it. In practice I'm sure there would be some race conditions with vis code and possibly some other parts of the sim that need to be notified, etc.
Title: Re: Wormhole Disrupters
Post by: BadgerBadger on November 20, 2017, 10:09:42 AM
First, it's great that this seems like a potential area for modding.

The second question is A. whether this actually sounds like fun, and B. whether it makes sense to try to have something like this in for 1.0. It might make the most sense to hold onto this until you were planning to do Nomad planets anyway; Nomad planets seem like a useful selling point for an expansion since people enjoyed them in AIWC.
Title: Re: Wormhole Disrupters
Post by: keith.lamothe on November 20, 2017, 11:33:17 AM
It does seem better for post-1.0, expansion or otherwise. Perhaps as part of a "Dynamic Map Types" feature where the external mapgen implementor can:
- move planets during the game
- update the position of wormholes on a planet so that the angle stays correct (I'm not sure if it would be cool, disconcerting, or both to see wormholes orbiting in real time)
- add or remove links

An example would be a Concentric map, where the even rings "turn" clockwise and the odd rings "turn" counter clockwise, with each "outbound" connection from one ring to another periodically updating to link to whatever the nearest planet is in the target ring. That seems like a decent balance between chaos and order. If there were territory-based special factions it might mess with them, but I could see some (like the Nanocaust) become more interesting as a result of being fragmented like that.

Another would be Nomads proper (the moving planets part, not the planetary-warhead part, which would be handled separately), probably with default motion and re-linking logic that could be used on whatever map type (as in AIWC) that could be replaced by specific map types where it's desirable to have a more tailored behavior.

As a semi-joke, the force-directed-graph detangling logic from AIWC could be ported over with as part of a Detangling Vines map type, that starts as crazy as Vines did in AIWC, but over the course of a few hours resolves into a map that actually makes sense ;)

An actually-gameplay-relevant variant of that would be to seed some kind of Repulsor and Attractor structures on different planets, and capturing/hacking/whatever one would cause it to feed into that force-directed-graph algorithm as a repulsion/attraction with other activated nodes. No other forces would be exerted except:
- Planets try to maintain their original distances to their neighbors
- Planets generally repel other planets that get very close
- Linked planets forced more than 2x their original distance apart causes the link to cut
- Unlinked planets forced closer than X units link up
Something like that; it would add a layer of meta-strategy.

Whether any of those would be fun to play a serious game on, I dunno.