How to Write Your Own AI
Moderator: Forum Moderators
How to Write Your Own AI
I have written a guide on how to write your own Wesnoth AI in C++.
You can read it at http://wesnoth.slack.it/?WritingYourOwnAI
(fairly strong knowledge of C++ is likely required).
I look forward to seeing other people's AI's!
David
You can read it at http://wesnoth.slack.it/?WritingYourOwnAI
(fairly strong knowledge of C++ is likely required).
I look forward to seeing other people's AI's!
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
-
- Posts: 129
- Joined: April 27th, 2004, 4:24 pm
I can't get the AI vs AI multiplayer battle to work. (I haven't written the AI yet, but I thought I would start by making sure I could run the tests).
I'm running Wesnoth 0.7.5 and trying the command:
wesnoth --nogui --multiplayer --controller1=ai --controller2=ai --algorithm1=z_ai --algorithm2=z_ai
It parses the command line normally but then says "cannot find side" and quits out.
I tried passing --side1=orc --side2=elf as additional arguments, but that didn't help.
How do I get this to work?
I'm running Wesnoth 0.7.5 and trying the command:
wesnoth --nogui --multiplayer --controller1=ai --controller2=ai --algorithm1=z_ai --algorithm2=z_ai
It parses the command line normally but then says "cannot find side" and quits out.
I tried passing --side1=orc --side2=elf as additional arguments, but that didn't help.
How do I get this to work?
Oops. It looks for data for the sides in a multiplayer game (the [multiplayer_side] tags), but since 0.7.5 they are encapsulated in [era] tags. Workaround for 0.7.5: edit your data/multiplayer.cfg file and find the 'default' era and make copies of all the [multiplayer_side] tags and put them outside of the [era] tag.mlangsdorf wrote: It parses the command line normally but then says "cannot find side" and quits out.
I have committed a fix to this problem to the CVS.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
-
- Posts: 129
- Joined: April 27th, 2004, 4:24 pm
Thanks for that suggestion, it seems to have fixed the problem.
How does it decide what two races are in the fight? It looks like human versus human, but with the default AI, the first player wins 80% of the time (20 out of 25 games).
I'm going to do a longer analysis run tonight and see if that changes
anything.
Also, is there any possibility of restructuring choose_weapon so that it is part of the ai_interface class, and changing attack_analysis() to use ai_interface instead of ai? As it is now, every AI writer has to write a new attack_analysis(), even if they're happy with the standard attack routines.
I could do it for my local copy, but it seems like it'd be a useful change in general.
How does it decide what two races are in the fight? It looks like human versus human, but with the default AI, the first player wins 80% of the time (20 out of 25 games).
I'm going to do a longer analysis run tonight and see if that changes
anything.
Also, is there any possibility of restructuring choose_weapon so that it is part of the ai_interface class, and changing attack_analysis() to use ai_interface instead of ai? As it is now, every AI writer has to write a new attack_analysis(), even if they're happy with the standard attack routines.
I could do it for my local copy, but it seems like it'd be a useful change in general.
You can run without the --nogui option to see for sure.mlangsdorf wrote: How does it decide what two races are in the fight? It looks like human versus human,
To set which sides are fighting use e.g. "--side1=Elvish Lord" to set side1 to be rebels. "--side2=Lich" to set side 2 to Undead, and so forth.
Probably the default map with Loyalists favors side 1.mlangsdorf wrote: but with the default AI, the first player wins 80% of the time (20 out of 25 games).
You can use --scenario=scenario-id to change the multiplayer scenario used.
What I'm considering doing is making most of the functions in 'ai' virtual, so if people want, they can derive their new AI from the default AI and just override the behavior they want to change.mlangsdorf wrote: Also, is there any possibility of restructuring choose_weapon so that it is part of the ai_interface class, and changing attack_analysis() to use ai_interface instead of ai? As it is now, every AI writer has to write a new attack_analysis(), even if they're happy with the standard attack routines.
I could do it for my local copy, but it seems like it'd be a useful change in general.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
-
- Posts: 129
- Joined: April 27th, 2004, 4:24 pm
[quote="Dave"]What I'm considering doing is making most of the functions in 'ai' virtual, so if people want, they can derive their new AI from the default AI and just override the behavior they want to change.
[/quote]
Please do. It'd make it a lot easier to "tweak" the current AI and simplify writing new ones.
[/quote]
Please do. It'd make it a lot easier to "tweak" the current AI and simplify writing new ones.
Working on a new AI
I've begun serious work on a new learning AI for the Battle For Wesnoth. It's based on a new idea I've been playing with for a while - a decision tree that has action scripts at the bottom of every branch and observes player action to create new actions and branches. Anyone interested is welcome to email me at geva_yashfe@sbcglobal.net
Questions are welcome, ideas even more so. There is no working code atm but there is a bunch of written information and a few functions/algorithms.
Questions are welcome, ideas even more so. There is no working code atm but there is a bunch of written information and a few functions/algorithms.
2B |! 2B = 3F
Re: Working on a new AI
I'm still concerned about the processor power this would require, and all the other points I made when I played you. But that was before 0.8.3, which doesn't work on 10.2.8...ryn wrote:I've begun serious work on a new learning AI for the Battle For Wesnoth. It's based on a new idea I've been playing with for a while - a decision tree that has action scripts at the bottom of every branch and observes player action to create new actions and branches. Anyone interested is welcome to email me at geva_yashfe@sbcglobal.net
Questions are welcome, ideas even more so. There is no working code atm but there is a bunch of written information and a few functions/algorithms.
"ILLEGITIMIS NON CARBORUNDUM"
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Re: Working on a new AI
Sure this is a concern. Just like the concerns that the AI will be too dumb, or too complex, or too limited in scope, or unimplementable.MadMax wrote:I'm still concerned about the processor power this would require
We can only wait and see how well it can be done
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming