Exercises in Formula and Lua AI and AI-demos add-on feedback

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
tadpol
Posts: 38
Joined: March 14th, 2006, 8:08 pm
Location: Oregon USA, where the sky is cloudy all day

Re: Exercises in Formula and Lua AI

Post by tadpol »

grunt rush vs elves.

turn 6. a multi-suicide attempt on my leader fails because an assassin takes a village before the combat starts. There is a unit that can't help with the kill in range of the village.

The behavior on the left side didn't seem very clever. A wolf doesn't run at 1/4 hp vs 2 full health elves. A grunt wanders off into the woods not threatening anything or retreating to safety. A goblin stops next to an unoccupied village I can reach.
Attachments
exp_ai_vs_elves.gz
(20.66 KiB) Downloaded 199 times
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Exercises in Formula and Lua AI

Post by AI »

Attempting to run 'dragon' on recent trunk results in this:

Code: Select all

wesnoth: src/shared_object.hpp:79: const T& shared_object<T, node>::get() const [with T = t_string_base, node = shared_node<t_string_base>]: Assertion `valid()' failed.
Aborted
Backtrace: http://pastebin.com/xWN1jxq6
With debug symbols: http://pastebin.com/EnaLMsP4

It's starting to look like this is related to GSOC carryover changes.
nelson
Posts: 91
Joined: March 19th, 2008, 11:15 pm
Contact:

Re: Exercises in Formula and Lua AI

Post by nelson »

mattsc, is there any chance you could put the code for the grunt rush AI etc. on Github to make it easier for people to collaborate with you on writing the code? I'm a programming noob but I could probably help with minor refinements. Also, version control is a good thing even if people don't help you ;-)
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

nelson wrote:mattsc, is there any chance you could put the code for the grunt rush AI etc. on Github to make it easier for people to collaborate with you on writing the code? I'm a programming noob but I could probably help with minor refinements. Also, version control is a good thing even if people don't help you ;-)
Sure, I can do this. I just need to take the time to learn how to set it up, which is time I won't have to work on the coding itself. But in the long run that's time well spent, of course, if it means others can help with this. That would be great. (Btw, the reason why I haven't so far is that I never thought this work would grow to this complexity and that others would actually be interested in it. I figured I'd set up a few examples of modifying AI behavior and be done with it. :D)

Btw, I do have my own version control system, so I can easily revert any part of the grunt rush, if that's desired. I have seen you comment in the replays that you think the previous version played better than the current one, and I agree with that if you just look at the current play. However, I do believe that the current version has much more potential, it's just unfinished and badly tuned at this time. I probably should not have published it when I did, but with a 2-week coding hiatus looming, I wanted to show some progress. Didn't quite work out that way, oh well. I am back now and will start working on it again, although work's suddenly turned quite busy, so progress will still be somewhat slow.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Exercises in Formula and Lua AI

Post by Anonymissimus »

Nah, put it into the wesnoth-umc-dev repository: http://wesnoth-umc-dev.ai0867.net/
That's where almost all of the wml wizards are. :)

Looks like AI's bug has to do with some menu item, I think you should report that to Ayne, yes.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
nelson
Posts: 91
Joined: March 19th, 2008, 11:15 pm
Contact:

Re: Exercises in Formula and Lua AI

Post by nelson »

Anonymissimus wrote:Nah, put it into the wesnoth-umc-dev repository: http://wesnoth-umc-dev.ai0867.net/
That's where almost all of the wml wizards are. :)
Personally I think Github is the most user-friendly version control system ever created, and it makes it shockingly easy to contribute patches to a project. For example, http://ladder8.herokuapp.com/ is on Github at https://github.com/f6p/ladder8 and I submitted a trivial patch to the website (just editing some text) entirely through the browser without ever downloading the source or anything. It also comes with a bug tracker, a wiki and other useful stuff.

It's possible that using the wesnoth-umc-dev Subversion repository might be better if it makes it easy for existing UMC devs to contribute and they would be less likely to contribute to a Github repository. However, I think that Github has such superior technology for encouraging collaboration and is being improved so regularly that you'd be crazy to use anything else.

EDIT: A possible compromise would be to put it into both repositories and just sync the two every now and then, but if people really contribute in both places that could create a lot of unnecessary overhead.
nelson
Posts: 91
Joined: March 19th, 2008, 11:15 pm
Contact:

Re: Exercises in Formula and Lua AI

Post by nelson »

Incidentally, I don't want to completely sidetrack this thread, but has anyone considered trying to use machine learning to train a Wesnoth AI? If we used all of the archives of ladder games, plus a bunch of automated AI vs. AI games, we could probably get a pretty beefy data set to use in training an AI. My understanding is that the secret to doing machine learning well is getting a huge data set, if you can get enough data machine learning becomes much easier. I wouldn't want to scrap the current knowledge-based approach to the AI, but there's no reason we couldn't try a machine-learning AI as well.

Also, I'd just like to mention that the reason I'm excited about this AI (and I assume why others are excited too) is that it is the only Wesnoth AI that I've seen that can come close to beating a human player in a fair game. It is challenging, and if we can create an AI that is challenging to top players it should dramatically increase the quality of play we see from new Wesnoth players who are able to train against it.
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Exercises in Formula and Lua AI

Post by Ravana »

In the ai demo campaign, dragon part it did nothing once poisoned and surrounded.
Attachments
AI-demos-Dragon_replay.gz
(9.06 KiB) Downloaded 198 times
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

Ravana wrote:In the ai demo campaign, dragon part it did nothing once poisoned and surrounded.
That's not so good... Thanks for reporting. I thought I had it set up that the default AI would take over in that case, but I might remember incorrectly (or the default AI might be deciding that there's no benefit in attacking in that situation). I'll look into it.
nelson wrote:Incidentally, I don't want to completely sidetrack this thread, but has anyone considered trying to use machine learning to train a Wesnoth AI?
Check out http://forum.wesnoth.org/viewtopic.php? ... 2&start=30. I haven't had time to check this out yet, but I will. I also don't know anything about this myself, but hopefully SeattleDad will continue to work on this.
nelson wrote:Also, I'd just like to mention that the reason I'm excited about this AI (and I assume why others are excited too) is that it is the only Wesnoth AI that I've seen that can come close to beating a human player in a fair game. It is challenging, and if we can create an AI that is challenging to top players it should dramatically increase the quality of play we see from new Wesnoth players who are able to train against it.
Thanks for the compliment. As I said (I think it was you to whom I said that), the AI will never be able to beat a good human player (maybe occasionally through luck, but not consistently), but in some of the games I've watched, I am already quite pleased to see how long it lasts. :) Hopefully, the next updates will make it be able to survive for even a couple more turns...

As for the github vs. wesnoth-umc-dev discussion: I neither have experience nor really an opinion on that (other than that I do not want to do both). The arguments for both sides make sense to me.
User avatar
alexanderthegre
Posts: 193
Joined: December 8th, 2011, 3:23 am
Location: nowhere

Re: Exercises in Formula and Lua AI

Post by alexanderthegre »

nelson wrote: Also, I'd just like to mention that the reason I'm excited about this AI (and I assume why others are excited too) is that it is the only Wesnoth AI that I've seen that can come close to beating a human player in a fair game. It is challenging, and if we can create an AI that is challenging to top players it should dramatically increase the quality of play we see from new Wesnoth players who are able to train against it.
It beat me... :oops:
But then again I was playing drakes-- I'm bad at that. I'd post the replay, but I don't have it anymore.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

alexanderthegre wrote:It beat me... :oops:
Woohoo, it won one!! :lol2: Sorry, I didn't mean any insult to anybody and it probably just got lucky (I mean lucky in choosing the right combination of moves, not RNG luck, although that helps too ;)). Actually, it has beaten me also - although I usually win, but that's because I know exactly what it's going to do and how to exploit its weaknesses, and not because I am such a great player. I bet if you played against it bunch of times, you wouldn't have too many problems. One of the great strength of human players is that we can adapt to our opponents. Teaching that to an AI is rather difficult.

Seriously though, thanks for reporting this! It's nice to know that the AI wins from time to time. Most of the time I just see it get slaughtered, so it's good to know that it does ok sometimes too, even if that's against your weak faction.
Last edited by mattsc on August 6th, 2012, 1:10 am, edited 1 time in total.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Exercises in Formula and Lua AI

Post by Anonymissimus »

as for umc-dev vs github: nelson, I don't question that there are good reasons for both, we (mainline devs) even considered moving the mainline source to github. But IMO this question has been decided at the point when shadowmaster and esr did set up the umc repository. It makes no sense to set up side projects at github or wherever. It's better in case all of the related authors disappear, like it did happen for many of the projects in umc-dev, so it doesn't get lost and can easily be taken over.
(Personally, I mostly use git-svn anyway.)

Well, this AI certainly plays better than many beginners I've encountered at the mp server.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
nelson
Posts: 91
Joined: March 19th, 2008, 11:15 pm
Contact:

Re: Exercises in Formula and Lua AI

Post by nelson »

Anonymissimus wrote:It's better in case all of the related authors disappear, like it did happen for many of the projects in umc-dev, so it doesn't get lost and can easily be taken over.
I'm not sure that losing the original authors is a serious concern on Github. One thing I like about Github is how easy it is to fork projects that have been abandoned and for a new person to carry the torch. If the old author comes back, you can easily merge in the changes from the fork and let the original author run things again.

I just think Sourceforge and SVN are an antiquated way of doing things. The barrier to entry on Github is much lower, it's much easier to get involved.

However, I am willing to learn to use whatever repository mattsc sets up, and I will contribute no matter what decision he makes.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

So, I understand the arguments for and against umc-dev and github and both make perfect sense to me. In the end, I essentially made the decision based on the fact that my time available for Wesnoth is not plentiful at the moment and chose the one that seemed easiest and quickest to set up. I make no claims that this is a good decision, makes sense, or anything along those lines. ;) Meaning:

AI-Demos is now available for others to participate on github at this link.

Anonymissimus, to simplify things in case I might disappear (I'm not planning to but, hey, stuff happens), I'd be perfectly happy to give you or one of the other devs (maybe Crab?) admin access to this.

So, nelson (and others), if I understand that right, I need your github user name so that I can give you commit access? Send it to me in a PM and I'll set it up. Any help with this would be great, especially since it looks like I will not have much time to work on this at least until the end of August. Thanks much!

I also enabled the wiki page for the repository, but for now it only includes a cut and paste of my personal todo list. Don't expect that to make much sense yet. It's written for me, so I didn't put down any explanations. I'll add to that in time.
Anonymissimus wrote:Well, this AI certainly plays better than many beginners I've encountered at the mp server.
:) Thanks.
nelson
Posts: 91
Joined: March 19th, 2008, 11:15 pm
Contact:

Re: Exercises in Formula and Lua AI

Post by nelson »

Thanks for choosing Github, I'm happy ;-) Technically you don't *have* to give us commit access in order to accept contributions, we could just submit pull requests and you could merge the patches yourself, but if you give us commit access then I believe we can handle pull requests for you :)

I guess a reasonable thing for us to work on next would be to write clear, detailed bug reports with objective criteria so we know when they are fixed. It's very hard to put strategic and tactical improvements into the form of a bug report >.<
Post Reply