<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ryo</id>
	<title>The Battle for Wesnoth Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ryo"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Ryo"/>
	<updated>2026-05-01T19:44:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7814</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7814"/>
		<updated>2006-03-02T21:29:46Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Cheating */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Having access to the properties 'HP' and 'Poisonned' of a unit. This would allow focussing on already damaged units when attacking and sending low HP units for rest. It could improve dramatically python AI efficiency. [[User:Viorc|Viorc]]&lt;br /&gt;
&lt;br /&gt;
:added ''hitpoints'', ''max_hitpoints'' and ''poisoned'', thanks for the patch :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:22, 2 March 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== chance to kill ==&lt;br /&gt;
&lt;br /&gt;
Can I get a chance_to_kill(wesnoth.location)? And it would tell me the chance to kill the unit at the given location, using terrain modifiers and everything.. I assume, the C++ AI has something like it available. [[User:Allefant|Allefant]] 22:39, 10 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:I'll check what the C++ has, and export it. [[User:Ryo|Ryo]] 09:24, 11 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:Ok, there is a structure/function associated, &amp;lt;code&amp;gt;attack_analysis&amp;lt;/code&amp;gt;. Gonna try to export it, but may be a mess :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 11:29, 15 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== usage pattern ==&lt;br /&gt;
&lt;br /&gt;
I'm not sure it would be really useful, since a good AI would probably derive the usage of a unit out of its properties - but maybe there could be a way to query the usage pattern of a unit? Like &amp;quot;scout&amp;quot; or &amp;quot;fighter&amp;quot;.. --[[User:Allefant|Allefant]] 22:35, 13 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== minor API cleanup ==&lt;br /&gt;
&lt;br /&gt;
* properties or methods? E.g. why '''wesnoth.unit.type()''' but '''wesnoth.unit.name'''? Same or wesnoth.get_map() or wesnoth.get_gamestatus(), and others.. The rule behind it is not clear. One way could be, make everything that can change inside a turn a method, everything else a property. Or just make everything methods/properties, since it doesn't seem to matter much in the Python-C-API..&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_cost''' - why does it need the wesnoth.gamemap parameter? Since you don't have a lot of choice what to pass there (or do I have it? could i modify the map returned by get_map?), I think the parameter could go. Same for defense_modifier.&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_left''' - it seems that this data is not present in 'unit' interface. It should either be added or removed from ReferencePythonAPI (but could be useful later).&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.attack_unit(attacker,defender,weapon)''' - how can we related the integer weapon with a attack as the one retrieved from unit.attacks() ? Couldn't we use this attack_type as parameter of attack_unit function ?&lt;br /&gt;
&lt;br /&gt;
:You're right, property/method should be coherent. I'll do:&lt;br /&gt;
:*property =&amp;gt; simple type, no argument&lt;br /&gt;
:*method =&amp;gt; complex type or argument&lt;br /&gt;
:For the gamemap, I'm not sure, I merely mapped the function :) But I'll change the API to not use map anymore and use current one.&lt;br /&gt;
:movement_left does indeed exist in unit.&lt;br /&gt;
:Attack weapon is the index of the weapon in the list from attacks( ).&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:27, 2 March 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== Cheating ==&lt;br /&gt;
&lt;br /&gt;
Should the Python AI be allowed to cheat? I'd like if it couldn't,&lt;br /&gt;
since then I could concentrate on the strategy in the AI script I'm&lt;br /&gt;
playing with, and wouldn't need to check for violated rules myself.&lt;br /&gt;
(So far, my AI attacks multiple times with one unit, and also moves&lt;br /&gt;
after capturing villages or attacking..)&lt;br /&gt;
&lt;br /&gt;
OTOH, if the Python AI is meant to later allow scenario scripting,&lt;br /&gt;
it probably will be wanted to just modify things. But I think, that&lt;br /&gt;
could be done with an alternate API. Something like:&lt;br /&gt;
wesnoth.remove_unit(), wesnoth.place_unit().. and the current ones&lt;br /&gt;
still could have anti-cheat checks.&lt;br /&gt;
&lt;br /&gt;
:I don't think AI should be able to cheat. AI is like a player (ok, maybe no fog of war, but still, unit moves should be legal).&lt;br /&gt;
:I'll check how to enforce the same rules than for players.&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:29, 2 March 2006 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7813</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7813"/>
		<updated>2006-03-02T21:27:54Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* minor API cleanup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Having access to the properties 'HP' and 'Poisonned' of a unit. This would allow focussing on already damaged units when attacking and sending low HP units for rest. It could improve dramatically python AI efficiency. [[User:Viorc|Viorc]]&lt;br /&gt;
&lt;br /&gt;
:added ''hitpoints'', ''max_hitpoints'' and ''poisoned'', thanks for the patch :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:22, 2 March 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== chance to kill ==&lt;br /&gt;
&lt;br /&gt;
Can I get a chance_to_kill(wesnoth.location)? And it would tell me the chance to kill the unit at the given location, using terrain modifiers and everything.. I assume, the C++ AI has something like it available. [[User:Allefant|Allefant]] 22:39, 10 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:I'll check what the C++ has, and export it. [[User:Ryo|Ryo]] 09:24, 11 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:Ok, there is a structure/function associated, &amp;lt;code&amp;gt;attack_analysis&amp;lt;/code&amp;gt;. Gonna try to export it, but may be a mess :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 11:29, 15 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== usage pattern ==&lt;br /&gt;
&lt;br /&gt;
I'm not sure it would be really useful, since a good AI would probably derive the usage of a unit out of its properties - but maybe there could be a way to query the usage pattern of a unit? Like &amp;quot;scout&amp;quot; or &amp;quot;fighter&amp;quot;.. --[[User:Allefant|Allefant]] 22:35, 13 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== minor API cleanup ==&lt;br /&gt;
&lt;br /&gt;
* properties or methods? E.g. why '''wesnoth.unit.type()''' but '''wesnoth.unit.name'''? Same or wesnoth.get_map() or wesnoth.get_gamestatus(), and others.. The rule behind it is not clear. One way could be, make everything that can change inside a turn a method, everything else a property. Or just make everything methods/properties, since it doesn't seem to matter much in the Python-C-API..&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_cost''' - why does it need the wesnoth.gamemap parameter? Since you don't have a lot of choice what to pass there (or do I have it? could i modify the map returned by get_map?), I think the parameter could go. Same for defense_modifier.&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_left''' - it seems that this data is not present in 'unit' interface. It should either be added or removed from ReferencePythonAPI (but could be useful later).&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.attack_unit(attacker,defender,weapon)''' - how can we related the integer weapon with a attack as the one retrieved from unit.attacks() ? Couldn't we use this attack_type as parameter of attack_unit function ?&lt;br /&gt;
&lt;br /&gt;
:You're right, property/method should be coherent. I'll do:&lt;br /&gt;
:*property =&amp;gt; simple type, no argument&lt;br /&gt;
:*method =&amp;gt; complex type or argument&lt;br /&gt;
:For the gamemap, I'm not sure, I merely mapped the function :) But I'll change the API to not use map anymore and use current one.&lt;br /&gt;
:movement_left does indeed exist in unit.&lt;br /&gt;
:Attack weapon is the index of the weapon in the list from attacks( ).&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:27, 2 March 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== Cheating ==&lt;br /&gt;
&lt;br /&gt;
Should the Python AI be allowed to cheat? I'd like if it couldn't,&lt;br /&gt;
since then I could concentrate on the strategy in the AI script I'm&lt;br /&gt;
playing with, and wouldn't need to check for violated rules myself.&lt;br /&gt;
(So far, my AI attacks multiple times with one unit, and also moves&lt;br /&gt;
after capturing villages or attacking..)&lt;br /&gt;
&lt;br /&gt;
OTOH, if the Python AI is meant to later allow scenario scripting,&lt;br /&gt;
it probably will be wanted to just modify things. But I think, that&lt;br /&gt;
could be done with an alternate API. Something like:&lt;br /&gt;
wesnoth.remove_unit(), wesnoth.place_unit().. and the current ones&lt;br /&gt;
still could have anti-cheat checks.&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7811</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=7811"/>
		<updated>2006-03-02T21:22:30Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Having access to the properties 'HP' and 'Poisonned' of a unit. This would allow focussing on already damaged units when attacking and sending low HP units for rest. It could improve dramatically python AI efficiency. [[User:Viorc|Viorc]]&lt;br /&gt;
&lt;br /&gt;
:added ''hitpoints'', ''max_hitpoints'' and ''poisoned'', thanks for the patch :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 22:22, 2 March 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== chance to kill ==&lt;br /&gt;
&lt;br /&gt;
Can I get a chance_to_kill(wesnoth.location)? And it would tell me the chance to kill the unit at the given location, using terrain modifiers and everything.. I assume, the C++ AI has something like it available. [[User:Allefant|Allefant]] 22:39, 10 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:I'll check what the C++ has, and export it. [[User:Ryo|Ryo]] 09:24, 11 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:Ok, there is a structure/function associated, &amp;lt;code&amp;gt;attack_analysis&amp;lt;/code&amp;gt;. Gonna try to export it, but may be a mess :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 11:29, 15 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== usage pattern ==&lt;br /&gt;
&lt;br /&gt;
I'm not sure it would be really useful, since a good AI would probably derive the usage of a unit out of its properties - but maybe there could be a way to query the usage pattern of a unit? Like &amp;quot;scout&amp;quot; or &amp;quot;fighter&amp;quot;.. --[[User:Allefant|Allefant]] 22:35, 13 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== minor API cleanup ==&lt;br /&gt;
&lt;br /&gt;
* properties or methods? E.g. why '''wesnoth.unit.type()''' but '''wesnoth.unit.name'''? Same or wesnoth.get_map() or wesnoth.get_gamestatus(), and others.. The rule behind it is not clear. One way could be, make everything that can change inside a turn a method, everything else a property. Or just make everything methods/properties, since it doesn't seem to matter much in the Python-C-API..&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_cost''' - why does it need the wesnoth.gamemap parameter? Since you don't have a lot of choice what to pass there (or do I have it? could i modify the map returned by get_map?), I think the parameter could go. Same for defense_modifier.&lt;br /&gt;
&lt;br /&gt;
* '''unit.movement_left''' - it seems that this data is not present in 'unit' interface. It should either be added or removed from ReferencePythonAPI (but could be useful later).&lt;br /&gt;
&lt;br /&gt;
* '''wesnoth.attack_unit(attacker,defender,weapon)''' - how can we related the integer weapon with a attack as the one retrieved from unit.attacks() ? Couldn't we use this attack_type as parameter of attack_unit function ?&lt;br /&gt;
&lt;br /&gt;
== Cheating ==&lt;br /&gt;
&lt;br /&gt;
Should the Python AI be allowed to cheat? I'd like if it couldn't,&lt;br /&gt;
since then I could concentrate on the strategy in the AI script I'm&lt;br /&gt;
playing with, and wouldn't need to check for violated rules myself.&lt;br /&gt;
(So far, my AI attacks multiple times with one unit, and also moves&lt;br /&gt;
after capturing villages or attacking..)&lt;br /&gt;
&lt;br /&gt;
OTOH, if the Python AI is meant to later allow scenario scripting,&lt;br /&gt;
it probably will be wanted to just modify things. But I think, that&lt;br /&gt;
could be done with an alternate API. Something like:&lt;br /&gt;
wesnoth.remove_unit(), wesnoth.place_unit().. and the current ones&lt;br /&gt;
still could have anti-cheat checks.&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=6023</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=6023"/>
		<updated>2006-01-15T10:29:08Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* chance to kill */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
== chance to kill ==&lt;br /&gt;
&lt;br /&gt;
Can I get a chance_to_kill(wesnoth.location)? And it would tell me the chance to kill the unit at the given location, using terrain modifiers and everything.. I assume, the C++ AI has something like it available. [[User:Allefant|Allefant]] 22:39, 10 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:I'll check what the C++ has, and export it. [[User:Ryo|Ryo]] 09:24, 11 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:Ok, there is a structure/function associated, &amp;lt;code&amp;gt;attack_analysis&amp;lt;/code&amp;gt;. Gonna try to export it, but may be a mess :)&lt;br /&gt;
:[[User:Ryo|Ryo]] 11:29, 15 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== usage pattern ==&lt;br /&gt;
&lt;br /&gt;
I'm not sure it would be really useful, since a good AI would probably derive the usage of a unit out of its properties - but maybe there could be a way to query the usage pattern of a unit? Like &amp;quot;scout&amp;quot; or &amp;quot;fighter&amp;quot;.. --[[User:Allefant|Allefant]] 22:35, 13 January 2006 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5941</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5941"/>
		<updated>2006-01-11T08:24:18Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* chance to kill */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
== chance to kill ==&lt;br /&gt;
&lt;br /&gt;
Can I get a chance_to_kill(wesnoth.location)? And it would tell me the chance to kill the unit at the given location, using terrain modifiers and everything.. I assume, the C++ AI has something like it available. [[User:Allefant|Allefant]] 22:39, 10 January 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
:I'll check what the C++ has, and export it. [[User:Ryo|Ryo]] 09:24, 11 January 2006 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Credits&amp;diff=5501</id>
		<title>Credits</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Credits&amp;diff=5501"/>
		<updated>2005-12-27T21:19:00Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Developers */ add myself&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In July 2003, '''David White''' released the first version of Wesnoth. Since then, many people have joined the project, contributing in very different ways.&lt;br /&gt;
&lt;br /&gt;
== Developers ==&lt;br /&gt;
* Alfredo Beaumont (ziberpunk) - autotools&lt;br /&gt;
* András Salamon ([[User:Ott|ott]]) - general QA and bug fixing, subediting&lt;br /&gt;
* [mailto:dragonking_AT_o2.pl Bartek Waresiak] (Dragonking) - multiplayer developer&lt;br /&gt;
* Benjamin Drieu - scenario designer&lt;br /&gt;
* Benoît Timbert (Noyga) - coder&lt;br /&gt;
* Bram Ridder (Morloth) - editor improvements&lt;br /&gt;
* [[User:bruno|Bruno Wolff III]] - Campaign web interface, [[MainlineScenarios#The_Dark_Hordes|The Dark Hordes]] maintainer, bug fixing, minor coder&lt;br /&gt;
* Cédric Duval - coder, internationalization manager&lt;br /&gt;
* Crossbow/Miyo - administrator, release manager&lt;br /&gt;
* David Philippi (Torangan) - internationalization manager, wescamp&lt;br /&gt;
* [mailto:davidnwhite_AT_verizon.net David White] (Sirp) - founder, lead developer, scenario designer&lt;br /&gt;
* Francisco Muñoz (fmunoz) - artwork manager, original units, scenario designer&lt;br /&gt;
* Guillaume Melquiond (silene) - &lt;br /&gt;
* Hogne Håskjold (frame) - terrain designer&lt;br /&gt;
* [mailto:isaac_AT_sindominio.net Isaac Clerencia] - administrator, release manager&lt;br /&gt;
* [mailto:Crazy-Ivanovic_AT_gmx.net Nils Kneuper] (Ivanovic) - internationalization manager&lt;br /&gt;
* James Spencer (Shade) - scenario designer&lt;br /&gt;
* Jan Zvánovec (jaz) -&lt;br /&gt;
* Jérémy Rosen (Boucman) - coder&lt;br /&gt;
* John B. Messerly - &lt;br /&gt;
* [mailto:forcemaster_AT_gmx.net Jon Daniel] (forcemstr) - &lt;br /&gt;
* [mailto:jorda_AT_ettin.org Jordà Polo] (ettin) -&lt;br /&gt;
* Joseph Simmons (Turin) - scenario designer, graphics&lt;br /&gt;
* Jörg Hinrichs (Yogi Bear/YogiHH) - coder&lt;br /&gt;
* J.R. Blain (Cowboy) -&lt;br /&gt;
* [mailto:mcnabb_AT_gravity.psu.edu J.W.C. McNabb] (Darth Fool) - coder, graphics&lt;br /&gt;
* Justin Zaun (jzaun) - coder, scenario designer&lt;br /&gt;
* [mailto:erl_AT_erl.se Kristoffer Erlandsson] (erl) - help system, editor&lt;br /&gt;
* Maksim Orlovich (SadEagle) -&lt;br /&gt;
* Mark Michelsen (skovbaer) - internationalization manager&lt;br /&gt;
* Nicolas Weeger (ryo) - Python API&lt;br /&gt;
* [mailto:philippe.plantier_AT_naema.org Philippe Plantier] ([[User:Ayin|Ayin]]) - several parts of the code, notably terrain graphics code&lt;br /&gt;
* Richard Kettering (Jetryl) - artwork coordinator, several graphics&lt;br /&gt;
* Richard S. (Noy) - multiplayer developer&lt;br /&gt;
* Scott Klempner - campaign maintainer&lt;br /&gt;
* Soliton - multiplayer developer&lt;br /&gt;
* [mailto:susanna.bjorverud_AT_telia.com Susanna Björverud] (sanna) - internationalization manager&lt;br /&gt;
* [mailto:ydirson_AT_altern.org Yann Dirson] - gettext support, tinygui&lt;br /&gt;
* Zas -&lt;br /&gt;
&lt;br /&gt;
== Artists ==&lt;br /&gt;
* Aleksi - music coordinator&lt;br /&gt;
* Alex Jarocha-Ernst (Jormungandr) - portraits&lt;br /&gt;
* Andrew James Patterson (Kamahawk) - sprites&lt;br /&gt;
* antwerp - sprites&lt;br /&gt;
* Christophe Anjard - sprites&lt;br /&gt;
* Diego Brea (Cobretti) - sprites&lt;br /&gt;
* Eli Dupree (Elvish Pillager) - sprites&lt;br /&gt;
* Fredrik Lindroth - music&lt;br /&gt;
* Gareth Miller (Gafgarion) - sprites&lt;br /&gt;
* James Barton (Sangel) - sprites&lt;br /&gt;
* James Woo (Pickslide) - portraits&lt;br /&gt;
* Jason Lutes - portraits&lt;br /&gt;
* Jimmy Olsson (Azlan) - icons&lt;br /&gt;
* Johanna Manninen (lohari) - tiles&lt;br /&gt;
* John Muccigrosso (Eponymous Archon) - sprites&lt;br /&gt;
* John-Robert Funck (XJaPaN) - sprites&lt;br /&gt;
* Jonatan Alamà (tin) - logo&lt;br /&gt;
* Joseph Toscano (zhaymusic.com) - music&lt;br /&gt;
* J.W. Bjerk (Eleazar) - tiles, graphics&lt;br /&gt;
* Michael Gil de Muro (grp21) - portraits&lt;br /&gt;
* Neorice - sprites&lt;br /&gt;
* Pau Congost - music&lt;br /&gt;
* Pekka Aikio - tiles&lt;br /&gt;
* Peter Geinitz (Shadow) - sprites&lt;br /&gt;
* Robert Bolin (Zebulon) - tiles&lt;br /&gt;
* Slainte - sprites&lt;br /&gt;
* Stephen Stone - [graphics]&lt;br /&gt;
* Svetac - [graphics]&lt;br /&gt;
&lt;br /&gt;
== Translators ==&lt;br /&gt;
* adson - hungarian translation&lt;br /&gt;
* İhsan Akın - turkish translation&lt;br /&gt;
* Alessio D'Ascanio (otaku) - italian translation&lt;br /&gt;
* Alexander Alexiou (Santi) - greek translation&lt;br /&gt;
* Alexander Kjäll (capitol) - swedish translation&lt;br /&gt;
* Alexandr Menovchicov - russian translation&lt;br /&gt;
* Alfredo Beaumont (ziberpunk) - basque translation&lt;br /&gt;
* Ambra Viviani Loos - brazilian portuguese translation&lt;br /&gt;
* Americo Iacovizzi (DarkAmex) - italian translation&lt;br /&gt;
* Anders K. Madsen (madsen) - danish translation&lt;br /&gt;
* András Salamon ([[User:Ott|ott]]) - afrikaans, english and hungarian translation&lt;br /&gt;
* Andre Schmidt (schmidta) - german translation&lt;br /&gt;
* Anežka Bubeníčková (Bubu) - czech translation&lt;br /&gt;
* Ankka - finnish translation&lt;br /&gt;
* Anton Tsigularov (Atilla) - bulgarian translation&lt;br /&gt;
* Arkadiusz Danilecki (szopen) - polish translation&lt;br /&gt;
* Arne Deprez - dutch translation&lt;br /&gt;
* Artur R. Czechowski - polish translation&lt;br /&gt;
* Aurélien Brevers (Breversa) - french translation&lt;br /&gt;
* Azamat Hackimov - russian translation&lt;br /&gt;
* Bartek Waresiak (Dragonking) - polish translation&lt;br /&gt;
* Beer (Eddi) - hungarian translation&lt;br /&gt;
* Benoit Astruc - french translation&lt;br /&gt;
* Bjarke Sørensen (basher) - danish translation&lt;br /&gt;
* Boris Stumm (quijote_) - german translation&lt;br /&gt;
* BOrsuk - polish translation&lt;br /&gt;
* Cédric Duval - french translation&lt;br /&gt;
* Carles Company (brrr) - catalan translation&lt;br /&gt;
* Celso Goya - brazilian portuguese translation&lt;br /&gt;
* Christoph Berg (chrber) - german translation&lt;br /&gt;
* Claus Aranha - brazilian portuguese translation&lt;br /&gt;
* crys0000 - italian translation&lt;br /&gt;
* Dan Rosàs Garcia (focks) - catalan translation&lt;br /&gt;
* Daniel López (Azazelo) - catalan translation&lt;br /&gt;
* DaringTremayne - french translation&lt;br /&gt;
* David Martínez Moreno - spanish translation&lt;br /&gt;
* David Nečas (Yeti) - czech translation&lt;br /&gt;
* dentro - hungarian translation&lt;br /&gt;
* Enes Akın (yekialem) - turkish translation&lt;br /&gt;
* Erik J. Mesoy (Circon) - norwegian translation&lt;br /&gt;
* Eugenio Favalli (ElvenProgrammer) - italian translation&lt;br /&gt;
* Federico Tomassetti - italian translation&lt;br /&gt;
* Flamma - spanish translation&lt;br /&gt;
* Franciso Muñoz (fmunoz) - spanish translation&lt;br /&gt;
* François Orieux - french translation&lt;br /&gt;
* Gabriel Rodríguez (Chewie) - spanish translation&lt;br /&gt;
* Georgi Dimitrov (oblak)- bulgarian translation&lt;br /&gt;
* Gerfried Fuchs (Alfie) - german translation&lt;br /&gt;
* Gilluin - hungarian translation&lt;br /&gt;
* Guillaume Duwelz-Rebert - french translation&lt;br /&gt;
* [mailto:massart.guillaume_AT_wanadoo.fr Guillaume Massart (Piou2fois)] - french translation&lt;br /&gt;
* Guillaume Melquiond (silene) - french translation&lt;br /&gt;
* Hallvard Norheim Bø (Lysander) - norwegian translation&lt;br /&gt;
* Håvard Korsvoll - norwegian translation&lt;br /&gt;
* Huang huan (unicon) - chinese translation&lt;br /&gt;
* Ilya Kaznacheev - russian translation&lt;br /&gt;
* isazi - italian translation&lt;br /&gt;
* Iván Herrero (navitux) - spanish translator&lt;br /&gt;
* Jaka Kranjc (lynx) - slovenian translation&lt;br /&gt;
* Jan Greve (Jan) - german translation&lt;br /&gt;
* Jan-Heiner Laberenz (jan-heiner) - german translation&lt;br /&gt;
* Jean Privat (Tout) - french translation&lt;br /&gt;
* Jean-Luc Richard (Le Gnome) - french translation&lt;br /&gt;
* Jérémy Rosen (Boucman) - french translation&lt;br /&gt;
* Jesper Fuglsang Wolff (ulven) - danish translation&lt;br /&gt;
* Jonatan Alamà (tin) - catalan translation&lt;br /&gt;
* [mailto:jorda_AT_ettin.org Jordà Polo] (ettin) - catalan translation coordinator&lt;br /&gt;
* Jose Gordillo (kilder) - spanish and catalan translation&lt;br /&gt;
* Jose Manuel Gomez (joseg) - spanish translation&lt;br /&gt;
* Julien Moncel - french translation&lt;br /&gt;
* Julien Tailleur - french translation&lt;br /&gt;
* Julen Landa (genars) - basque translation&lt;br /&gt;
* Kai Ensenbach (Pingu) - german translation&lt;br /&gt;
* Kékkői László (BlackEvil) - hungarian translation&lt;br /&gt;
* Karol Nowak (grzywacz) - polish translation&lt;br /&gt;
* Katerina Sykioti - greek translation&lt;br /&gt;
* Kertész Csaba - hungarian translation&lt;br /&gt;
* Khiraly - hungarian translation&lt;br /&gt;
* kko - finnish translation&lt;br /&gt;
* Konstantinos Karasavvas - greek translation&lt;br /&gt;
* Kosif -  turkish translation&lt;br /&gt;
* Kovács Dániel - hungarian translation&lt;br /&gt;
* krix - hungarian translation&lt;br /&gt;
* Lala - dutch translation&lt;br /&gt;
* Leo Danielson (Lugo Moll) - swedish translation&lt;br /&gt;
* Lim Choon Kiat - 林俊杰 - chinese translation&lt;br /&gt;
* Lukáš Faltýnek - czech translation&lt;br /&gt;
* Maarten Albrecht - dutch translation&lt;br /&gt;
* Mark Michelsen (skovbaer) - danish translation&lt;br /&gt;
* Mark Polo (mpolo) - latin translation&lt;br /&gt;
* Mark Recasens - catalan translation&lt;br /&gt;
* Mart Tõnso - estonian translation&lt;br /&gt;
* Martin Šín - czech translation&lt;br /&gt;
* Mathias Bundgaard Svensson (freaken) - danish translation&lt;br /&gt;
* Matias Parmala - finnish translation&lt;br /&gt;
* methinks - polish translation&lt;br /&gt;
* Michał Jedynak (Artanis) - polish translation&lt;br /&gt;
* Michel Loos - brazilian portuguese translation&lt;br /&gt;
* Mikel Olasagasti (Hey_neken) - basque translation&lt;br /&gt;
* Mintaka - czech translation&lt;br /&gt;
* Naoki Iimura - japanese translation&lt;br /&gt;
* Nico Oliver - afrikaans translation&lt;br /&gt;
* Nicolas Boudin (Blurgk) - french translation&lt;br /&gt;
* [mailto:Crazy-Ivanovic_AT_gmx.net Nils Kneuper] (Ivanovic) - german translation&lt;br /&gt;
* Nobuhito Okada - japanese translation&lt;br /&gt;
* [mailto:tapik_AT_buchtovi.cz Oto Buchta] ([[User:Tapik|tapik]]) - czech translation&lt;br /&gt;
* Pau Rul·lan Ferragut - catalan translation&lt;br /&gt;
* Paweł Stradomski - polish translation&lt;br /&gt;
* Paweł Tomak - polish translation&lt;br /&gt;
* paxed - finnish translation&lt;br /&gt;
* Petr Kopač (Ferda) - czech translation&lt;br /&gt;
* Petr Kovár (Juans) - czech translation&lt;br /&gt;
* [mailto:philippe.plantier_AT_naema.org Philippe Plantier] ([[User:Ayin|Ayin]]) - french translation&lt;br /&gt;
* Pieter Vermeylen (Onne) - dutch translation&lt;br /&gt;
* P&amp;amp;#305;nar Yanarda&amp;amp;#287; (moonquelle) - turkish translation&lt;br /&gt;
* Renato Cunha - brazilian portuguese translation&lt;br /&gt;
* Roel Thijs (Roel) - dutch translation&lt;br /&gt;
* RokStar - italian translation&lt;br /&gt;
* Roman Tuchin (Sankt) - russian translation&lt;br /&gt;
* Rudolf Orság - czech translation&lt;br /&gt;
* Ruben Philipp Wickenhäuser (The Very Uhu) - german translation&lt;br /&gt;
* Sérgio de Miranda Costa -  brazilian portuguese translation&lt;br /&gt;
* Selim Farsakoğlu -  turkish translation&lt;br /&gt;
* Sofronius - czech translation&lt;br /&gt;
* Spiros, Giorgis - greek translation&lt;br /&gt;
* Srecko Toroman (FreeCraft) - serbian translation&lt;br /&gt;
* Stefan Bergström (tephlon) - swedish translation&lt;br /&gt;
* Stephan Grochtmann (Schattenstephan) - german translation&lt;br /&gt;
* [mailto:susanna.bjorverud_AT_telia.com Susanna Björverud] (sanna) - swedish translation&lt;br /&gt;
* Susanne Mesoy (Rarlgland) - norwegian translation&lt;br /&gt;
* Széll Tamás (TomJoad) - hungarian translation&lt;br /&gt;
* Tiago Souza (Salvador) - brazilian portuguese translation&lt;br /&gt;
* Tobe Deprez - dutch translation&lt;br /&gt;
* Vít Komárek - czech translation&lt;br /&gt;
* Vít Krčál - czech translation&lt;br /&gt;
* Viliam Bur - slovak translation&lt;br /&gt;
* wint3r - swedish translation&lt;br /&gt;
* [mailto:ydirson_AT_altern.org Yann Dirson] - french translation&lt;br /&gt;
* Yuji Matsumoto - japanese translation&lt;br /&gt;
* Zas - french translation&lt;br /&gt;
&lt;br /&gt;
== Other Contributions ==&lt;br /&gt;
* Ben Anderman (crimson_penguin) - unit list&lt;br /&gt;
* Dacyn - scenario designer&lt;br /&gt;
* Cyril Bouthors (CyrilB) - debian packager, patron&lt;br /&gt;
* Darryl Dixon - packager&lt;br /&gt;
* edge - packager&lt;br /&gt;
* Francesco Gigli (Jaramir) - wiki, wesnoth.slack.it&lt;br /&gt;
* Frédéric Wagner&lt;br /&gt;
* Jay Hopping - packager&lt;br /&gt;
* Jeff Breidenbach (Jab) - Bilinear interpolation&lt;br /&gt;
* Marcin Konicki (ahwayakchih) - BeOS packager&lt;br /&gt;
* Marcus Phillips (Sithrandel) - Mac OS X packager&lt;br /&gt;
* Mark Michelsen (skovbaer) - slackware packager&lt;br /&gt;
* Mike Quinones (Doc Paterson) - multiplayer maps&lt;br /&gt;
* Peter Groen (pg) - multiplayer maps&lt;br /&gt;
* Ruben Philipp Wickenhäuser (The Very Uhu) - multiplayer maps&lt;br /&gt;
* Tom Chance (telex4) - multiplayer maps, scenario balancing&lt;br /&gt;
* Sam Phillips (dark172) - creation of campains and multiplayer maps&lt;br /&gt;
&lt;br /&gt;
{{Home}}&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5249</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5249"/>
		<updated>2005-12-08T19:09:22Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
:Done, experimental though :) [[User:Ryo|Ryo]] 20:09, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5247</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5247"/>
		<updated>2005-12-08T18:53:09Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
:Actually it's gonna be unit.find_path() since it depends on a unit. [[User:Ryo|Ryo]] 19:53, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5246</id>
		<title>Talk:ReferencePythonAPI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Talk:ReferencePythonAPI&amp;diff=5246"/>
		<updated>2005-12-08T18:44:21Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Feature Requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Feature Requests ==&lt;br /&gt;
&lt;br /&gt;
* Path finder, something like: wesnoth.find_path(loc1, loc2), and it would return a list of all locations in between, or just the first step.. whatever the C++ API has&lt;br /&gt;
:Gonna wrap a_star_search (in pathfind.hpp) [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Persistent variables. Right now, the script state isn't reset, so all variables are already persistent. But for the final version, there should be real persistent variables, which can also be stored to WML, and reloaded. An AI would use it to e.g. store a path, or some other state.&lt;br /&gt;
:Probably with the Object -&amp;gt; String Python conversion. Will look at that [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;br /&gt;
&lt;br /&gt;
* Something like wesnoth.get_possible_moves(loc) - it would return all possible moves for the unit at the given location. It seems, right now, I make a lot of mistakes because the info of wesnoth.get_src_dst or wesnoth.get_units gets outdated after I move a unit. (Not really sure about this one, better planning out of the algorithm might make this function un-necessary.)&lt;br /&gt;
:Yes, you need to grab again the array after moving. What happens is that you get a &amp;quot;snapshot&amp;quot; copy, which isn't updated when you move a unit - thus your &amp;quot;obsolete&amp;quot; copy can contain now invalid destinations. I'm not sure of a fix for that apart getting again the array. [[User:Ryo|Ryo]] 19:44, 8 December 2005 (CET)&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WritingYourOwnAI&amp;diff=5033</id>
		<title>WritingYourOwnAI</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WritingYourOwnAI&amp;diff=5033"/>
		<updated>2005-11-28T19:13:30Z</updated>

		<summary type="html">&lt;p&gt;Ryo: + PythonTestScript&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Writing your own AI ==&lt;br /&gt;
&lt;br /&gt;
Wesnoth supports a pluggable AI system that allows programmers to write their own AIs in C++.&lt;br /&gt;
&lt;br /&gt;
To write an AI, you need to derive a class from ''ai_interface''&lt;br /&gt;
(defined in '''ai.hpp'''), and implement the function ''play_turn()'' which will be called every time your AI is expected to play a turn.&lt;br /&gt;
&lt;br /&gt;
Class ''ai_interface'' contains three important functions&lt;br /&gt;
which allow you to execute the three basic types of move available in the game:&lt;br /&gt;
&lt;br /&gt;
* ''attack_enemy()'', which is used to order an attack on an enemy unit,&lt;br /&gt;
* ''move_unit()'', which is used to order a unit to move from one location to another, and&lt;br /&gt;
* ''recruit()'', which is used to recruit a new unit.&lt;br /&gt;
&lt;br /&gt;
Of course, to decide where units are to move and attack, you must have information about the state of the game - the dimensions and layout of the map, the locations and type of units on the map, the types of units your side can recruit, and information about your allies and enemies.&lt;br /&gt;
&lt;br /&gt;
Firstly, a type ''location'' is defined, which defines any location on the map.  It has members ''x'' and ''y''.  In '''pathfind.hpp''' there are a number of functions which will tell you useful things about locations -- whether two locations&lt;br /&gt;
are adjacent, all the locations adjacent to a certain location,&lt;br /&gt;
and the distance between locations.&lt;br /&gt;
&lt;br /&gt;
A type ''move_map'' is defined as a ''std::multimap&amp;lt;location,location&amp;gt;''.  Note that ''std::multimap'' is of course a standard C++ container, and cannot be documented here.  http://www.sgi.com/tech/stl/ is a good reference on standard C++ containers.  The purpose of a ''move_map'' is to show all the possible moves for a side.  It can either be a ''source -&amp;gt; destination'' map, which associates the locations of all the units a side has to all the possible places they can move to, or a ''destination -&amp;gt; source'' map, which associates all the locations all the units a side has can get to, to all the places they are now.&lt;br /&gt;
&lt;br /&gt;
The function ''calculate_possible_moves()'' is provided&lt;br /&gt;
as a useful utility function. It can give you maps for where all&lt;br /&gt;
your units can move, or where all your enemy's movements&lt;br /&gt;
can move when it's their turn. This is a very important&lt;br /&gt;
function to use to work out all the possible places your units can move to.&lt;br /&gt;
&lt;br /&gt;
''ai_interface'' also defines an ''info'' type.  This type contains a number of references to various game objects which you&lt;br /&gt;
will need access to in order to make moves.  The two most important of these objects are the unit map (unit_map units)&lt;br /&gt;
and the game map (gamemap map).&lt;br /&gt;
&lt;br /&gt;
The unit map is of type ''std::map&amp;lt;location,unit&amp;gt;''&lt;br /&gt;
and associates locations with units.  This object can be used to find the location of, and information about, every unit on the board.  See '''unit.hpp''' for a definition of the ''unit'' object.&lt;br /&gt;
&lt;br /&gt;
The game map allows you to inspect the dimensions and layout of the playing board.  Given a location, it can tell you the&lt;br /&gt;
terrain type at that location.  See '''map.hpp''' for a definition of this object.  You can combine this class with use of the functions in '''pathfind.hpp''' to find various&lt;br /&gt;
information about where units can move to.&lt;br /&gt;
&lt;br /&gt;
The team class (defined in '''team.hpp''') is also very important.  Each side is represented by a ''team'' object. The team object can tell you the gold balance of a team, which villages (note that internally, villages are often called 'towers') the team owns, what units the team can recruit,&lt;br /&gt;
and which other teams are this teams friends or enemies.&lt;br /&gt;
&lt;br /&gt;
The utility function ''current_team()'' can be used to get a reference to the team that your AI is in control of, but you&lt;br /&gt;
can also use the vector ''teams'' inside the info object to get a list of all teams.&lt;br /&gt;
&lt;br /&gt;
If you want to make your AI customizable within the configuration file, you can gain access to any parameters passed to your AI using ''team::ai_parameters()''.  This returns an object of type ''config'' (see '''config.hpp''').  These ''config'' objects are representations of WML document fragments.  When the user defines your side, if they put an [ai] tag inside it, everything inside the [ai] tag will be returned by ''team::ai_parameters()''.&lt;br /&gt;
&lt;br /&gt;
== Using your AI ==&lt;br /&gt;
&lt;br /&gt;
Finally, when you have your AI ready to go, you can add it to the ''create_ai()'' function in '''ai.cpp'''.  Suppose you called your class ''killer_ai'', you could add it like so:&lt;br /&gt;
&lt;br /&gt;
 if(name == &amp;quot;killer_ai&amp;quot;)&lt;br /&gt;
     return new killer_ai(info);&lt;br /&gt;
&lt;br /&gt;
Then, you can define a side to use your AI in [[ReferenceWML|WML]]:&lt;br /&gt;
&lt;br /&gt;
 ai_algorithm=killer_ai&lt;br /&gt;
&lt;br /&gt;
and when that side is created, it'll use your AI!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== An example ==&lt;br /&gt;
&lt;br /&gt;
Let us conclude with a small sample AI, called ''sample_ai''.  How should this AI behave?&lt;br /&gt;
&lt;br /&gt;
* First it should detect if there are any enemies in range,&lt;br /&gt;
and if there are it should attack them by moving onto the&lt;br /&gt;
best defensive terrain next to them.  Attacks should be made with the weapon for which damage*strikes*chance to hit is&lt;br /&gt;
the highest.&lt;br /&gt;
* If there are no enemies in range, it should move units onto villages that don't already belong to it.&lt;br /&gt;
* If there are no enemies or villages in range, it should move toward the enemy leader along the shortest possible route.&lt;br /&gt;
* At the end of its turn, it should recruit random units until it runs out of money or doesn't have any space.&lt;br /&gt;
&lt;br /&gt;
In the following example, I will place all functions in-line&lt;br /&gt;
rather than in the cpp file. To do this properly, of course you should put them in the cpp file.  The entire definition of this AI can be found in '''ai.cpp''' and '''ai.hpp''' in the source distribution.&lt;br /&gt;
&lt;br /&gt;
We start the definition,&lt;br /&gt;
&lt;br /&gt;
  class sample_ai : public ai_interface {&lt;br /&gt;
  public:&lt;br /&gt;
      sample_ai(info&amp;amp; i) : ai_interface(i) {}&lt;br /&gt;
&lt;br /&gt;
We have defined the constructor which takes an ''info'' object&lt;br /&gt;
and passes it straight onto ai_interface.  We don't need to&lt;br /&gt;
store anything ourselves in this simple AI.  (Although it would be fine to have data members if we wanted them.)&lt;br /&gt;
&lt;br /&gt;
Next we define the main function, ''play_turn()'':&lt;br /&gt;
&lt;br /&gt;
      void play_turn() {&lt;br /&gt;
          do_attacks();&lt;br /&gt;
          get_villages();&lt;br /&gt;
          do_moves();&lt;br /&gt;
          do_recruitment();&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
Just a series of calls to functions we are about to write which do the actual work.  Firstly, ''do_attacks()''. We start by&lt;br /&gt;
calculating all the moves our units can make:&lt;br /&gt;
&lt;br /&gt;
  private:&lt;br /&gt;
      void do_attacks() {&lt;br /&gt;
          std::map&amp;lt;location,paths&amp;gt; possible_moves;&lt;br /&gt;
          move_map srcdst, dstsrc;&lt;br /&gt;
          calculate_possible_moves(possible_moves,srcdst,dstsrc,false);&lt;br /&gt;
&lt;br /&gt;
Note that the ''possible_moves'' thing is of little direct interest.  It contains details of exactly which tiles the unit&lt;br /&gt;
moves along to get from one tile to another.  This is useful for the display to know about when it draws the unit moving, but as an AI programmer, it's not likely you'll ever care about&lt;br /&gt;
what it contains. Just pass it along to the ''move_unit()'' function so it can draw the unit moving along the correct path.&lt;br /&gt;
&lt;br /&gt;
The things we're interested in are ''srcdst'', and especially ''dstsrc'', which will tell us all the hexes our units can reach.&lt;br /&gt;
We want to check if any of these hexes are next to an enemy unit.  Let's walk over the units and see if we can reach any of them:&lt;br /&gt;
&lt;br /&gt;
          for(unit_map::const_iterator i = get_info().units.begin(); i != get_info().units.end(); ++i) {&lt;br /&gt;
              if(current_team().is_enemy(i-&amp;gt;second.side()) {&lt;br /&gt;
&lt;br /&gt;
We're iterating over all units, but we're only interested in units that are enemies of our side.  So, we access our team object, and ask if the side the unit is on is an enemy.  If it is, then we're interested in seeing if any of our units can move to a hex that's adjacent to the enemy unit.  We do this by getting the six locations around the enemy unit:&lt;br /&gt;
&lt;br /&gt;
                  location adjacent_tiles[6];&lt;br /&gt;
                  get_adjacent_tiles(i-&amp;gt;first,adjacent_tiles);&lt;br /&gt;
&lt;br /&gt;
This kind of call is very common in the game's code -- make an array of 6 locations, and fill them up with the locations adjacent to a certain location.  We actually want to find the position to attack from which gives our unit the best possible defense. So, we initialize some variables to find the best possible defense:&lt;br /&gt;
&lt;br /&gt;
                  int best_defense = -1;&lt;br /&gt;
                  std::pair&amp;lt;location,location&amp;gt; best_movement;&lt;br /&gt;
&lt;br /&gt;
The value of ''best_defense'' will of course be between 1 and 100, but we give it a value of -1 to mean 'not initialized', since we haven't found any possible attacks at all yet.  Variable ''best_movement'' will contain the destination/source pair that gives the best possible defense for our attacking unit.&lt;br /&gt;
&lt;br /&gt;
                  for(size_t n = 0; n != 6; ++n) {&lt;br /&gt;
                      typedef move_map::const_iterator Itor;&lt;br /&gt;
                      std::pair&amp;lt;Itor,Itor&amp;gt; range = dstsrc.equal_range(adjacent_tiles[n]);&lt;br /&gt;
&lt;br /&gt;
If you don't understand how ''equal_range'' works, then look up documentation on how the standard container multimap works.  ''range'' now refers to all the possible movements that can end&lt;br /&gt;
with our unit being at ''adjacent_tiles[n]''.  Let's iterate over all those movements, and find if any of them give a better defensive rating than our current best defense.  We'll start our iteration by creating some aliases that ensure we don't go crazy ;)&lt;br /&gt;
&lt;br /&gt;
                      while(range.first != range.second) {&lt;br /&gt;
                          const location&amp;amp; dst = range.first-&amp;gt;first;&lt;br /&gt;
                          const location&amp;amp; src = range.first-&amp;gt;second;&lt;br /&gt;
&lt;br /&gt;
Now let's find out about the unit that we're planning to send to this destination:&lt;br /&gt;
&lt;br /&gt;
                          const unit_map::const_iterator un = get_info().units.find(src);&lt;br /&gt;
                          assert(un != get_info().units.end());&lt;br /&gt;
&lt;br /&gt;
We can assume that the unit is in that location (hence the assert), because ''calculate_possible_moves()'' said that it's the possible source of a move.  Let's find out the type of terrain we're planning to move to:&lt;br /&gt;
&lt;br /&gt;
                          const gamemap::TERRAIN terrain = get_info().map.get_terrain(dst);&lt;br /&gt;
&lt;br /&gt;
Okay, so we have the unit, and we have the terrain, now we should be able to find out the unit's defensive rating on this terrain.&lt;br /&gt;
The ''unit'' class has a convenient ''defense_modifier()'' function which will tell us the chance of hitting that unit on a certain terrain.&lt;br /&gt;
&lt;br /&gt;
                          const int chance_to_hit = un-&amp;gt;second.defense_modifier(get_info().map,terrain);&lt;br /&gt;
&lt;br /&gt;
So, now we have all that, if it's the best chance to hit we've seen so far, or we haven't seen any other chances to hit at all, then we add it as our best option seen.&lt;br /&gt;
&lt;br /&gt;
                          if(best_defense == -1 || chance_to_hit &amp;lt; best_defense) {&lt;br /&gt;
                              best_defense = chance_to_hit;&lt;br /&gt;
                              best_movement = *range.first;&lt;br /&gt;
                          }&lt;br /&gt;
&lt;br /&gt;
That's it for these two loops. Iterate and close:&lt;br /&gt;
&lt;br /&gt;
                          ++range.first;&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
Now if we found a possible move, best_defense will not be -1,&lt;br /&gt;
and the movement will be stored in ''best_movement''.  So, if ''best_defense'' is -1, we want to move from ''best_movement.second'' to ''best_movement.first''.&lt;br /&gt;
&lt;br /&gt;
                  if(best_defense != -1) {&lt;br /&gt;
                      move_unit(best_movement.second,best_movement.first,possible_moves);&lt;br /&gt;
&lt;br /&gt;
Remember that ''possible_moves'' thing?  That comes in useful here, where we have to give it to the display object so it can know the path to move the unit along.  This is the only time we need to touch it.&lt;br /&gt;
&lt;br /&gt;
Immediately after moving, we want to attack.  First we need to know which weapon to use.  We'll write a ''choose_weapon()''&lt;br /&gt;
function later which will choose our weapon.  It'll have to take the location of the attacker and the location of the defender, and it'll return an int referring to our weapon of choice.  For now we'll just make use of this function:&lt;br /&gt;
&lt;br /&gt;
                      const int weapon = choose_weapon(best_movement.first,i-&amp;gt;first);&lt;br /&gt;
                      attack_enemy(best_movement.first,i-&amp;gt;first,weapon);&lt;br /&gt;
&lt;br /&gt;
This will implement our attack.  What now?  We've attacked once, but we want to attack with as many units as we can attack with, right?  We can't use the same move_maps again, because they'll be invalid now that we've moved and attacked. What we'll do is we'll call ''do_attacks()'' all over again, recursively, and return immediately.  This way all our maps will be recalculated.&lt;br /&gt;
&lt;br /&gt;
                       do_attacks();&lt;br /&gt;
                       return;&lt;br /&gt;
                   }&lt;br /&gt;
               }&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
That's the entire function done.  It'll keep attacking while it finds attacks, and when it finally runs out of attacks to execute, it'll return nicely. Let's write that ''choose_weapon()'' function now:&lt;br /&gt;
&lt;br /&gt;
  int choose_weapon(const location&amp;amp; attacker, const location&amp;amp; defender) {&lt;br /&gt;
      const unit_map::const_iterator att = get_info().units.find(attacker);&lt;br /&gt;
      assert(att != get_info().units.end());&lt;br /&gt;
&lt;br /&gt;
      const std::vector&amp;lt;a ttack_type&amp;gt;&amp;amp; attacks = att-&amp;gt;second.attacks();&lt;br /&gt;
&lt;br /&gt;
unit contains a convenient ''attacks()'' function which returns a vector of all a unit's possible attacks.  We'll store the&lt;br /&gt;
best attack found so far, and iterate over all attacks:&lt;br /&gt;
&lt;br /&gt;
      int best_attack_rating = -1;&lt;br /&gt;
      int best_attack = -1;&lt;br /&gt;
      for(int n = 0; n != attacks.size(); ++n) {&lt;br /&gt;
&lt;br /&gt;
There is a nice function called ''evaluate_battle_stats()'' in '''actions.hpp''' which will give us all sorts of information about a potential battle. We make use of it here:&lt;br /&gt;
&lt;br /&gt;
          const battle_stats stats = evaluate_battle_stats(get_info().map,&lt;br /&gt;
                attacker, defender, n, get_info().units,&lt;br /&gt;
                get_info().state, get_info().gameinfo, 0, false);&lt;br /&gt;
&lt;br /&gt;
A rather complicated function call, but most of the parameters can be pulled straight from ''get_info()''.  The last two parameters are a little confusing.  The first one of these, ''attacker_terrain_override'', is used if we wanted to know what the combat would look like if the attacker was on different terrain to what it is on now.  If this is non-0, the function will assume the attacker is on the type of terrain given.  This is useful if you want to test the possibility of moving to many different hexes without actually moving there.  The last parameter is false, meaning that strings won't be included in the results.  Strings are useful for showing to a player in a dialog,&lt;br /&gt;
but not useful for an AI, and are expensive to calculate, so this should always be false from within AI algorithms.&lt;br /&gt;
&lt;br /&gt;
Let's use our stats to come up with a rating for this attack:&lt;br /&gt;
&lt;br /&gt;
           const int attack_rating = stats.damage_defender_takes*stats.nattacks*stats.chance_to_hit_defender;&lt;br /&gt;
&lt;br /&gt;
Now if this is the best attack, we can use it,&lt;br /&gt;
&lt;br /&gt;
           if(best_attack == -1 || attack_rating &amp;gt; best_attack_rating) {&lt;br /&gt;
               best_attack = n;&lt;br /&gt;
               best_attack_rating = attack_rating;&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
       return best_attack;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Now we're done with that, we can move onto our ''get_villages()'' function.  We start off by calculating possible moves,&lt;br /&gt;
&lt;br /&gt;
  void get_villages() {&lt;br /&gt;
      std::map&amp;lt;location,paths&amp;gt; possible_moves;&lt;br /&gt;
      move_map srcdst, dstsrc;&lt;br /&gt;
      calculate_possible_moves(possible_moves,srcdst,dstsrc,false);&lt;br /&gt;
&lt;br /&gt;
Now it's a simple matter of iterating over possible destinations,&lt;br /&gt;
and seeing if they are villages not controlled by us:&lt;br /&gt;
&lt;br /&gt;
      for(move_map::const_iterator i = dstsrc.begin(); i != dstsrc.end(); ++i) {&lt;br /&gt;
          if(get_info().map.is_village(i-&amp;gt;first) &amp;amp;&amp;amp;&lt;br /&gt;
              current_team().owns_village(i-&amp;gt;first) == false) {&lt;br /&gt;
&lt;br /&gt;
First it checks whether the destination is a village.  The right side of the ''&amp;amp;&amp;amp;'' simply sees if our team owns the village at that location or not. If we don't own the village, we've found the movement we want to make, and we recurse and return.&lt;br /&gt;
&lt;br /&gt;
              move_unit(i-&amp;gt;second,i-&amp;gt;first,possible_moves);&lt;br /&gt;
              get_villages();&lt;br /&gt;
              return;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Just a couple more functions now.  Firstly, ''do_moves()'' is meant to move our units toward the enemy leader. Well, there may be multiple enemies and thus more than one leader, so we'll just go for the first enemy leader we can find.  We start off by trying to find the enemy leader:&lt;br /&gt;
&lt;br /&gt;
  void move_units() {&lt;br /&gt;
      unit_map::const_iterator leader;&lt;br /&gt;
      for(leader = get_info().units.begin(); leader != get_info().units.end(); ++leader) {&lt;br /&gt;
&lt;br /&gt;
A unit is a leader if it can recruit -- so we use the ''can_recruit()'' function to test if it's a leader.&lt;br /&gt;
&lt;br /&gt;
          if(leader-&amp;gt;second.can_recruit() &amp;amp;&amp;amp; current_team().is_enemy(leader-&amp;gt;second.side())) {&lt;br /&gt;
              break;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
We better have found an enemy leader, otherwise we'll just return...&lt;br /&gt;
&lt;br /&gt;
      if(leader == get_info().units.end())&lt;br /&gt;
          return;&lt;br /&gt;
&lt;br /&gt;
Now, let's find all our unit's possible moves:&lt;br /&gt;
&lt;br /&gt;
      std::map&amp;lt;location,paths&amp;gt; possible_moves;&lt;br /&gt;
      move_map srcdst, dstsrc;&lt;br /&gt;
      calculate_possible_moves(possible_moves,srcdst,dstsrc,false);&lt;br /&gt;
&lt;br /&gt;
We want to find the move that'll take us as close as possible to the enemy leader.  Let's make our variables to show us the best move so far,&lt;br /&gt;
&lt;br /&gt;
      int closest_distance = -1;&lt;br /&gt;
      std::pair&amp;lt;location,location&amp;gt; closest_move;&lt;br /&gt;
&lt;br /&gt;
Now iterate and find the destination closest to the enemy leader:&lt;br /&gt;
&lt;br /&gt;
      for(move_map::const_iterator i = dstsrc.begin(); i != dstsrc.end(); ++i) {&lt;br /&gt;
          const int distance = distance_between(i-&amp;gt;first,leader-&amp;gt;first);&lt;br /&gt;
          if(closest_distance == -1 || distance &amp;lt; closest_distance) {&lt;br /&gt;
              closest_distance = distance;&lt;br /&gt;
              closest_move = *i;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
If ''closest_distance'' is not -1, we've found a valid move that'll take one of our units toward the enemy leader.  We can make the move and recurse&lt;br /&gt;
&lt;br /&gt;
      if(closest_distance != -1) {&lt;br /&gt;
          move_unit(closest_move.second,closest_move.first,possible_moves);&lt;br /&gt;
          do_moves();&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Okay, all our movement functions are done!  Now all we've got left is the recruitment function. We start by getting the units that we can recruit.&lt;br /&gt;
&lt;br /&gt;
  void do_recruitment() {&lt;br /&gt;
      const std::set&amp;lt;std::string&amp;gt;&amp;amp; options = current_team().recruits();&lt;br /&gt;
&lt;br /&gt;
We can choose the number of a unit to recruit at random:&lt;br /&gt;
&lt;br /&gt;
      const int choice = (rand()%options.size());&lt;br /&gt;
      std::set&amp;lt;std::string&amp;gt;::const_iterator i = options.begin();&lt;br /&gt;
      std::advance(i,choice);&lt;br /&gt;
      const bool res = recruit(*i);&lt;br /&gt;
&lt;br /&gt;
And if the recruitment succeeds, we will try to recruit another unit,&lt;br /&gt;
&lt;br /&gt;
      if(res) {&lt;br /&gt;
          do_recruitment();&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
That's it! We've made our ''sample_ai''.  All we have to do is add it to ''create_ai'' in '''ai.cpp''' and we're done!&lt;br /&gt;
&lt;br /&gt;
== AI - specific parameters ==&lt;br /&gt;
&lt;br /&gt;
 wesnoth --multiplayer --controller1=ai --controller2=ai --algorithm1=z_ai --algorithm2=sample_ai&lt;br /&gt;
&lt;br /&gt;
Use the ''--nogui'' switch before ''--multiplayer'' to make the game run without displaying a GUI.  The winner will be reported on stdout.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[DeveloperResources]]&lt;br /&gt;
* [[PythonTestScript]]&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=StartingPoints&amp;diff=4391</id>
		<title>StartingPoints</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=StartingPoints&amp;diff=4391"/>
		<updated>2005-11-01T15:23:22Z</updated>

		<summary type="html">&lt;p&gt;Ryo: /* Tweaking the Game (Create) */ add Python API&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
Battle for Wesnoth is a turn-based fantasy strategy game.&lt;br /&gt;
&lt;br /&gt;
Defeat all enemy leaders using a well-chosen cadre of troops,&lt;br /&gt;
taking care to manage your resources of gold and villages.&lt;br /&gt;
All units have their own strengths and weaknesses; to win,&lt;br /&gt;
deploy your forces to their best advantage while&lt;br /&gt;
denying your foes the chance to do the same. As units gain&lt;br /&gt;
experience, they acquire new abilities and become more&lt;br /&gt;
powerful. Play in your own language and test your skill&lt;br /&gt;
against a smart computer opponent, or join Wesnoth's large&lt;br /&gt;
community of on-line players.&lt;br /&gt;
Create your own custom units, scenarios or campaigns,&lt;br /&gt;
and share them with others.&lt;br /&gt;
&lt;br /&gt;
Battle for Wesnoth is released under the&lt;br /&gt;
[http://www.gnu.org/licenses/licenses.html#GPL GPL].&lt;br /&gt;
Prebuilt packages are available for most operating systems,&lt;br /&gt;
including Windows, Mac OS X, and GNU/Linux, or you can build&lt;br /&gt;
your own from source code.&lt;br /&gt;
&lt;br /&gt;
== Getting the Game ==&lt;br /&gt;
==== Downloading ====&lt;br /&gt;
* [[Download]] - get the most recent source-files and many binaries&lt;br /&gt;
** [[WesnothBinaries]] - precompiled for GNU/Linux, BeOS, PDAs, ...&lt;br /&gt;
** [[WesnothBinariesLinux]] - precompiled for many GNU/Linux distributions&lt;br /&gt;
&lt;br /&gt;
==== Compiling ====&lt;br /&gt;
* [[CompilingWesnoth]] - on Unix, Mac, Windows, GNU/Linux, PDAs, ...&lt;br /&gt;
* [[DebuggingWesnoth]] - on GNU/Linux and Unix-like systems&lt;br /&gt;
* [[WesnothOnLinuxPDAs]] - on the Qtopia/OPIE and thepdaXrom/Zaurus C series&lt;br /&gt;
&lt;br /&gt;
== Playing the Game ([[Play]]) ==&lt;br /&gt;
&lt;br /&gt;
==== For New Players ====&lt;br /&gt;
* [[GettingStarted]] - read me first!&lt;br /&gt;
* [[WesnothManual]] - the rules&lt;br /&gt;
* [[MainlineScenarios]] - walkthroughs for the game-supplied campaigns&lt;br /&gt;
&lt;br /&gt;
==== For Not-So-New Players ====&lt;br /&gt;
* [[AdvancedTactics]] - beating the AI and other people&lt;br /&gt;
* [[MultiplayerServers]] - where to play against other people online&lt;br /&gt;
&lt;br /&gt;
==== Reference ====&lt;br /&gt;
* [[HotKeysSystem]] - keyboard shortcuts&lt;br /&gt;
* [[CommandMode]] - commands you can use in-game&lt;br /&gt;
* [[ServerAdministration]] - commands that authenticated users can use to administer the server&lt;br /&gt;
* [http://wesnoth.slack.it/units.cgi Units] - Units stats and advance trees&lt;br /&gt;
** [http://wesnoth.slack.it/units.cgi?page=frames Wesnoth Unit List]&lt;br /&gt;
** ([http://wesnoth.slack.it/units.cgi?page=list without frames])&lt;br /&gt;
** [http://wesnoth.slack.it/units.cgi Experience Tree]&lt;br /&gt;
** [http://wesnoth.slack.it/units.cgi?factions Factions]&lt;br /&gt;
** [http://wesnoth.slack.it/units.cgi?movetypes Movement, defense and resistance tables]&lt;br /&gt;
* [[RaceDescriptions]] - Elves, Humans, Dwarves, Orcs, Drakes, Undead, Others&lt;br /&gt;
* [[GraphicLibrary]] - unit and terrain images posted on the forums&lt;br /&gt;
**[[UnsortedContrib]] - Unsorted Contributions&lt;br /&gt;
**[[GameArt]] - Art for the main game&lt;br /&gt;
* [[WesnothAcronyms|Wesnoth Acronyms (by category)]] - common wesnothian acronyms explained&lt;br /&gt;
* [[WesnothAcronyms(alphabetic)|WesnothAcronyms (alphabetic)]] - common wesnothian acronyms explained&lt;br /&gt;
&lt;br /&gt;
== Tweaking the Game ([[Create]]) ==&lt;br /&gt;
&lt;br /&gt;
* [[UserScenarios]] - user-written scenarios, campaigns and game modifications&lt;br /&gt;
* [[ReferenceWML]] - all about Wesnoth Markup Language&lt;br /&gt;
* [[ReferencePythonAPI]] - upcoming Python interface for AI&lt;br /&gt;
* [[BuildingCampaigns]] - how to make your own campaigns&lt;br /&gt;
* [[BuildingScenarios]] - how to make your own scenarios&lt;br /&gt;
*[[BuildingUnits]] - how to make your own units&lt;br /&gt;
* [[WesnothMapEditor]] - summary of controls&lt;br /&gt;
* [[CastleTutorial]] - how to create tileable castles and other castle-like tilesets&lt;br /&gt;
* [[ExternalUtilities]] - scripts to help create scenarios, campaigns, and graphics&lt;br /&gt;
* [[UnitAnalysis]] - tool to analyze units&lt;br /&gt;
&lt;br /&gt;
== Improving the Game ==&lt;br /&gt;
* [[ReportingBugs]] - use Gna&lt;br /&gt;
==== Developer information ====&lt;br /&gt;
* [[DeveloperResources]] - useful links&lt;br /&gt;
* [http://changelog.wesnoth.org Changelog] - the most recent changes made to the game&lt;br /&gt;
* [[WesnothCVS]] - accessing the source code&lt;br /&gt;
* [[HackingWesnoth]] - guide for programmers&lt;br /&gt;
* [[CodingStandards]] - for programmers&lt;br /&gt;
* [[UnitDescriptionRewriting]] - coordinating the revision&lt;br /&gt;
* [http://wesnoth.slack.it/missing.cgi Missing unit animations and sounds] - what's available and what's missing&lt;br /&gt;
* [[WritingYourOwnAI]] - write a C++ plugin&lt;br /&gt;
* [[ThemeSystem]] - customizing the screen layout for the game and the editor&lt;br /&gt;
* [[ReleasingWesnoth]] - steps to follow to release a new version&lt;br /&gt;
* [[WesnothPackagersGuide]] - guidelines for packaging Wesnoth for different platforms&lt;br /&gt;
* [[WesnothPreferences]]&lt;br /&gt;
&lt;br /&gt;
==== Game translations ====&lt;br /&gt;
* [[GettextForTranslators]] - how to translate Wesnoth under [[GetText]]&lt;br /&gt;
* [[WesnothTranslations]] - 11 complete, 2 almost complete, 7 more than halfway, 10 partial&lt;br /&gt;
* [[WesCamp]] - a project for translating user-made campaigns&lt;br /&gt;
&lt;br /&gt;
==== Ideas ====&lt;br /&gt;
* [[FrequentlyProposedIdeas]] - before you propose an idea, check here!&lt;br /&gt;
* [[NewUnits]] - units that exist only in theory&lt;br /&gt;
* [[NewTerrains]] - tile status&lt;br /&gt;
* To submit a feature request, use http://bugs.wesnoth.org&lt;br /&gt;
&lt;br /&gt;
== About the Game ==&lt;br /&gt;
* [[WesnothPhilosophy]] - Dave on Wesnoth&lt;br /&gt;
* [[WesnothHistory]] - the Ages of Wesnoth&lt;br /&gt;
* [[WesnothGeography]] - description of Wesnoth and surrounding lands&lt;br /&gt;
* [[WesnothReviews]] - third party reviews of Wesnoth&lt;br /&gt;
* [irc://irc.wesnoth.org/wesnoth #wesnoth] - our IRC channel&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
* [[UsefulLinks]]&lt;br /&gt;
* [[WesnothLSM]] - presentation at LSM&lt;br /&gt;
* [http://wesnoth.slack.it/?WesnothPlayerMap Wesnoth player's map] - add yourself to the map!&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Battle_for_Wesnoth Wikipedia entry for Wesnoth]&lt;br /&gt;
* [[WikiMigration]] - we are looking for a replacement&lt;br /&gt;
&lt;br /&gt;
== About this Wiki ==&lt;br /&gt;
* [[Help:Editing|Editing]] - learn how to edit pages&lt;br /&gt;
* [[Sandbox]] - experiment with the wiki&lt;/div&gt;</summary>
		<author><name>Ryo</name></author>
		
	</entry>
</feed>