Rout Logic

Field of Glory II is a turn-based tactical game set during the Rise of Rome from 280 BC to 25 BC.
Post Reply
Ludendorf
1st Lieutenant - 15 cm sFH 18
1st Lieutenant - 15 cm sFH 18
Posts: 834
Joined: Sun Dec 15, 2013 5:35 pm

Rout Logic

Post by Ludendorf »

This is something that has been bothering me for a while now. I've been playing this game for a long time, and I still don't fully understand how routing units path. Even the direction they initially break away in seems to be semi-random. Has anyone worked out fully how it works?
Schweetness101
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 928
Joined: Tue Nov 29, 2016 6:12 am

Re: Rout Logic

Post by Schweetness101 »

I can look at it. The evading stuff is pretty complicated though, especially when it has to take into account the pathing of a router, one ore more pursuers (who cannot each take the same path because they can't be on top of each other) and all of the potential terrain and unit obstacles to run around. Hence why it sometimes seems pretty wild.

The relevant code stuff generally involves the REPQueue, but it's all pretty complex. Not something I have looked into changing. Although if you look into the DoUnitNextREPQueueStep() function and its helper GetNextRetreatStep() you can see a lot of the logic for choosing evasion routs, but they are long and complex functions.

A few notes from the comments from the latter function though:

// After first square of initial rout/evade move, preferred facing (direction of move) is to continue in the direction the unit is already facing.
// If first square of evade or initial rout, favour facing (direction of rout) directly away from the enemy unit that charged or inflicted the rout
// Check whether pass through is possible
// If pass through not possible, check whether normal move possible
// If sufficient move to get to new square (or, in the case of pass-through, the passed through square).
// Prevent toing and froing
// Calculate risk according to threat map - higher value means more chance of being damaged
// favour moves that end further away from enemy
// Favour moves directly away from enemy in contact on first square of initial rout, then favour direction already travelling,
// less favour for 45 degree deviation, and forbid more than 90 degree deviation.
// Disfavour moves that get closer to the enemy
// Stop units coming back towards enemy
// This should make route prefer easier to enter squares, and prefer straight to diagonal moves
// Favour direction towards own baseline if we know where that is.
// Give priority to leaving playable area, but preferably towards own base edge.

hope that helps
My Mods:
Ancient Greek https://www.slitherine.com/forum/viewtopic.php?p=977908#p977908
Dark Ages Britain https://www.slitherine.com/forum/viewtopic.php?t=106417
Anarchy (Medieval) https://www.slitherine.com/forum/viewtopic.php?p=987488#p987488
Ludendorf
1st Lieutenant - 15 cm sFH 18
1st Lieutenant - 15 cm sFH 18
Posts: 834
Joined: Sun Dec 15, 2013 5:35 pm

Re: Rout Logic

Post by Ludendorf »

Schweetness101 wrote: Sun May 31, 2020 11:43 pm snip
Wow Schweetness. I wasn't expecting a technical breakdown like that. Thank you. This should be useful. :)
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28411
Joined: Sun Dec 04, 2005 6:25 pm

Re: Rout Logic

Post by rbodleyscott »

It is also worth noting that for the purpose of selecting the direction for the first square of rout movement, when a unit is fighting multiple units, the unit that "inflicted the rout" is the one whose combat was being resolved when the unit routed.

You can therefore influence the direction of rout by picking the order in which you activate the melees. But only, of course, if the unit you pick does actually rout them.
Richard Bodley Scott

Image
Post Reply

Return to “Field of Glory II”