Questions about [event] name=time over
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Questions about [event] name=time over
I am playing around with turn limits in players vs player games (PvP).
It appears that when the turn limit is reached or that time over event is fired, a nice dialog is showing giving a computer generated estimation on the status of the game. Like in the attached picture.
I have several questions on the code this WML is triggering:
It appears that when the turn limit is reached or that time over event is fired, a nice dialog is showing giving a computer generated estimation on the status of the game. Like in the attached picture.
I have several questions on the code this WML is triggering:
- what are the formula used for that estimation? Can it be modified?
- is it possible to fire the calculations at will (ie before turn limit is reached)?
- is it possible to retrieve the result from calculation in WML variables?
- after the dialogs show, both players are still shown "you have been defeated dialog". Is it possible to decide the winner based on the calculations?
- Attachments
-
- Side 2 has the advantage
- BFW-1.14.timeover.png (161.29 KiB) Viewed 1163 times
"simply put, it's an old game"T — Cackfiend
Re: Questions about [event] name=time over
AFAICS it's all in data/multiplayer/eras.lua , and it's triggered by an [event]name="time over" in data/multiplayer/eras.cfg.
Looks as if you can disable it by setting (in WML)
Looks as if you can disable it by setting (in WML)
show_turns_over_advantage = no
, and then use your own modified version of it instead. Awarding victory to one side can probably be done with an [endlevel]result=victory
inside the time over event.Re: Questions about [event] name=time over
Kudos octalot, things are very clear now:
final score = income score + unit score + gold score
gold score = team's gold
income score = income * 5
unit score = math.max(type.cost * %hp, best_adv.cost * %xp)
[income]
- The income factor is somehow already present in the unit/gold score: more steady income means more units or more gold.
- If you have a long history of better income but units do not reflect that, it means you got more losses and possibly not doing that well
- An incentive for instantaneous village advantage on the last turn (20 points for each village flipped) seems heavily impacting result based on ToD of the last turn (which should be second night if turns is multiple of 6 for fairness, helping chaotic teams).
- I don't think using advancement cost to evaluate the unit score is wise. The cost of level 2 in known to be very roughly set. For example Elder Wose (31) is 11 gold more than 20 gold Wose while Elvish Captain and Ranger (32, 38) are 4 gold over the double of their corresponding level 1 (14, 17).
- Elvish Captain and Ranger (32, 38) can also be compared to the value of Swordman (25) and Longbowman (26).
- Next factor is the all-or-nothing choice between XP and HP. A 10%-HP, 90%-XP elvish archer (ie. 3 HP, 3XP to level) would be estimated to 35 gold while a full heath new archer is 17 gold. I would not spend 35 gold on a 3 HP archer.
type.cost * (%hp + %xp)
or type.cost * (type.max_hp * %hp + best_adv.max_hp * %xp)/type.max_hp
would be better. With best_adv.max_hp = type.max_hp
if no advancement available.
- That would leave the problem of already leveled units (but might not happen that much)
Maybe adding a leader specific score: HP, access to keep, area for next move, ... maybe moving the income/gold factor here too
"simply put, it's an old game"T — Cackfiend
Re: Questions about [event] name=time over
In my opinion, a lot of thought goes into the cost of level 2 units. I've noticed that in many updates to BfW, unit costs are scrutinized by the developers to make gameplay more balanced. Some costs go up as little as 1 gold, some costs go down as little as 1 gold. The developers evidently believe that the cost of a level 2 unit can create imbalances if the numbers are off.
For example, there are 15 adjustments to costs in the changelog for the recent release of 1.15.6, all done for the purpose of balancing.
If you want to avoid relying on level 2 unit costs in your formula, maybe you could assign each level 2 unit a value based on how valuable you think it is, and use that instead.
Or, within your formula, modify the cost of specific units that you think should be cheaper or costlier.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
How to use [endlevel] in PvP multiplayer?
Man, I am completely confused here. It is not working. The victory (or defeat) result is passed to both sides equally.
If I try to write both
turn_limit_victory
and turn_limit_defeat
and call one for each side, it tells me that [endlevel] is used twice and discards it.
How can I make one side wins and the other side loses?There is no way I am going to understand this code, but it works. Much thanks for the pointer!
Last edited by demario on October 24th, 2020, 10:04 am, edited 1 time in total.
"simply put, it's an old game"T — Cackfiend
Re: Questions about [event] name=time over
Lua arrays use 1-based indices. So
Your code should also check whether one of the winning sides
wesnoth.get_units { side = winning_sides[0] }
is the same as wesnoth.get_units {}
.Your code should also check whether one of the winning sides
is_local
- and searching for code that uses that gives examples of how to do this. The Creep War add-on's am_i_victorious
function seems to be the most concise example (and the line that calls it is also relevant to this question).Re: How to use [endlevel] in PvP multiplayer?
EDIT: Actually I don't know if this will work inside time over event. I also had to do something similar and then I used it inside a turn end event of the last turn to work around it
In this example all sides win, except side 1 and the side of a certain unit that triggered a certain event
You can adapt to your needs
For different results for different sides you can use:demario wrote: ↑October 24th, 2020, 7:18 am
Man, I am completely confused here. It is not working. The victory (or defeat) result is passed to both sides equally.
If I try to write bothturn_limit_victory
andturn_limit_defeat
and call one for each side, it tells me that [endlevel] is used twice and discards it.
Code: Select all
[endlevel]
result = victory
reveal_map = no
[result]
result = defeat
side = 1
[/result]
[result]
result = defeat
side = $unit.side
[/result]
[/endlevel]
You can adapt to your needs
What gold difference leads to sure defeat?
Seems the code is running now with the modified am_i_victorious from Creep wars (from Vasya N, well done!).
I also want to improve the tie criteria so as to make a draw more an usual result when game stops at fixed number of turns.
The current code is checking equality of score, which make it unlikely and making some defeat very arbitrary (as the score computation is a rough guess).
I wondering which score difference should mark a clear advantage to decide victory. I see two ways to answer the question:
For now I will put 25 gold, but my feeling is that is still a bit low.
For the time being I will keep the Creep Wars version as it is sorted out in lua like the code I am struggling with.
I also want to improve the tie criteria so as to make a draw more an usual result when game stops at fixed number of turns.
The current code is checking equality of score, which make it unlikely and making some defeat very arbitrary (as the score computation is a rough guess).
I wondering which score difference should mark a clear advantage to decide victory. I see two ways to answer the question:
- without taking the village grabbing into account, with how fewer gold at start than your equal strength opponent would you directly resign?
- in an equal loyalist vs drake (or northerners vs rebels), with how many spearmen (or grunts) removed would you directly resign?
For now I will put 25 gold, but my feeling is that is still a bit low.
Much thanks for the support GForce0, this will help anyone playing with this in the future.GForce0 wrote: ↑October 24th, 2020, 12:15 pm EDIT: Actually I don't know if this will work inside time over event. I also had to do something similar and then I used it inside a turn end event of the last turn to work around it
You can adapt to your needsCode: Select all
...
For the time being I will keep the Creep Wars version as it is sorted out in lua like the code I am struggling with.
"simply put, it's an old game"T — Cackfiend
How to value a wounded unit?
Another problem with the formula is that a very low XP, from
1
HP to less than type.max_hp/type.cost
HP unit accounts for 0 into the team score.That would help teams with poison to outscore their opponent and goes against the evidence that people value such units enough to retreat/heal them.
A calculation such as
type.cost * (type.max_hitpoints * (1.+2*%hp)/3 + best_adv.max_hitpoints * %xp)/type.max_hitpoints
make sense, as it makes these units to score a third of their recruit value (between 4 to 8 gold generally speaking). Full health, 0XP unit still scores its recruit cost."simply put, it's an old game"T — Cackfiend