Random Campaign - feasibility?

Discussion and development of scenarios and campaigns for the game.

Moderator: Forum Moderators

Post Reply
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Random Campaign - feasibility?

Post by Simons Mith »

I may not have logged on to the forums for years, but I still play Wesnoth reasonably often, and even my casual play counter on Steam has clocked up 65 hours.

I tend to play quick 1v2 battles against the AI on a large random map with no turn limit.

This has some problems - losing takes forever, because the AI can dominate me economically but only push me back very slowly. I have learned to recognize when the game is a lost cause and exit early. Winning (which is a lot rarer) /also/ takes forever, because the AI does /not/ recognize when it has been beaten so it fights to the death.

Second, it's only ever one scenario, so I never get to recall units.


On the other hand, I like the variety, and I like making the best of unfavourable random maps.


So I'd like to write a random campaign where you can choose more than one scenario and more than one random map, and ideally, where all sides can admit it when they're beaten and surrender before the bitter end. (This avoids an hour plus of play with a foregone conclusion, which is kind of fun if you just want to slaughter things, but if you're not in the right mood can get boring.)


So I have one question: can you write a multi-stage campaign that can call the random map generator and generate a random map for each scenario? I've never seen this done, and I don't know if it's technically feasible. Map /balance/ is obviously not a concern here. I'll play with whatever I'm given.
A nice-to-have extra would be a random campaign seed, so that if you find an interesting series of maps and matchups you can re-enter the seed and get the same maps and opponents.
 
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Random Campaign - feasibility?

Post by Lord-Knightmare »

So I'd like to write a random campaign where you can choose more than one scenario and more than one random map, and ideally, where all sides can admit it when they're beaten and surrender before the bitter end. (This avoids an hour plus of play with a foregone conclusion, which is kind of fun if you just want to slaughter things, but if you're not in the right mood can get boring.)


So I have one question: can you write a multi-stage campaign that can call the random map generator and generate a random map for each scenario? I've never seen this done, and I don't know if it's technically feasible. Map /balance/ is obviously not a concern here. I'll play with whatever I'm given.
A nice-to-have extra would be a random campaign seed, so that if you find an interesting series of maps and matchups you can re-enter the seed and get the same maps and opponents.
Seems like you just described World Conquest. If optimism persists, World conquest might be playable as part of the 1.16.x releases. It's available as an add-on in 1.14.x currently. I am surprised you have "never seen this" before. It's quite popular.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Random Campaign - feasibility?

Post by Simons Mith »

I've not played many UMCs, and I didn't know that one did it. I'll certainly look at its source code. Thanks. How do I access older campaigns? While I think about it, I might look at reawakening Fate of a Princess as well.
 
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Random Campaign - feasibility?

Post by Lord-Knightmare »

Simons Mith wrote: July 19th, 2021, 12:16 am I've not played many UMCs, and I didn't know that one did it. I'll certainly look at its source code. Thanks. How do I access older campaigns? While I think about it, I might look at reawakening Fate of a Princess as well.
To download an older campaign, check the old add-on servers and then start the deprecation patching in order to port to the latest stable.
https://addons.wesnoth.org/
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
shevegen
Posts: 497
Joined: June 3rd, 2004, 4:35 pm

Re: Random Campaign - feasibility?

Post by shevegen »

> can call the random map generator

Isn't the map simply an ASCII file? If so you could probably generate it as-is via ruby, python or lua and
probably add some more variables to determine how populated it may be. Perhaps Wesnoth even comes
with such tools integrated? Would make sense IMO; people could use that to help starting campaign
design. It's been years since I last used the map editor though ...

As for seeds: no idea but this could be made simpler or? If you generated a map you like you click
on "store" (just to give an example), it will be stored and then is available at a later time again
using the dataset that is used to store all of these.

I guess one has to find out which maps lead to infinite-gameplay moments. When I play elves, I
love rangers, but without forest they aren't as good ... so I favour forests .... :P
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Random Campaign - feasibility?

Post by Lord-Knightmare »

Isn't the map simply an ASCII file? If so you could probably generate it as-is via ruby, python or lua and
probably add some more variables to determine how populated it may be. Perhaps Wesnoth even comes
with such tools integrated? Would make sense IMO; people could use that to help starting campaign
design. It's been years since I last used the map editor though ...
Not sure why anyone would want to go through such arduous methods, when Two randomised map generators exist for UMC authors.
You can set up params to generate your preferred maps. For instance, setting temperature to moderately high generates tropical maps, and setting it too low would produce snowy maps. You can even add in conversion rules and such. Read the wiki maybe for a full list of available customisations.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
SigurdFireDragon
Developer
Posts: 545
Joined: January 12th, 2011, 2:18 am
Location: Pennsylvania, USA

Re: Random Campaign - feasibility?

Post by SigurdFireDragon »

Simons Mith wrote: July 18th, 2021, 2:46 pm So I have one question: can you write a multi-stage campaign that can call the random map generator and generate a random map for each scenario? I've never seen this done, and I don't know if it's technically feasible. Map /balance/ is obviously not a concern here. I'll play with whatever I'm given.
A nice-to-have extra would be a random campaign seed, so that if you find an interesting series of maps and matchups you can re-enter the seed and get the same maps and opponents.
In addition to World Conquest, this also describes the 'Random Campaign' add-on on 1.14 (I'm in the process of porting it to 1.16.) RC serves up a series of randomly generated maps against random factions from the selected era.
Co-Author of Winds of Fate
My Add-ons: Random Campaign, Custom Campaign, Ultimate Random Maps, Era of Legends, Gui Debug Tools
Erfworld: The comic that lead me to find Wesnoth.
User avatar
egallager
Posts: 568
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Random Campaign - feasibility?

Post by egallager »

SigurdFireDragon wrote: July 19th, 2021, 10:06 pm
Simons Mith wrote: July 18th, 2021, 2:46 pm So I have one question: can you write a multi-stage campaign that can call the random map generator and generate a random map for each scenario? I've never seen this done, and I don't know if it's technically feasible. Map /balance/ is obviously not a concern here. I'll play with whatever I'm given.
A nice-to-have extra would be a random campaign seed, so that if you find an interesting series of maps and matchups you can re-enter the seed and get the same maps and opponents.
In addition to World Conquest, this also describes the 'Random Campaign' add-on on 1.14 (I'm in the process of porting it to 1.16.) RC serves up a series of randomly generated maps against random factions from the selected era.
yeah THAT'S the one I was thinking of
Argothair
Posts: 53
Joined: May 10th, 2014, 12:01 am

Re: Random Campaign - feasibility?

Post by Argothair »

There's also Cities of the Frontier and Wild Frontiers, both of which generate random maps as part of something rather like a multi-scenario campaign. I'm in the process of porting CotF to 1.16.

As far as the victory conditions, it's easy enough to set those yourself in WML to whatever you feel is appropriate. E.g., you can say that you win if you control X% of the villages, or you win if you have X more units on the map than your opponent, or X more gold than your opponent, or any combination of similar factors. I'd be curious to hear what you suggest, actually -- how do you "know" when you've won?
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Random Campaign - feasibility?

Post by Simons Mith »

quoth Argothair: "how do you "know" when you've won?"

Yes, I've been mulling that over. I was considering some kind of surrender UI as an option. That turns your question on its head - instead of determining if you've won, it's deciding whether a team has lost. That's not exactly the opposite IMO.

For the player I don't want something that just triggers the 'you have been defeated' message because there's little incentive to use it. Timing and relative resources matter; it would be nice if the AI could model the costs of beating me against the surrender terms offered and score it in some way. And if I demand the AI's surrender, it needs to be able to tell whether I really do have the upper hand, or whether it should tell me to get stuffed.

So I'm also thinking the scoring system ought to monitor trends, because it's not the absolute score that matters, it's whether it's reliably getting worse or better.

Let's pick a really simple heuristic to start with:

Code: Select all

Final score = losing team's surviving units at surrender divided by winning team's surviving units at surrender * 100.
If you fight to the death, and your leader is the last to die, you score zero. If you surrender [Edit: And they accept your surrender] when you've got 20 units and they've got 50, you score 40.
But I can beat 2:1 odds, so if my score goes far enough over 50 I'm probably winning. If the AI's score goes below about 170, they're probably losing.
I could plug units into that, villages, levels, territory, recruitment costs, maybe even hit points, all of which give different degrees of nuance - and all of which can be gamed. Which is what makes this an interesting puzzle.

Thanks for the extra campaign pointers - I'll look at those too.
Last edited by Simons Mith on July 30th, 2021, 6:15 pm, edited 1 time in total.
 
Argothair
Posts: 53
Joined: May 10th, 2014, 12:01 am

Re: Random Campaign - feasibility?

Post by Argothair »

Final score = losing team's surviving units at surrender divided by winning team's surviving units at surrender * 100.
That's actually really interesting; you could even use that as the amount of gold that carries over to the next scenario in the campaign, or something like that. If my campaign will come to an end as soon as I surrender, then no matter what the "points" say about my degree of victory, I'm likely to keep fighting until I'm bloody sure I'm doomed, just in case there's some way to keep the campaign going. On the other hand, if surrendering allows me to keep the campaign going, with more or less gold in the next scenario depending on how I time my surrender, now the surrender becomes one more tool in my tactical toolbox, to be exploited rather than avoided.

I'm not sure what to do about the unit list after a surrender, though. Do you lose all your active units, on the theory that they become POWs? Can you do some kind of prisoner exchange? Do you lose some or all of the units on your recall list? The penalty needs to be severe enough that it *feels* like a surrender, but not severe enough that it essentially amounts to a game-over, no-point-in-continuing kind of defeat that means, in practice, that you'll be quitting to desktop and restarting anyway.

As far as the details of the formula, I'm not sure I'd get down to the details of fussing with hit points. It's relatively hard to deliberately arrange a situation where you have more units than your opponent, all of which are low on health, and most of which will soon be killed. If you send low-level cannon fodder against a high-level enemy, then several of them will be killed in one turn, but if you have more of the same-level units than your enemy does, then you're probably winning, even if your units are badly injured.

I would want to include villages owned and the level of your units, I think. Probably makes sense just to count total number of levels, no? Like if you have a level 3 unit and two level 1 units, that's 3 + 1 + 1 = 5. Actually, your 'score' before you divide by your opponent's score might just be the number of villages you own plus the number of levels on the units you own.
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Random Campaign - feasibility?

Post by Simons Mith »

Well, the stronger you are when you surrender, the better the terms you can get.
My first thought for a carryover heuristic was simply

Code: Select all

levels of recallable units = villages
In particular, as I want recalling to be possible, you can't lose all units on the field,
because those guys will be the only ones who might have levelled.

But there's a second game balance issue which only shows up in second and subsequent scenarios -
if you win handily, you'll have a full recall list, so you'll have a big advantage for future adventures.
So some kind of 'you must leave forces behind as a garrison' mechanic might also be necessary.

And that ought to be proportional to how powerful the defeated sides are - except that would
encourage you to wipe them out so you can leave a smaller garrison behind.

And all of these issues start to become matters of strategic concern... Fun!
 
Argothair
Posts: 53
Joined: May 10th, 2014, 12:01 am

Re: Random Campaign - feasibility?

Post by Argothair »

Hmm. I wonder if surrendering is the wrong mechanic. Maybe we should be talking instead about a strategic retreat. Like, if your units can escape off the edge of the map, then you can recall them next scenario.

I feel like "if you win handily you'll have a full recall list and a big advantage in the next scenario" is a feature, not a bug. The traditional Wesnothian way of handling that is to limit the turns per scenario (so you can't just sit and milk a technically-not-yet-defeated opponent for an outrageously long time) and to give you only a percentage of your gold as carry-over, so that over the course of a few scenarios, a big advantage will be diluted unless you're renewing that advantage each battle.

I suppose we could say you carry over some percentage of your recall list, instead of some percentage of your gold -- but that actually seems unpleasantly fussy; you'd have to figure out which specific units remain on the recall list, and why, and it's not fun to lose advanced units who weren't even in the battle.

The garrison idea has maybe more promise; it's interesting to think about leaving a unit from your recall list behind on each of your controlled villages, or getting to keep one extra unit on your recall list for each village you control. The problem is that they pull in opposite directions; do we want to reward players for owning villages, or punish them for it? I think the answer has to be "reward," because owning villages is good and it's weird to encourage players to try to run some guerilla strategy with minimal villages unless that's specifically what the campaign is about.

So putting it all together...

(1) You can order any of your units to "stand down" at any time instead of taking their turn as long as they're either (a) in a village, or (b) on the edge of the map. A unit that stands down goes onto your recall list for the *next* scenario. You can't recall them right away, but you can recall them in the next battle.

(2) You can end the scenario at any time by ordering your leader to make a strategic retreat, as long as your leader is on a keep. If you make a strategic retreat, all of your units besides your leader and the units that you've already ordered to stand down are lost -- the idea is that they're killed or taken prisoner while holding the area long enough for your main body of troops to make an orderly withdrawal.

(3) When you make a strategic retreat, you get bonus gold for the next scenario based on the number of villages you owned at the time of the retreat -- something like a one-time payment of 10 gold per village, on top of a general minimum treasury of 100 gold per scenario that you would get even if you owned 0 villages.

(4) If your AI opponent is being beaten badly enough, then they will likewise make a strategic retreat, following similar rules, including possible loss of some of their units. The AI will be taught to consider standing down units as a Candidate Action with a variable score that depends on how badly they're losing and how injured the unit standing down is. When your opponent retreats, you get bonus gold for the next scenario based on the number of turns left in the scenario, and you get to keep everyone on your unit list, just as if you had won a regular Wesnoth scenario.

(5) If turns run out before anyone is defeated or retreats, then you still get to keep everyone on your unit list, but you don't get any bonus gold.
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Random Campaign - feasibility?

Post by Simons Mith »

One little refinement to that list - it struck me you don't necessarily have to garrison villages.
If you garrison keeps, then the other side can't recruit no matter how many villages they have,
and the number of keeps would be much more stable across scenarios.

The rest, I'm mulling. Also want to play through some of the suggested UMCs and haven't
done that yet.
 
Post Reply