Help with testing Fred - Freelands MP Custom AI v0.14.15

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Post Reply
name
Posts: 569
Joined: January 6th, 2008, 3:32 am

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by name »

mattsc wrote:And even if you "only" say exactly what I am thinking, it will be good to get the confirmation from somebody who is much better at this than I am. I'm not that good a player in the first place (in MP at least, I seem to be doing semi-ok in SP*).
Oops, I might have given you the wrong impression regarding my competence level! I am a mediocre to intermediate player at best, not anyone from the ladder or such caliber. Given the length of an average multiplayer game, I never had the necessary time to allocate to getting so very good at it.
mattsc wrote: Perfect, thanks! It really is fun for me to watch these replays, seeing that Fred more or less does the things I am trying to teach him to do.
Well it is least we in the community can do, since on one end it is a very easy and fun way to be somewhat helpful and on the other you have made a long and serious effort to tackle the biggest weakness of present day wesnoth, which is lack of full quality AI (for such a defensive game as this, that means an AI that knows when and especially how to defend as Fred does).
mattsc wrote: * As a side note, coming from my SP background: one of my far-in-the-future goals once I start generalizing Fred for other maps/factions is to set up an AI that can play through and win HttT on medium. Revealing my hubris here, I've decided that doing so on easy is too easy. :shock:
If such a stage is reached, campaigns like HttT should certainly be fully restructured around using Fred for basically all scenarios' opponents.
name
Posts: 569
Joined: January 6th, 2008, 3:32 am

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by name »

Since there were some interesting differences with Fred's play against Knalgans and Drakes, I figured it might be interesting to test him against a further faction (loyalists). Although now looking at how much you already have done towards v14.5 this may be somewhat obsolete information.
14.4_versus_loyalists.gz
(21.9 KiB) Downloaded 275 times
At turn 3 Fred over deploys to center. Consistently, he seems to neglect the east (where he can do the most damage) in favor of the center (where neither side can do too much). Makes me wonder what would happen if I hacked zone_weight down from 0.5 to 0.1 or just 0 and retry this match...

At turn 8 I get excessively aggressive in the west and over the next few turns Fred does a good job punishing me for not showing him the proper respect.

Also at turn 8, he moves a lone archer to the open at (15,14), instead of the hills at (16,14).

At turn 14 he does a nice job defending in the west and then nice follow-through on the next turn.

At turn 18 he needed to fall back a bit further given the opposition strength and time of day.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by mattsc »

Thanks yet again, Cold Steel. Somehow I got the impression that Fred's more "scatter brained" in this replay, but maybe I am just imagining that. As for this:
Cold Steel wrote:Although now looking at how much you already have done towards v14.5 this may be somewhat obsolete information.
No, not at all. First of all, I've mostly just been dealing with internal clean-up and re-organization so far. Second, I am really working on the attack mechanics and evaluation for this release. Most of the things you point out here (and in previous post) aren't really affected much by that. And finally, there's not going to be a sudden big change in behavior any more at this point anyway. I think Fred's general behavior is pretty much what it is going to be at this time, with changes very incremental and in the fine-tuning of things, such as when to be more aggressive or more defensive. But as you say yourself in a previous post, it's pretty hard to get that right all the time.

Point of all of this is, your replays and comments are much appreciated and useful, but probably more so for the next two releases than for 0.14.5. So I'll get back to them then.

Anyways, I am going to continue to work on these small incremental changes, in the hope that the sum of them will make a small difference. :-)
name
Posts: 569
Joined: January 6th, 2008, 3:32 am

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by name »

mattsc wrote:Thanks yet again, Cold Steel. Somehow I got the impression that Fred's more "scatter brained" in this replay, but maybe I am just imagining that.
I got a bit of that impression too, but it is hard for me to say. What I would say is that the biggest single reason that he lost against the loyalists in this match is for having too many forces in the center and too few in the east.

In Freelands, attacks across the center are almost always suicide missions because the terrain favors the defender and there are no villages to capture, plus the defender's castle is close by to supply reinforcements and even the king can swing out for one turn to deal additional hurt. In contrast, the east is the most vulnerable to raids by side 1 due to both the number of villages and difficulty of defending the outermost of these. If Fred amasses forces near there, a human opponent will need to / feel the need to divert more forces to the eastern theater to defend these villages. But if there is no threat in the east, those forces can instead be massed to rush Fred's (side 1's) own weak flank in the west at full strength.

I don't remember which version of Fred it must have been, but way back I vaguely recall him massing forces at the castle outpost in the north east to launch (or threaten, depending on defender strength) raids to the south east during the night. I don't know if that changed because his zone system was altered over the years or if my play style has changed in a way that disrupts that behavior. Or if my memory is just badly corrupted and I hallucinated the whole thing...

In other news, the Rebels have invaded the Freelands:
14.4_versus_rebels.gz
(24.4 KiB) Downloaded 294 times
Fred could retreat a bit more and to stronger terrain at turn 5 in the west and then again at turn 10.

I stick around too long in the west at turn 7 and over the next couple of turns Fred does a good job retaliating.

At turn 8 the troll at (12,7) doesn't attack with the rest of his forces or move at all while it is night and he is only holding flat ground anyway.

Fred retreats well in the west at turn 11.

At turn 19 fred is ambushed by a wose which he saw go into cover. (Not sure if this is expected behavior.)
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by mattsc »

Thanks for yet another replay, Cold Steel. :) I feel kind of bad because I continuously seem to ignore the issues you point out, but I've decided that sticking to the plan I outlined has its definite benefit in the long run (and it actually helps me focus on the current tasks as well), even if it does not address the biggest problems right away.
Cold Steel wrote:In Freelands, attacks across the center are almost always suicide missions because [...]

I don't remember which version of Fred it must have been, but way back I vaguely recall him massing forces at the castle outpost in the north east [...]
Yeah ... When we worked with some of the ladder players in the early days of Fred (before he was Fred), that's the first thing they told us. As a result, there were direct orders built into the code to do the rushing through the east. Those don't exist any more because they were too rigid and cannot easily be generalized to other maps. So you do remember correctly.

Instead, there are now weighting functions in the code to (de)emphasize zones over the others. You pointed out the zone_weight factor yourself, but that's only part of it. So the functionality is still there, but in a more general sense and a lot of those weights currently only have ad hoc values that likely need to be adjusted, and there's also still some considerations that are simply missing in the code. The goal is to get back to the previous behavior, but in a more flexible way. Unfortunately, that's part of the operations layer improvements, so you will have to wait a couple releases for that. (And things like not retreating far enough or leaving units stranded is on the list for 0.14.6.)
Cold Steel wrote:At turn 19 fred is ambushed by a wose which he saw go into cover. (Not sure if this is expected behavior.)
At this point that should probably be expected, yes. Remembering where ambushers are or might be is on the list, but not for the near future. :|

In the meantime, I'll continue working on the attack evaluation. That code's not been worked on in a long time and needs a lot of overhauling. I'm not sure if it will make a big difference overall (it will in specific situations), but it is work that needs to be done. As for expected progress, starting next week RL is going to get really busy until ... at least August, but probably well into fall. I'll still be online regularly and work on Fred when I can, but I'm afraid progress will become (even) slower.
name
Posts: 569
Joined: January 6th, 2008, 3:32 am

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by name »

mattsc wrote:Thanks for yet another replay, Cold Steel. :) I feel kind of bad because I continuously seem to ignore the issues you point out, but I've decided that sticking to the plan I outlined has its definite benefit in the long run (and it actually helps me focus on the current tasks as well), even if it does not address the biggest problems right away.
No need to feel bad, some posts ago I was hinting to break up the task list into more manageable pieces, so I fully agree with this strategy. I am just queuing up for future use, a set of replays of current fred versus each faction along with a brief summary of interesting events for quick reference (at said future date). And of course its partly out of my own curiosity, since AI development is an interesting topic. Anyways, there's now only two left to go to complete the set (northerners and undead.)
mattsc wrote: The goal is to get back to the previous behavior, but in a more flexible way. Unfortunately, that's part of the operations layer improvements, so you will have to wait a couple releases for that. (And things like not retreating far enough or leaving units stranded is on the list for 0.14.6.)
Sounds like 14.7 is going to be a particularly high challenge / high reward leg of development.

Although of the sum of the things on the 14.5 and 14.6 task lists (with attack evaluations being no small part) sound like they could by themselves make fred something like 20% to 50% more dangerous, which would be significant to say the least.
mattsc wrote: As for expected progress, starting next week RL is going to get really busy until ... at least August, but probably well into fall. I'll still be online regularly and work on Fred when I can, but I'm afraid progress will become (even) slower.
That's too bad, although sometimes a hiatus helps clear the mind to make room for new insights to pop up.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by mattsc »

Cold Steel wrote:That's too bad, although sometimes a hiatus helps clear the mind to make room for new insights to pop up.
That's very true and that's what I did last year. It helped a lot. This won't really be a hiatus though, just a longer period during which I'll have less time for Fred than I'd like. I'll keep chipping away at things though.

On everything else: sounds like we agree. It's actually really good to have this dedicated time for the attack evaluation. It's turning out to be more or less as complex as I had expected -- which was the reason why I did not do anything about it previously. I knew it was going to be a lot of work, but so far it's never been the biggest fire to put out, so it never got done. It still isn't the limiting factor in most situations, but at some point it just needs to get done.

Looking forward to the other two replays.
name
Posts: 569
Joined: January 6th, 2008, 3:32 am

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by name »

mattsc wrote: This won't really be a hiatus though, just a longer period during which I'll have less time for Fred than I'd like. I'll keep chipping away at things though.
Relieved to hear it. ^_^
mattsc wrote: On everything else: sounds like we agree. It's actually really good to have this dedicated time for the attack evaluation. It's turning out to be more or less as complex as I had expected -- which was the reason why I did not do anything about it previously. I knew it was going to be a lot of work, but so far it's never been the biggest fire to put out, so it never got done. It still isn't the limiting factor in most situations, but at some point it just needs to get done.
Well just looking at the task list it seems you are tearing into it, with many more boxes checked than unchecked after only a short time.


Discovered the first fatal error when I took over Fred's keeps, blocking him from returning there:
14.4_versus_northerners.gz
(19.09 KiB) Downloaded 288 times
stderr --

Code: Select all

Battle for Wesnoth v1.12.4
Started on Sun Jun 18 13:14:11 2017

Automatically found a possible data directory at C:/Users/Files/Game/Battle for Wesnoth
Data directory: C:/Users/Files/Game/Battle for Wesnoth
User configuration directory: C:/Users/Files/Game/Battle for Wesnoth\userdata
User data directory: C:/Users/Files/Game/Battle for Wesnoth\userdata
Cache directory: C:/Users/Files/Game/Battle for Wesnoth\userdata\cache
Checking video mode: 1440x900x32...
setting mode to 1440x900x32
20170618 13:16:02 warning unit: Unknown attribute 'no_recruit' discarded.
20170618 13:16:02 warning unit: Unknown attribute 'no_recruit' discarded.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm01_eval'; ignoring.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm02_exec'; ignoring.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm02a_units_info'; ignoring.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm03_choose_ca'; ignoring.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm04_highest_score_CA'; ignoring.
20170618 13:16:05 warning engine: Trying to remove non-existent menu item 'm05_play_turn'; ignoring.
20170618 13:47:11 error scripting/lua: ...dd-ons/AI-demos/lua/fred_gamestate_utils_incremental.lua:23: bad argument #1 to '__index' (unknown unit)
stack traceback:
	[C]: in function '__index'
	...dd-ons/AI-demos/lua/fred_gamestate_utils_incremental.lua:23: in function 'get_unit_defense'
	...userdata\data/add-ons/AI-demos/lua/fred_attack_utils.lua:318: in function 'attack_rating'
	...userdata\data/add-ons/AI-demos/lua/fred_attack_utils.lua:1102: in function 'get_attack_combos'
	...userdata\data/add-ons/AI-demos/lua/fred_attack_utils.lua:1362: in function 'calc_counter_attack'
	...h\userdata\data/add-ons/AI-demos/lua/unit_hex_combos.lua:472: in function 'find_best_combo'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3554: in function 'get_hold_action'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4122: in function 'get_zone_action'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4279: in function <... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4171>
	(...tail calls...)
20170618 13:47:11 error scripting/lua: ...Wesnoth\userdata\data/add-ons/AI-demos/lua/ai_helper.lua:212: bad argument #1 to 'check_stopunit' (location (unit/integers) expected, got userdata)
stack traceback:
	[C]: in function 'check_stopunit'
	...Wesnoth\userdata\data/add-ons/AI-demos/lua/ai_helper.lua:212: in function 'checked_stopunit_moves'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4606: in function 'remove_MP_exec'
	[string "(...):remove_MP_exec()"]:1: in main chunk
20170618 13:47:11 error scripting/lua: ... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3965: attempt to index local 'leader' (a nil value)
stack traceback:
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3965: in function <... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3951>
	(...tail calls...)
20170618 13:47:11 error scripting/lua: ... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:1518: bad argument #1 to 'get_unit' (number expected, got nil)
stack traceback:
	[C]: in function 'get_unit'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:1518: in function 'update_ops_data'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4187: in function <... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4171>
	(...tail calls...)
20170618 13:47:11 error scripting/lua: ... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3965: attempt to index local 'leader' (a nil value)
stack traceback:
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3965: in function <... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:3951>
	(...tail calls...)
20170618 13:47:12 error scripting/lua: ... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:767: bad argument #1 to 'get_unit' (number expected, got nil)
stack traceback:
	[C]: in function 'get_unit'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:767: in function 'set_ops_data'
	... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4185: in function <... for Wesnoth\userdata\data\add-ons/AI-demos/lua/fred.lua:4171>
	(...tail calls...)
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm01_eval'; ignoring.
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm02_exec'; ignoring.
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm02a_units_info'; ignoring.
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm03_choose_ca'; ignoring.
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm04_highest_score_CA'; ignoring.
20170618 13:48:44 warning engine: Trying to remove non-existent menu item 'm05_play_turn'; ignoring.
stdout --

Code: Select all

**** Fred 0.14.4 *******************************************************
Beginning of Turn 1 (Dusk) stats	[ t = 120.431 ]
  Side 1: 1 Units (36 HP), 0/16 villages  (Orcish Slayer, 100 gold)
  Side 2: 1 Units (55 HP), 1/16 villages  (Troll, 100 gold)
************************************************************************
=> exec: east: grab_village	[ t = 124.254, dt = 3.909 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 2 (First Watch) stats	[ t = 216.442 ]
  Side 1: 7 Units (274 HP), 1/16 villages  (Orcish Slayer, 18 gold)
  Side 2: 7 Units (274 HP), 2/16 villages  (Troll, 24 gold)
************************************************************************
=> exec: west: grab_village	[ t = 216.769, dt = 0.563 ]
=> exec: west: grab_village	[ t = 217.663, dt = 1.457 ]
=> exec: move_leader_to_keep CA	[ t = 218.590, dt = 2.384 ]
=> exec: east: grab_village	[ t = 219.442, dt = 3.236 ]
=> exec: center: advance	[ t = 220.793, dt = 4.587 ]
=> exec: east: advance	[ t = 221.959, dt = 5.753 ]
=> exec: east: advance	[ t = 222.885, dt = 6.679 ]
=> exec: remove_MP CA	[ t = 224.235, dt = 8.029 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 3 (Second Watch) stats	[ t = 276.704 ]
  Side 1: 8 Units (301 HP), 4/16 villages  (Orcish Slayer, 8 gold)
  Side 2: 9 Units (356 HP), 4/16 villages  (Troll, 2 gold)
************************************************************************
=> exec: west: grab_village	[ t = 277.110, dt = 0.679 ]
=> exec: west: grab_village	[ t = 278.219, dt = 1.788 ]
=> exec: east: grab_village	[ t = 279.015, dt = 2.584 ]
=> exec: center: grab_village	[ t = 279.992, dt = 3.561 ]
=> exec: center: hold	[ t = 281.624, dt = 5.193 ]
=> exec: east: advance	[ t = 282.441, dt = 6.010 ]
=> exec: east: advance	[ t = 283.435, dt = 7.004 ]
=> exec: east: advance	[ t = 284.411, dt = 7.980 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 4 (Dawn) stats	[ t = 327.887 ]
  Side 1: 8 Units (301 HP), 8/16 villages  (Orcish Slayer, 26 gold)
  Side 2: 9 Units (356 HP), 8/16 villages  (Troll, 9 gold)
************************************************************************
=> exec: move_leader_to_keep CA	[ t = 328.165, dt = 0.554 ]
=> exec: east: hold	[ t = 329.836, dt = 2.225 ]
=> exec: east: hold	[ t = 330.252, dt = 2.641 ]
=> exec: east: hold	[ t = 330.555, dt = 2.944 ]
=> exec: center: hold	[ t = 331.969, dt = 4.358 ]
=> exec: west: advance	[ t = 332.906, dt = 5.295 ]
=> exec: west: advance	[ t = 334.036, dt = 6.425 ]
=> exec: west: advance	[ t = 335.187, dt = 7.576 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 5 (Morning) stats	[ t = 423.985 ]
  Side 1: 10 Units (384 HP), 8/16 villages  (Orcish Slayer, 18 gold)
  Side 2: 11 Units (437 HP), 8/16 villages  (Troll, 0 gold)
************************************************************************
=> exec: center: attack	[ t = 424.962, dt = 1.284 ]
=> exec: center: attack	[ t = 426.783, dt = 3.105 ]
=> exec: west: hold	[ t = 430.068, dt = 6.390 ]
=> exec: east: hold	[ t = 431.711, dt = 8.033 ]
=> exec: east: hold	[ t = 432.047, dt = 8.369 ]
=> exec: east: hold	[ t = 432.735, dt = 9.057 ]
=> exec: west: advance	[ t = 433.648, dt = 9.970 ]
=> exec: west: advance	[ t = 434.596, dt = 10.918 ]
=> exec: west: advance	[ t = 435.881, dt = 12.203 ]
=> exec: remove_MP CA	[ t = 437.445, dt = 13.767 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 6 (Afternoon) stats	[ t = 507.918 ]
  Side 1: 11 Units (403 HP), 8/16 villages  (Orcish Slayer, 21 gold)
  Side 2: 12 Units (438 HP), 8/16 villages  (Troll, 0 gold)
************************************************************************
=> exec: east: grab_village	[ t = 508.455, dt = 0.869 ]
=> exec: east: attack	[ t = 510.389, dt = 2.803 ]
=> exec: west: hold	[ t = 514.092, dt = 6.506 ]
=> exec: west: hold	[ t = 514.858, dt = 7.272 ]
=> exec: west: hold	[ t = 516.177, dt = 8.591 ]
=> exec: east: hold	[ t = 518.445, dt = 10.859 ]
=> exec: center: advance	[ t = 520.330, dt = 12.744 ]
=> exec: west: advance	[ t = 521.701, dt = 14.115 ]
=> exec: west: advance	[ t = 522.460, dt = 14.874 ]
=> exec: west: advance	[ t = 523.978, dt = 16.392 ]
=> exec: remove_MP CA	[ t = 525.804, dt = 18.218 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 7 (Dusk) stats	[ t = 643.297 ]
  Side 1: 12 Units (399 HP), 9/16 villages  (Orcish Slayer, 25 gold)
  Side 2: 12 Units (414 HP), 7/16 villages  (Troll, 13 gold)
************************************************************************
=> exec: west: hold	[ t = 645.935, dt = 2.944 ]
=> exec: west: hold	[ t = 646.148, dt = 3.157 ]
=> exec: east: hold	[ t = 648.323, dt = 5.332 ]
=> exec: east: hold	[ t = 648.647, dt = 5.656 ]
=> exec: center: hold	[ t = 650.889, dt = 7.898 ]
=> exec: west: advance	[ t = 652.898, dt = 9.907 ]
=> exec: west: advance	[ t = 654.184, dt = 11.193 ]
=> exec: west: advance	[ t = 655.057, dt = 12.066 ]
=> exec: west: advance	[ t = 656.082, dt = 13.091 ]
=> exec: all_map: attack	[ t = 656.973, dt = 13.982 ]
=> exec: all_map: advance	[ t = 658.239, dt = 15.248 ]
=> exec: all_map: advance	[ t = 658.593, dt = 15.602 ]
=> exec: all_map: attack	[ t = 658.967, dt = 15.976 ]
=> exec: remove_MP CA	[ t = 661.401, dt = 18.410 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 8 (First Watch) stats	[ t = 782.509 ]
  Side 1: 10 Units (363 HP), 8/16 villages  (Orcish Slayer, 29 gold)
  Side 2: 13 Units (456 HP), 8/16 villages  (Troll, 3 gold)
************************************************************************
=> exec: west: hold	[ t = 784.583, dt = 2.402 ]
=> exec: west: hold	[ t = 785.079, dt = 2.898 ]
=> exec: west: hold	[ t = 785.259, dt = 3.078 ]
=> exec: east: hold	[ t = 786.791, dt = 4.610 ]
=> exec: east: hold	[ t = 787.435, dt = 5.254 ]
=> exec: center: hold	[ t = 788.742, dt = 6.561 ]
=> exec: all_map: retreat	[ t = 789.361, dt = 7.180 ]
=> exec: all_map: retreat	[ t = 790.737, dt = 8.556 ]
=> exec: west: advance	[ t = 792.072, dt = 9.891 ]
=> exec: remove_MP CA	[ t = 794.179, dt = 11.998 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 9 (Second Watch) stats	[ t = 913.174 ]
  Side 1: 11 Units (391 HP), 8/16 villages  (Orcish Slayer, 28 gold)
  Side 2: 14 Units (510 HP), 8/16 villages  (Troll, 5 gold)
************************************************************************
=> exec: west: attack	[ t = 914.371, dt = 1.535 ]
=> exec: west: attack	[ t = 915.730, dt = 2.894 ]
=> exec: west: hold	[ t = 919.639, dt = 6.803 ]
=> exec: top: hold	[ t = 922.019, dt = 9.183 ]
=> exec: top: hold	[ t = 922.652, dt = 9.816 ]
=> exec: top: hold	[ t = 924.669, dt = 11.833 ]
=> exec: top: hold	[ t = 925.301, dt = 12.465 ]
=> exec: all_map: retreat	[ t = 926.567, dt = 13.731 ]
=> exec: west: advance	[ t = 927.545, dt = 14.709 ]
=> exec: west: advance	[ t = 928.122, dt = 15.286 ]
=> exec: remove_MP CA	[ t = 930.575, dt = 17.739 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 10 (Dawn) stats	[ t = 1139.303 ]
  Side 1: 12 Units (453 HP), 7/16 villages  (Orcish Slayer, 14 gold)
  Side 2: 14 Units (532 HP), 9/16 villages  (Troll, 6 gold)
************************************************************************
=> exec: top: attack	[ t = 1139.968, dt = 1.003 ]
=> exec: leader_threat: leader_threat: recruit for leader protection	[ t = 1142.549, dt = 3.584 ]
=> exec: west: hold	[ t = 1145.674, dt = 6.709 ]
=> exec: west: hold	[ t = 1146.314, dt = 7.349 ]
=> exec: west: hold	[ t = 1146.515, dt = 7.550 ]
=> exec: west: attack	[ t = 1147.775, dt = 8.810 ]
=> exec: west: hold	[ t = 1150.449, dt = 11.484 ]
=> exec: top: hold	[ t = 1152.118, dt = 13.153 ]
=> exec: top: hold	[ t = 1152.733, dt = 13.768 ]
=> exec: top: hold	[ t = 1153.014, dt = 14.049 ]
=> exec: west: advance	[ t = 1154.794, dt = 15.829 ]
=> exec: west: advance	[ t = 1156.532, dt = 17.567 ]
=> exec: east: advance	[ t = 1157.971, dt = 19.006 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 11 (Morning) stats	[ t = 1257.378 ]
  Side 1: 13 Units (433 HP), 6/16 villages  (Orcish Slayer, 10 gold)
  Side 2: 16 Units (577 HP), 10/16 villages  (Troll, 2 gold)
************************************************************************
=> exec: move_leader_to_keep CA	[ t = 1257.726, dt = 0.686 ]
=> exec: top: attack	[ t = 1259.769, dt = 2.729 ]
=> exec: top: attack	[ t = 1262.330, dt = 5.290 ]
=> exec: west: hold	[ t = 1267.115, dt = 10.075 ]
=> exec: west: hold	[ t = 1270.286, dt = 13.246 ]
=> exec: west: hold	[ t = 1270.594, dt = 13.554 ]
=> exec: all_map: retreat	[ t = 1273.069, dt = 16.029 ]
=> exec: all_map: retreat	[ t = 1275.787, dt = 18.747 ]
=> exec: west: advance	[ t = 1278.610, dt = 21.570 ]
=> exec: west: advance	[ t = 1280.554, dt = 23.514 ]
=> exec: west: advance	[ t = 1282.432, dt = 25.392 ]
=> exec: center: advance	[ t = 1283.379, dt = 26.339 ]
=> exec: east: advance	[ t = 1284.729, dt = 27.689 ]
=> exec: remove_MP CA	[ t = 1286.326, dt = 29.286 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 12 (Afternoon) stats	[ t = 1417.194 ]
  Side 1: 12 Units (396 HP), 4/16 villages  (Orcish Slayer, 13 gold)
  Side 2: 18 Units (617 HP), 12/16 villages  (Troll, 0 gold)
************************************************************************
=> exec: top: attack	[ t = 1419.755, dt = 2.912 ]
=> exec: top: attack	[ t = 1421.084, dt = 4.241 ]
=> exec: top: attack	[ t = 1422.729, dt = 5.886 ]
=> exec: leader_threat: leader_threat: recruit for leader protection	[ t = 1426.340, dt = 9.497 ]
=> exec: west: hold	[ t = 1432.290, dt = 15.447 ]
=> exec: west: hold	[ t = 1436.684, dt = 19.841 ]
=> exec: west: hold	[ t = 1436.915, dt = 20.072 ]
=> exec: west: hold	[ t = 1439.832, dt = 22.989 ]
=> exec: west: hold	[ t = 1440.551, dt = 23.708 ]
=> exec: west: hold	[ t = 1441.155, dt = 24.312 ]
=> exec: all_map: retreat	[ t = 1442.631, dt = 25.788 ]
=> exec: center: advance	[ t = 1444.225, dt = 27.382 ]
=> exec: remove_MP CA	[ t = 1444.909, dt = 28.066 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 13 (Dusk) stats	[ t = 1587.563 ]
  Side 1: 12 Units (364 HP), 3/16 villages  (Orcish Slayer, 1 gold)
  Side 2: 18 Units (611 HP), 13/16 villages  (Troll, 24 gold)
************************************************************************
=> exec: west: attack	[ t = 1589.009, dt = 1.775 ]
=> exec: west: attack	[ t = 1590.607, dt = 3.373 ]
=> exec: west: attack	[ t = 1592.061, dt = 4.827 ]
=> exec: top: attack	[ t = 1594.580, dt = 7.346 ]
=> exec: west: hold	[ t = 1597.863, dt = 10.629 ]
=> exec: west: hold	[ t = 1598.179, dt = 10.945 ]
=> exec: top: hold	[ t = 1600.199, dt = 12.965 ]
=> exec: top: hold	[ t = 1600.498, dt = 13.264 ]
=> exec: all_map: retreat	[ t = 1602.165, dt = 14.931 ]
=> exec: center: advance	[ t = 1604.171, dt = 16.937 ]
=> exec: all_map: advance	[ t = 1605.428, dt = 18.194 ]
=> exec: remove_MP CA	[ t = 1606.035, dt = 18.801 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 14 (First Watch) stats	[ t = 1777.028 ]
  Side 1: 11 Units (276 HP), 3/16 villages  (Orcish Slayer, 2 gold)
  Side 2: 21 Units (713 HP), 13/16 villages  (Troll, 5 gold)
************************************************************************
=> exec: top: attack	[ t = 1778.910, dt = 2.244 ]
=> exec: top: attack	[ t = 1781.372, dt = 4.706 ]
=> exec: top: attack	[ t = 1785.229, dt = 8.563 ]
=> exec: top: attack	[ t = 1786.978, dt = 10.312 ]
=> exec: west: hold	[ t = 1793.007, dt = 16.341 ]
=> exec: west: hold	[ t = 1793.651, dt = 16.985 ]
=> exec: west: hold	[ t = 1794.353, dt = 17.687 ]
=> exec: east: advance	[ t = 1797.281, dt = 20.615 ]
=> exec: all_map: attack	[ t = 1798.566, dt = 21.900 ]
=> exec: all_map: advance	[ t = 1800.510, dt = 23.844 ]
=> exec: all_map: advance	[ t = 1801.443, dt = 24.777 ]
=> exec: all_map: advance	[ t = 1802.654, dt = 25.988 ]

**** Fred 0.14.4 *******************************************************
Beginning of Turn 15 (Second Watch) stats	[ t = 1969.970 ]
  Side 1: 5 Units (121 HP), 2/16 villages  (Orcish Slayer, 6 gold)
  Side 2: 20 Units (667 HP), 14/16 villages  (Troll, 27 gold)
************************************************************************
=> exec: top: attack	[ t = 1971.698, dt = 2.017 ]
=> exec: top: attack	[ t = 1973.109, dt = 3.428 ]
=> exec: top: hold	[ t = 1977.165, dt = 7.484 ]
=> exec: remove_MP CA	[ t = 1979.856, dt = 10.175 ]
The battle was effectively concluded at that point anyway though. It went fast, maybe because being a mirror match meant there was no time spent attacking and retreating based on time of day.


But in total contrast, due to my hubris and overly aggressive strategy, the next match (as undead) got well out of hand and lasted 40 turns:
14.4_versus_unwise.gz
(36.24 KiB) Downloaded 306 times
This is effectively what happens whenever I don't remain in the mindset that I am against a human opponent. Unless it has a significant income bonus, you can walk through RCA like it mostly isn't there. But with no bonus, Fred will effectively punish poor play and thereby draw out a battle until you resume a respectfully conservative play style. I actually made a similar mistake during the drake match but restarted to demonstrate Fred's current state against competent play (and totally not out of personal shame ;)), but it would have otherwise dragged out as long otherwise.
User avatar
Krogen
Posts: 310
Joined: January 1st, 2013, 3:43 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by Krogen »

I just found this topic and downloaded the add-on. (I didn't read the full conversation though.) And wow! I actually had to make plans and think about my next move to beat Fred safely. This is just great. I like how he thanks for the game at the end. :)
I can give one advice: (Again, I didn't read the conversation, so i don't know if this was already discussed.)
I was with Drakes, and Fred kept recruiting troll whelps. Probably it would be a good idea to make it recruit units effective against the opponent's faction.
"A lion doesn't concern himself with the opinions of the sheep." - Tywin Lannister
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by mattsc »

Cold Steel wrote:Well just looking at the task list it seems you are tearing into it, with many more boxes checked than unchecked after only a short time.
Well, yes, but unfortunately it's not quite linear in number of tasks. Things like "better pre-selection" is a rather open-ended task that could take forever just by itself. :P Nevertheless, progress is being made, so that's good.

Thanks for the replays against Northerners and Undead. Fred's showing the usual weaknesses you/we have seen in your previous replays, but overall I am pleased for the current state of the code and it's good to see that he's not letting you get away with getting too careless. ;) The work currently planned for 0.14.6 (improving defensive positioning) is going to be a challenge, but I have a lot of great test cases from your replays now.

As for the error: interesting... I was able to reproduce it and track it down. It's one of those cases where the code looks into "what if I did this" situations and a unit is not moved correctly out of the way. I'm not entirely sure yet if it only happens when the keep is blocked, but it's definitely related to that. Either way I have what I need to fix it.
Krogen wrote:I just found this topic and downloaded the add-on. (I didn't read the full conversation though.) And wow! I actually had to make plans and think about my next move to beat Fred safely. This is just great. I like how he thanks for the game at the end. :)
I can give one advice: (Again, I didn't read the conversation, so i don't know if this was already discussed.)
I was with Drakes, and Fred kept recruiting troll whelps. Probably it would be a good idea to make it recruit units effective against the opponent's faction.
Thanks, Krogen. :) That's great to hear. Thanks also for the comment on recruiting. The recruiting code is quite old and needs some work. It does try to take the opponent units (both on the map and the recruit list) into account, but it does so in a general sense that could certainly be improved. I will eventually get to that. In the meantime (to save you the trouble of having to search through the thread) I've put out a plan for the next couple releases. So it's going to be a little until I get to recruiting.

My eventual goal is to have Fred be able to play against any opponent on any map (well, most maps, probably) with very minor input from the map/scenario creator, but with lots of customization options. So, for example, if I cannot get him to figure out automatically how to recruit best against a given faction, it will be possible to give him map or faction specific instructions.
User avatar
Krogen
Posts: 310
Joined: January 1st, 2013, 3:43 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by Krogen »

That's a nice list and admirable goals, good luck with that! Maybe one day Fred will be able to hold his own against truly experienced players or even beat them...?
In my free hours i'll play some games with Fred, if i discover anything that could be useful, ofc i'll tell here.
"A lion doesn't concern himself with the opinions of the sheep." - Tywin Lannister
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by mattsc »

Thanks, Krogen, I'm looking forward to any comments you may have. As you probably have noticed even without reading all the posts, there are quite a few open and known issues that I will slowly be working on. But as I wrote to Cold Steel a couple weeks ago, any comment is appreciated. As for this:
Krogen wrote:Maybe one day Fred will be able to hold his own against truly experienced players or even beat them...?
Yeah, well, that would be nice, but that's not going to happen. I don't know whether it is theoretically possible, maybe if you put one of those teams on it that write champion level go or chess AIs, but I have worked on this for long enough that I know where my limits are. That's fine as far as I am concerned, no complaints, I just don't want to raise the wrong expectations here. :)
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.4

Post by pauxlo »

mattsc wrote:
Krogen wrote:Maybe one day Fred will be able to hold his own against truly experienced players or even beat them...?
Yeah, well, that would be nice, but that's not going to happen. I don't know whether it is theoretically possible, maybe if you put one of those teams on it that write champion level go or chess AIs, ...
Also note that those AIs take a lot more computing power (and accumulated knowledge) than what is realistically possible to put into a Wesnoth client on an average PC.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.5

Post by mattsc »


Fred / AI-demos v0.14.5 is now on the Wesnoth 1.12 add-ons server

This version was almost entirely about updates and changes to the attack evaluation. As with previous versions, the changes are largely incremental. While I can show that Fred behaves differently in specific situations, it might be difficult to notice this in normal gameplay.

One exception to this might be how Fred deals with units with significant amounts of XP in attacks (and in attacks only for this release). He is now more careful with them, and he also tries to maximize the chance of giving the unit closest to leveling the kill. As a result, he now typically ends up with 3 to 5 leveled-up units in games against the default AI (if the latter has 125 gold). Of course, I expect this effect to be less significant and noticeable against a human player.

Note that pretty much none of the issues raised recently by Cold Steel, Krogen and others was addressed in this release. These are the subject of the 1.14.6 and 1.14.7 releases.

See
Issue #13: Fred: Tasks for the 0.14.5 release
Issue #14: Fred: Tasks for the 0.14.6 release
for a summary of what was done and a tentative plan for the next few releases.
v0.14.5 complete changelog

Code: Select all

----- 0.14.5, 13 Aug 2017 -----

The majority of this release is dedicated to Fred's attack evaluation code. It
contains many changes to the attack evaluation and execution code, only the more
important of which are mentioned here.

- Fred (Freelands AI for Northerners, Side 1):
  - Attacks:
    - Attack rating:
      - Improve accounting for weapon specials and traits in attack ratings
      - Rating now takes into account whether unit is injured already
      - Improve accounting for XP in rating
      - Do not count slow as a delayed damage
    - Attack evaluation
      - Better protection of high-XP units when used in attacks (this does not
        protect them for holding/advancing/retreating ...)
      - Improve evaluation of danger to AI leader when used in attacks
      - Correctly calculate poison/slow in attack outcomes
      - Correctly account for leveling up through attack combos
      - Use actual next-level unit information in level-up evaluation
      - Correctly account for poison/slow propagation through attack combos
      - Improve accounting for weapon specials and traits in best weapon
        selection
      - Be more careful about exposure when attacking with one or two units
      - Consider plague in the attack evaluation
      - Discourage use of poison, slow and plague attacks under certain
        circumstances
      - Reduce trapping bonus if target has chance to die
      - Improve attack resource limitation criteria
    - Attack execution:
      - Reorder units used in attack to maximize XP gain and leveling up
      - Pass weapon choice from evaluation to execution function
    - Operations:
      - Use fred_attack_utils functions for some evaluations for consistency
      - Disambiguate zone and action ratings, to make them uniquely repeatable
    - Lots of internal changes, renaming and refactoring, such as:
      - Poison/slow percentages do not include the HP=0 case any more
      - Rename stat -> outcome, prob -> chance etc. for consistency
      - Simplify function calls, arguments, return values
      - Remove some functions from the globally accessible tables, making them
        local if only needed locally
      - Add unit_map to gamedata
      - calc_counter_attack now returns nil if no counter attacks found
      - attack_combo_eval: combine return values into one table
      - Lots of bug fixes
  - Misc. not attack related changes:
    - Improve accounting for weapon specials and traits in village grabbing and
      retreat evaluations
    - Fix a rare bug in the holding code that could crash the AI in some cases
      when the leader is blocked from returning to the keep
    - Add list of leveled AI units to Stats CA output
    - Rename unit_hex_combos.lua -> fred_hold_utils.lua and move some
      functions into other libraries
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Help with testing Fred - Freelands MP Custom AI v0.14.5

Post by mattsc »

So ... just for fun* I ran a whole bunch of batch tests of Fred vs. the default AI. 2 sets of 50 games against each faction with equal (100) gold. 2 sets against each faction with 125 gold for the default AI (vs. Fred's 100). And 4 sets of 50 games against each faction when the default AI has 60% more gold than Fred. Here are the results:

Code: Select all

v0.14.5

enemy gold   100               125               160

Drakes       50-0   50-0       48-2   47-3       34-16   26-24   32-18   29-21  (60.5%)
Knalgans     50-0   50-0       50-0   50-0       43-7    41-9    39-11   39-11  (81.0%)
Loyalists    50-0   50-0       48-2   47-3       41-9    35-15   33-17   34-16  (71.5%)
Northerners  50-0   49-1       47-3   49-1       29-21   32-18   30-20   35-15  (63.0%)
Rebels       50-0   50-0       50-0   49-1       43-7    44-6    44-6    43-7   (87.0%)
Undead       50-0   50-0       49-1   50-0       42-8    45-5    39-11   44-6   (85.0%)

win rate     100%   99.7%      97.3%  97.3%      77.3%   74.3%   72.3%   74.7%  (74.7%)
I wouldn't draw too many conclusions from that (esp. for a human player) other than that
  1. Fred is holding his own alright against the default AI, but that
  2. I still have not reached my goal of a 100% win rate against the default AI on even terms.

*Well, as I have pointed out before, it's not quite just for fun. It's also to see if there are any AI-crashing errors in the code. Result: there seem to be a few, but they occur very infrequently (in <1% of the games), so it is really hard to track them down. I've managed to identify and fix a couple of them, but not yet all. Meaning: if you encounter an error, please by all means send me the replay of the game together with the error message.
Post Reply