elmokki / nationgen

NationGen is a program that procedurally generates new playable nations, including graphics, for the strategy game Dominions 4 published by Illwinter. Support for Dominions 5 may be forthcoming.
32 stars 25 forks source link

New troop amount algorithm for rostergen #945

Open elmokki opened 6 years ago

elmokki commented 6 years ago

I gotta go sleep, should have gone two hours ago already, but need to write this down:

Currently rosters are generated stupidly: It randomly rolls for each unit. The reason this is stupid that it is very unintuitive to set the parameters. I wanna go for a setup where nations are just generated x ranged, y infantry, z cavalry and g chariots and then that is filled. Possibly races are selected at this point, but then again why complicate things too much.

I am not precisely sure how to make this so that some weirder combos with very heavy cavalry focus for example is possible but super rare, but eh, it can be pretty deeply hardcoded I suppose or there can be a nation theme that mixes things up too I suppose.

Ealb commented 6 years ago

I had clear, detailed ideas about this when the notification hit my phone last night, but I forgot I could respond by replying to that email so I can only offer a shadow of what I'd been thinking.

It might work to do something like have nations work off a default min/max/chance-of-another-pose for each type, which could then be overridden with #nationcommand foopose X Y Z. E.g. a default of min 3 max 6 infantry poses with a "more" chance of 50 would mean 3 would get made, then 50% chance of a 4th, then if there HAD been the 4th a 50% of a 5th, then 50% chance of a 6th and final if there had been the 5th. Fairly elemental Abysians overriding the ranged defaults with their custom 0 2 10 would automatically make 0, then have a 10% chance to make a 1st axe/rock/fire-thrower (why don't we have oni-esque Abysian fire throwers?!?!?), and if so a further 10% of a 2nd. That would allow for things like fairly generic themes like the cav-heavy example, either by a command modifying default or custom numbers, or just imposing new ones. I suppose that actually means it would probably be better to do min/max/chance as three single-variable commands for ease of doing +/-/* operations.

Side note since I can't easily comment on Dom5Mods right now: beyond Ancient Hurlers, I can't think of sacreds on walls, but there's also elites to consider, and MA/LA C'tis goes that route with their cap-recruit Poison Slingers. More peripherally, it might be worth considering that Mictlan does jags/eagles/jags for PD by era.

elmokki commented 6 years ago

I did think of a very similar system, albeit a bit more complex because instead of 50% per step more I had them as weights and dividers: Divider of 2 for 3 options is weights 1, 1/2 and 1/4 whereas divider of 3 is 1, 1/3 and 1/9. This makes probability distributions more complex though. There does, however, need to be an extra parameter for a separate probability of first increase. Archers should for humans be 0 to 2 with like 90% chance (or higher, this is just for easy math) of at least 1. With 0.9 we'd get:

Now, if we had an extra parameter of 0.9 and used a parameter of 0.25 for the more chance, we'd get:

This is much better, though the weighing algorithm I have has the small advantage of giving option of uniform distributions by setting all weights equal, though that doesn't matter as it'd only be good for infantry I reckon.

Now, I don't think we can make it like you described in terms of commands. A pile of x to y of pose z is too restricted and without considering the total amount of stuff generated you might end up with a nation of minimum amount of everything or a nation with maximum amount of everything.

The solution I thought was to first roll roster size and then roll archers, cavalry and ranged and finally just fill the rest with infantry, probably always generating at least one or two infantrymen even if it goes over the limit.

As for pose-specific stuff, well, I think that after the above we could have either proportional or absolute filling orders be specified. Like, an Abysian nation should often not roll too many ranged or cavalry, if any. They could then have poses or pose types specified to be be used, so if you wanted to guarantee elemental Abysians you'd tell the nation to generate 3 to 6 or 35 to 65 percent or whatever poses of tag "elemental abysian" or whatever as a priority. I'd probably make the actual generation of units still in random order so you could get a nation with elemental abysian cavalry and humanbred infantry if stars align.

elmokki commented 6 years ago

As for sacreds or elites on wall, yeah, whatever, if they are relatively cheap ones I guess they can be there, though it should be very rare for nations with non-sacred non-elite archers.

Ealb commented 6 years ago

[PD com stuff moved to separate issue]