Raid size/difficulty Algorithm

Started by EarthyTurtle, October 09, 2014, 01:10:42 PM

Previous topic - Next topic

EarthyTurtle

Raid sizes & difficulty
It's a long standing debate which has been brought up many times before. But last night in a dream I came up with a remarkable idea!
(Well not really an idea as I had a kind of fuzzy dream about rimworld and how the mechanics work, which lead to me waking up in the morning thinking about what it was I had dreamt and eventually trailing off into a thought which lead to me having this idea)


Currently raids are on a progressive incline in difficulty that involves the raiders getting more numbers and better weapons over time. However there is no cap on this. This eventually leads to towns receiving enormous raid sizes of up to 30-50+ (even 100+) raiders and getting overwhelmed. So essentially players either need to bunker down and come up with elaborate defences or build a starship asap. Which if your anything like me, you want your little township to last for a much longer time and you don't really wanna build the starship at all. Additionally if you take a huge blow to your colony (like for example raiders getting an astounding 3 kills in a row with M-24s), the game doesn't account for this and just continues to get stronger and stronger.
By no means is this a rip on Tynan, he's done remarkable work with Rimworld which has grown an astounding amount in the past year.

Raider sizes:
Instead of having raid numbers slowly increasing in size over time, have raid numbers determined by an equation involving the current state of your town. So raider sizes will always be the same depending on how well off your town is currently. This is how: (Warning, Untested algebraic equations ahead!)

Number of Colonists in your colony = C (accounts for all colonists; bedridden or otherwise.)
Number of Defensive buildings in your colony = D (accounts for all mortar turrets and improvised turrets.)
Total worth of resources in stockpiles = R (As seen in the colonies history and statistics)
Total worth of constructed buildings = B (As seen in the colonies history and statistics)
Difficulty Setting (in %) = S (base-builder|5%, casual|25%, rough|60%, challenge|100%, s.challenge|120%, e.challenge|160%)

Raid size = ((C+D/2)+(B+R/10)/1000)xS
OR
Raid size = ((C+D/2)+(R/B)/10)xS
OR
Raid size = ((C+D/2)+((R/10)/B)/100)xS

I'm still deciding on what would be the best way to approach determining additional raider numbers by resources and buildings. Don't want it too be too large of course. But the basic Idea is that the number of colonists plus half the number of defensive turrets you have will give you the main bulk of your raider sizes. If you have 10 colonists and 6 defences (say 4 mortars and 2 improvised turrets) turrets you can expect 13 raiders to show up at least.
Of course the more resources and buildings you have the larger the force will be as well. However I'm yet to locate a good mixture between. I'm thinking the best option might be to divide resources by building count as usually I have more building score than resource score early game (for me at least). There is always the risk people will abuse that and keep their resources lower than their building score however. Any suggestions by anyone?


Raider Difficulty
Additionally, game difficulty instead of being determined by numbers would now be determined by the equipment the raiders are packing. Raider difficulty is determined by how many weeks your colony has been alive. So this does progressively get harder and harder as you go on playing. However raider difficulty is completely determined by their equipment. This is a simple one:

Weeks = W (how many weeks your colony has been around for)
Difficulty Setting (in %) = S (base-builder|5%, casual|25%, rough|60%, challenge|100%, s.challenge|120%, e.challenge|160%)

Raid Difficulty = WxS
OR
Raid Difficulty = W

This 'raid difficulty' value determines what items the raiders will be packing. Each items has a strength value. It's basically telling the raiders, you have x amount of points to spend on items.

Weapons (in order)
Pistol - 0
Pump Shotgun - 2
Lee-Enfield - 3
Uzi - 5
T-9 Incendiary Launcher - 5
Molotov Cocktails - 5
M-16 - 10
Frag Grenades - 10
L-15 LMG - 10
M-24 - 15
EMP Grenades - 15
R-4 Charge Rifle - 15
Minigun - 30
... (not experienced enough with melee to speculate on values)

Apparels (in order)
Pants - 0
+
T-Shirt - 0
Button-down shirt - 0

Armour
None (50% chance regardless)
Armour Vest - 5
Power Armour - 10

Overcoat
None (50% chance regardless)
Duster - 2
Jacket - 2

Headgear
None (50% chance regardless)
Cowboy Hat - 2
Military Helmet - 5
Kevlar Helmet - 8
Power Armour Helmet - 10

Body parts (for much later in the game) (in order)
None (50% chance regardless)
Bionic Arm - 25
Bionic Leg - 25
Bionic Eye - 35
Power Claw - 35
Scyther knife Protrusion - 50

For each spawned raider a random weapon, armour and body part is chosen.
Raider #
Weapon: <random weapon> (-point cost of weapon from raider difficulty)
Apparel: <random apparel>+pants
Armour: <random armour> (-point cost of armour from raider difficulty)
Overcoat: <random overcoat> (if power armour is not present) (-point cost of overcoat from raider difficulty)
Headgear: <random headgear> (-point cost of headgear from raider difficulty)
Body part: <random body part> (-point cost of body part from raider difficulty)

Say we have 10 weeks (10 spending points) and we have raider 1 and 2.
Raider 1
Weapon: Lee-Enfield (-3)
Apparel: T-Shirt, pants (-0)
Armour: none
Overcoat: Duster (-2)
Headgear: Cowboy hat (-2)
Body part: None

A total of 7 points was used by the computer in randomly selecting items, Raider 2 cannot spent anymore than 3 points on items for them self.
Raider 2
Weapon: Pistol (-0)
Apparel: Shirt, pants (-0)
Armour:  none
Overcoat: Jacket (-2)
Headgear: none
Body part: none

The computer used a total of 9 points creating items for 2 raiders at week 10. In the early game you can expect to only be seeing pistols, uzi's, lee-enfields and shotguns. 1 year on there is a chance you'll start seeing some high end weapons come to bear. 2 years on you will be seeing these high end weapons come to bear much more often and plenty of the raiders will be heavily armed. 5 years on pretty much your fighting cyborg armies with power armour and miniguns (Not really but there is still a chance you'll see a few).



The idea behind raids increasing in strength through items is that you can get exactly the same items and more or less match the A.I for strength as the game progresses, even if all but 1 of your colonists dies you still have a chance of recovering because this algorithm takes into account that your colony isn't nearly as strong as it was before and gives leeway for recovery.

I recognise that the equations need some serious revision, but I think it's got massive potential to help solve the problems of players getting completely overrun by 100+ raiders. Less but stronger raiders. So what does everyone think? could this be a viable option for controlling raid sizes and strengths?

JimmyAgnt007

Well that seems pretty thought out.  Once the raider AI gets an update from the zerg rush it might need looking at but for now yours is a pretty good formula.  Id also make it a bit more dynamic.  As in, if a raid of a certain value attacked, was defeated, caused x amount of damage.  Then if x > say 25% of colony value then longer time before the next raid.  where if the damage was minimal then the next raid is sooner, and more powerful.  so if you have a base, awesome defenses, and can kill off a whole raid with killboxes, then it will send more next time rather than the same.  since if your overall value doesnt change then your formula would keep sending the same size that can be easily killed.  hope that made some kind of sense.

keylocke

#2
btw, aren't mechs like heavily armed raiders as well?
also, there are tribals that needs to fit in that too.

edit :

i think people usually go overdrive on building defenses since there's this choice of wanting their base to look "pretty" or if they just want a base that functions like a perfect "killing machine".

killing machines, just seem more practical..


JimmyAgnt007

well the formula is fine if everyone took a balanced approach.  however not everyone does.  so there should be some function to balance out vs  those players to keep it challenging.  or to avoid the senseless slaughter of new players or those who might just not be any good at fighting off raids.

EarthyTurtle

anyone got any ideas on how to adapt this formula to other types of raids etc?

I mean looking at tribal it's clear that difficulty is incredibly limited, the best they can do upgrade to great bows pilas etc. Perhaps  tribals do need to be given an exception to double the amount of guys they get.

eg:
Tribal size = 2((C+D/2)+(R/B)/10)xS
besieger/drop size = 0.8((C+D/2)+(R/B)/10)xS

Mechs I wouldn't be sure, they don't seem to run on a raid timer however. I've had mechs drop in on me not 3 days after a raid. So idk I think they'd need their own formula entirely. Perhaps something more basic along the lines of a scythe/centi balance.

Kill boxes are indeed more practical, that is a given. Idk how you'd get people out of that, it's been discussed here: https://ludeon.com/forums/index.php?topic=6365.0 and some people are coming up with some ideas for A.I tactics that nullify the kill-box method. Others are coming up with ideas that entice players to build open colonies with benefits specific to outside play. I think walls will always be a thing though. :P

Thunder Rahja

You're supposed to die past day 50+.

The points system is already in place. It's just scaled depending on how long you've been playing and what difficulty you've set.

EarthyTurtle

Build a interstellar starship in less than a year, o.O what is this madness?!

RawCode

60 tribals raids of insanity still possible to beat with proper kill box setup, with cheesy "entry maze filled with rotting bodies" you can defeat raids without single bullet and only threat will be mechanoids.

keylocke

#8
Quote from: RawCode on October 09, 2014, 09:51:18 PM
60 tribals raids of insanity still possible to beat with proper kill box setup, with cheesy "entry maze filled with rotting bodies" you can defeat raids without single bullet and only threat will be mechanoids.

^this.

doomstack of mechs are the hardest thing to get rid of.

-----------

anyways, i think you should add this to the equation.

add combat skills (shooting/melee) into the combat value.

ie : the raid spawner should detect the total combat value of a colony before being able to calculate the combat value of the raiders. maybe something like this : (feel free to modify)

total DPS = shooting skill + ranged weapon OR melee skill + melee weapon
of every colonist.

combat value = (#colonist + total DPS + total armor value) + (#turrets/2 + total DPS)

then add the combat value + the wealth value  = raid strength.

say :

raid strength <= 100 (just a sample).. then the storyteller will pick one of those low-tier prefab raider squad to spawn.
raid strength <= 200 && >100.. you get medium tier raider squad prefabs..

and so on and so forth..

creating raider squad "prefabs" ensures that each squad will be able to function the way that it's intended for it's "mission"

ie :
-a kidnap raider squad will focus on weapons for incapacitate and fast retreat.
-a loot-run raider squad will want heavy dps but quick escape
-a sabotage raider squad will want frags and molotovs. (focus on destroying base and turrets)
-an assassination raider squad will focus on guerrilla tactics. (focus on killing people)
-an annihilation raider squad will go full blast with heavy dps + heavy armor. (destroy everything)
-etc..

edit :

each squad type can have their own AI priorities and "missions" are decided based on several factors 
ie :
* kidnap raider missions are spawned more if #of colonist value > colony wealth value
* loot-run raider missions are spawned more if colony wealth value > #of colonist value
* sabotage raider missions are spawned more if turret combat value > colonist combat value
* assassination raider missions are spawned more if colonist combat value > turret combat value
* annihilation raider missions are spawned more if colonist combat value + turret combat value is very high

----------

now add this to a "learning" combat AI that can pinpoint killzones and learn to avoid it. then combat is gonna be dynamic yet appropriate. (ie: you won't get annihilation squads vs a colony that is weak in combat.. they'll rather send loot-raiders and kidnappers instead)