label="WW_thermophilus_21_04_09"
version="1.6"
completion="running"
campaign_type="multiplayer"
difficulty="NORMAL"
random_seed="31555"
random_calls="0"
next_underlying_unit_id="343"
end_text_duration="0"
[variables]
[/variables]
[replay]
	[command]
		[start]
		[/start]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ecridi has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="xplorer has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="zohAn- has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="18"
			y="5"
		[/recruit]
		[random]
			value="5764"
		[/random]
		[random]
			value="10547"
		[/random]
		[random]
			value="4325"
		[/random]
		[random]
			value="22015"
		[/random]
		[random]
			value="16339"
		[/random]
		[random]
			value="3554"
		[/random]
		[random]
			value="7229"
		[/random]
		[random]
			value="30211"
		[/random]
		[random]
			value="20193"
		[/random]
		[random]
			value="29608"
		[/random]
		[random]
			value="4448"
		[/random]
		[random]
			value="1406"
		[/random]
		[random]
			value="11519"
		[/random]
		[random]
			value="10205"
		[/random]
		[random]
			value="11346"
			[results]
				checksum="xNb9Bryn.D--c-i+05CRoaOL-EyQnvClJF7qE383X-fb-Zy1ji46+2f+9l+5<foc<nn6f23854.p3418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmIaF"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="21562"
		[/random]
		[random]
			value="2105"
		[/random]
		[random]
			value="26690"
		[/random]
		[random]
			value="31685"
		[/random]
		[random]
			value="28501"
		[/random]
		[random]
			value="28559"
		[/random]
		[random]
			value="28307"
		[/random]
		[random]
			value="283"
		[/random]
		[random]
			value="11958"
		[/random]
		[random]
			value="31356"
		[/random]
		[random]
			value="19671"
		[/random]
		[random]
			value="23150"
		[/random]
		[random]
			value="29348"
		[/random]
		[random]
			value="14913"
		[/random]
		[random]
			value="31005"
			[results]
				checksum="xNb9Bryn.D--c-i+05FRoaOL-EyQnvClJF7qE383X-fb-Zy1ji46+2f+9l+5<foc<nn6f23854.p4418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmIaF"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="11518"
		[/random]
		[random]
			value="26608"
		[/random]
		[random]
			value="15604"
		[/random]
		[random]
			value="3210"
		[/random]
		[random]
			value="20820"
		[/random]
		[random]
			value="18945"
		[/random]
		[random]
			value="9678"
		[/random]
		[random]
			value="12320"
		[/random]
		[random]
			value="10859"
		[/random]
		[random]
			value="22644"
		[/random]
		[random]
			value="32141"
		[/random]
		[random]
			value="11987"
		[/random]
		[random]
			value="28357"
		[/random]
		[random]
			value="21329"
		[/random]
		[random]
			value="6514"
			[results]
				checksum="xNb9Bryn.D--c-i+05CRoaOL-EyQnvClJF7qE383X-fb-Zy1ji46+2f+9l+5<foc<nn6f23854.p3418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmIaF"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="dozen has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="24"
			y="5"
		[/recruit]
		[random]
			value="25018"
		[/random]
		[random]
			value="24086"
		[/random]
		[random]
			value="29439"
		[/random]
		[random]
			value="8317"
		[/random]
		[random]
			value="29894"
		[/random]
		[random]
			value="15698"
		[/random]
		[random]
			value="16490"
		[/random]
		[random]
			value="23067"
		[/random]
		[random]
			value="14473"
		[/random]
		[random]
			value="7534"
		[/random]
		[random]
			value="9766"
		[/random]
		[random]
			value="32244"
		[/random]
		[random]
			value="6166"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="fgt has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="23"
			y="5"
		[/recruit]
		[random]
			value="12129"
		[/random]
		[random]
			value="17162"
		[/random]
		[random]
			value="15344"
		[/random]
		[random]
			value="31117"
		[/random]
		[random]
			value="15354"
		[/random]
		[random]
			value="26204"
		[/random]
		[random]
			value="10216"
		[/random]
		[random]
			value="8218"
		[/random]
		[random]
			value="17455"
		[/random]
		[random]
			value="10337"
		[/random]
		[random]
			value="26414"
		[/random]
		[random]
			value="4753"
		[/random]
		[random]
			value="6965"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Azae has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="4"
			x="22"
			y="4"
		[/recruit]
		[random]
			value="23258"
		[/random]
		[random]
			value="2366"
		[/random]
		[random]
			value="18660"
		[/random]
		[random]
			value="18350"
		[/random]
		[random]
			value="30608"
		[/random]
		[random]
			value="29400"
		[/random]
		[random]
			value="28963"
		[/random]
		[random]
			value="13070"
		[/random]
		[random]
			value="20314"
		[/random]
		[random]
			value="19197"
		[/random]
		[random]
			value="17008"
		[/random]
		[random]
			value="18736"
		[/random]
		[random]
			value="10520"
			[results]
				checksum="fEAwEAF+1Gub.aUZJ5kiOGDqZxM8i-LoLYEs-E3jSJv0zT>8cpf6b>5Im2-i0051mfOa-a-d4,d8b>dr3-aeWym.7BZSugG6.eC5RE539gmeoJZ4jM-lYWmgBNCho0u4"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="21,20,19,18,17"
			y="4,4,4,3,3"
		[/move]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="NetworkPlayer has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Lhun has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Warrior has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="4"
			x="24"
			y="19"
		[/recruit]
		[random]
			value="638196645"
		[/random]
		[random]
			value="1649603296"
		[/random]
		[random]
			value="2004519986"
		[/random]
		[random]
			value="1184674330"
		[/random]
		[random]
			value="399727647"
		[/random]
		[random]
			value="604981877"
		[/random]
		[random]
			value="1422551557"
		[/random]
		[random]
			value="444175655"
		[/random]
		[random]
			value="1510878890"
		[/random]
		[random]
			value="1305997085"
		[/random]
		[random]
			value="1512167791"
		[/random]
		[random]
			value="1394883825"
		[/random]
		[random]
			value="2020133094"
		[/random]
		[random]
			value="660004247"
		[/random]
		[random]
			value="197605892"
			[results]
				checksum="4zf1OSw,C7F>rbJjCs8AZ92.m<LzFBEHnuR73QRpoMa2r4.k-cpOaw87,.Y8Z.5ndaB-kwWvSlbAfbufC3iaj7hobd->Zhetk<>2fa5>ai01-b1+6Z+40CN5c8b.>X,4"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="23"
			y="20"
		[/recruit]
		[random]
			value="523467393"
		[/random]
		[random]
			value="760488136"
		[/random]
		[random]
			value="310287628"
		[/random]
		[random]
			value="1161664038"
		[/random]
		[random]
			value="262607784"
		[/random]
		[random]
			value="167323966"
		[/random]
		[random]
			value="198854720"
		[/random]
		[random]
			value="662335431"
		[/random]
		[random]
			value="772305843"
		[/random]
		[random]
			value="1621406277"
		[/random]
		[random]
			value="1106511086"
		[/random]
		[random]
			value="135701085"
		[/random]
		[random]
			value="779919714"
		[/random]
		[random]
			value="471195230"
		[/random]
		[random]
			value="1530584910"
			[results]
				checksum="4zf1OSv,C7F>rbJjGs8AZ92.m<LzFBEHnuR73QRpoMa2r4.k-cpOaw87,.Y8Z.5ndaB-kwWvSlbAfbufC3iaj7hobd->Zhepk<>2fa5>ai01-b1+6Z+40CN5c8b.>X,4"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Zakenis has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="1"
			x="22"
			y="20"
		[/recruit]
		[random]
			value="974660590"
		[/random]
		[random]
			value="803091600"
		[/random]
		[random]
			value="1154268168"
		[/random]
		[random]
			value="1331793760"
		[/random]
		[random]
			value="1446087062"
		[/random]
		[random]
			value="1871888044"
		[/random]
		[random]
			value="1687578459"
		[/random]
		[random]
			value="1624566908"
		[/random]
		[random]
			value="247871789"
		[/random]
		[random]
			value="300582947"
		[/random]
		[random]
			value="1934854536"
		[/random]
		[random]
			value="1409535828"
		[/random]
		[random]
			value="563190731"
		[/random]
		[random]
			value="2102178502"
		[/random]
		[random]
			value="1608390548"
			[results]
				checksum="KzLvyin74-,BpeaEvE02ik,1f-H<ltHpHl.4.Zv+KOuxJJEBpQwGOLzIDBBrtvLGpNIMjJxOsDGJKEAIFmsFKnyPOypu3tJHxVzEnyVqOuyLwrBF>8AJxGsqutBjv5-V"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="zod has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="2"
			x="18"
			y="19"
		[/recruit]
		[random]
			value="1991690398"
		[/random]
		[random]
			value="1104754396"
		[/random]
		[random]
			value="1956955074"
		[/random]
		[random]
			value="79361595"
		[/random]
		[random]
			value="2079414986"
		[/random]
		[random]
			value="612563026"
		[/random]
		[random]
			value="1233629763"
		[/random]
		[random]
			value="1263725099"
		[/random]
		[random]
			value="2058650088"
		[/random]
		[random]
			value="958034159"
		[/random]
		[random]
			value="803819910"
		[/random]
		[random]
			value="1535733348"
		[/random]
		[random]
			value="1205905949"
		[/random]
		[random]
			value="1104402857"
		[/random]
		[random]
			value="1323104237"
			[results]
				checksum="dyxuTOIUoJO8HNrG4rKqKKyCcwwqoNtRxBzMHwQmPyQBpPAuOCIG6zNHsCQFqzuGzwKqqyuyKqqT5RBJTuEm3frBwnBwBICTrpKGHCIsunwtfvIWc-MGO<7LH5>f<208"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="19"
			y="20"
		[/recruit]
		[random]
			value="725927452"
		[/random]
		[random]
			value="1585938534"
		[/random]
		[random]
			value="965820968"
		[/random]
		[random]
			value="1093245857"
		[/random]
		[random]
			value="1225403194"
		[/random]
		[random]
			value="792331168"
		[/random]
		[random]
			value="1066834813"
		[/random]
		[random]
			value="1069609944"
		[/random]
		[random]
			value="1897085564"
		[/random]
		[random]
			value="876306239"
		[/random]
		[random]
			value="1148971540"
		[/random]
		[random]
			value="1829016903"
		[/random]
		[random]
			value="1488869265"
		[/random]
		[random]
			value="235117655"
		[/random]
		[random]
			value="945258354"
			[results]
				checksum="3Cf1OSv,C7F>rbJjRs8AZ92.m<LzFBEHnuR73QRpoMa2r4.k-cpOaw87,.Y8Z.5ndaB-kwWvSlbAfbufC3iaj7hobd->Zheuk<>2fa5>ai01-b1+6Z+40CN5c8b.>X,4"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="20"
			y="20"
		[/recruit]
		[random]
			value="1241705086"
		[/random]
		[random]
			value="648397274"
		[/random]
		[random]
			value="971743515"
		[/random]
		[random]
			value="1099021227"
		[/random]
		[random]
			value="1659575482"
		[/random]
		[random]
			value="1901933219"
		[/random]
		[random]
			value="1819039150"
		[/random]
		[random]
			value="238019286"
		[/random]
		[random]
			value="1340388105"
		[/random]
		[random]
			value="637376471"
		[/random]
		[random]
			value="1331265143"
		[/random]
		[random]
			value="418307652"
		[/random]
		[random]
			value="1429707639"
		[/random]
		[random]
			value="250616308"
		[/random]
		[random]
			value="1487917596"
			[results]
				checksum="3Cf1OSv,C7F>rbJjHs8AZ92.m<KzFBEHnuR73QRpoMa2r4.k-cpOaw87,.Y8Z.5ndaB-kwWvSlbAfbufC3iaj7hobd->Zheok<>2fa5>ai01-b1+6Z+40CN5c8b.>X,4"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="21,22,23,24,25"
			y="21,21,22,21,21"
		[/move]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="d00mz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="franq has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="24,25,26,27,28"
			y="5,6,6,6,6"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="23,24,24,24,25"
			y="5,5,6,7,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17,16,15,14,13,12"
			y="5,5,5,5,5,5,4"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,18,17,16,15,14,13"
			y="5,5,6,6,7,7,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,22,22,22,22,22"
			y="4,5,6,7,8,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="c0pK has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,19,18,17,16,15,14"
			y="4,5,5,6,6,7,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="17,17,17,18"
			y="3,4,5,5"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="keenan has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="15520"
		[/random]
		[random]
			value="12070"
		[/random]
		[random]
			value="22578"
		[/random]
		[random]
			value="11939"
		[/random]
		[random]
			value="31807"
		[/random]
		[random]
			value="3983"
		[/random]
		[random]
			value="21606"
		[/random]
		[random]
			value="28668"
		[/random]
		[random]
			value="27544"
		[/random]
		[random]
			value="10140"
		[/random]
		[random]
			value="22841"
		[/random]
		[random]
			value="31952"
		[/random]
		[random]
			value="27766"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Rommel has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="4"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="18208"
		[/random]
		[random]
			value="28854"
		[/random]
		[random]
			value="9698"
		[/random]
		[random]
			value="11716"
		[/random]
		[random]
			value="10329"
		[/random]
		[random]
			value="10396"
		[/random]
		[random]
			value="9150"
		[/random]
		[random]
			value="6860"
		[/random]
		[random]
			value="10165"
		[/random]
		[random]
			value="26735"
		[/random]
		[random]
			value="30418"
		[/random]
		[random]
			value="1317"
		[/random]
		[random]
			value="27684"
			[results]
				checksum="fEAwEAF+1Gub.aUZJ5kiOGDqZxM8i-LoLYEs-E3jSJv0zT>8cpf6b>5Im2-i0051mfOa-a-d4,d8b>dr3-aeWym.7BZSugG6.eC5RE539gmeoJZ4jM-lYWmgBNCho0u4"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Flooz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="23,24,24,24,25"
			y="20,19,18,17,17"
		[/move]
	[/command]
	[command]
		[move]
			x="24,25,26,27,28,29,30"
			y="19,20,20,21,21,21,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tharicsin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="22,23,24,25,26,27"
			y="20,20,19,19,18,18"
		[/move]
	[/command]
	[command]
		[move]
			x="25,24,23,22,21"
			y="21,20,20,20,21"
		[/move]
	[/command]
	[command]
		[move]
			x="19,18,17,16,15"
			y="20,19,19,19,20"
		[/move]
	[/command]
	[command]
		[move]
			x="20,20,20,20,20,20"
			y="20,19,18,17,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Ashar has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,18,18,18,17,16,16"
			y="19,18,17,16,16,15,14"
		[/move]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="paso1 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="AntonioMB has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="damn"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Muneo has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,29,30,31"
			y="6,6,5,6"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="joueur has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,23,24,25,26,26"
			y="9,9,8,9,9,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="?"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26,27,28,29"
			y="8,8,9,9,10"
		[/move]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="you got ud :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Shelam has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="i hate ud vs drakes if i am the drake :D"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,19,18,18,17,17"
			y="4,5,5,6,7,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="traheja has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="LunaLoony has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Roethteor has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,18,17,16,15"
			y="5,5,6,6,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12,12"
			y="8,8,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,11"
			y="9,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Kaiko has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,12,12,12,12,12"
			y="4,5,6,7,8,9,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="14,13,12,12,12,13"
			y="7,8,8,9,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Zakeni has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="tyger has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,14,13,12,11"
			y="20,19,19,19,19"
		[/move]
	[/command]
	[command]
		[move]
			x="27,28,29,30,31"
			y="18,17,17,16,16"
		[/move]
	[/command]
	[command]
		[move]
			x="30,31,31,32,32,33"
			y="20,20,19,18,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="McBain has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="pie has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Lithonen has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Kalle-Peter123 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="16,17"
			y="14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="i don't like neither ud neither drakes"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,19,18,17,17,16"
			y="15,16,16,16,15,14"
		[/move]
	[/command]
	[command]
		[move]
			x="21,20,19,18"
			y="21,20,20,19"
		[/move]
	[/command]
	[command]
		[move]
			x="25,26,26,27"
			y="17,16,15,15"
		[/move]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,13,13"
			y="10,11,12,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,13"
			y="13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12"
			y="14,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,13,13"
			y="11,12,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="11,11,11,12"
			y="11,12,13,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="15,14,13,12,12"
			y="7,7,8,8,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="17,17,16,15,14,13"
			y="8,7,6,7,7,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="29,30,31"
			y="10,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="LordMaryn has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="31,31,31,30"
			y="6,7,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,27"
			y="10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Clavinius has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,27"
			y="11,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Papuc has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="hbobenicio has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="24"
			y="5"
		[/recruit]
		[random]
			value="6213"
		[/random]
		[random]
			value="6764"
		[/random]
		[random]
			value="29618"
		[/random]
		[random]
			value="31844"
		[/random]
		[random]
			value="18863"
		[/random]
		[random]
			value="31958"
		[/random]
		[random]
			value="24248"
		[/random]
		[random]
			value="8639"
		[/random]
		[random]
			value="20120"
		[/random]
		[random]
			value="5747"
		[/random]
		[random]
			value="803"
		[/random]
		[random]
			value="8704"
		[/random]
		[random]
			value="16781"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="23"
			y="5"
		[/recruit]
		[random]
			value="12539"
		[/random]
		[random]
			value="17735"
		[/random]
		[random]
			value="5096"
		[/random]
		[random]
			value="14887"
		[/random]
		[random]
			value="13050"
		[/random]
		[random]
			value="24574"
		[/random]
		[random]
			value="17385"
		[/random]
		[random]
			value="755"
		[/random]
		[random]
			value="16998"
		[/random]
		[random]
			value="6028"
		[/random]
		[random]
			value="526"
		[/random]
		[random]
			value="22361"
		[/random]
		[random]
			value="24821"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17,16,15,14,13"
			y="5,6,6,7,7,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Devas has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Hilquias has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Wargon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="5"
			x="19"
			y="20"
		[/recruit]
		[random]
			value="1271163064"
		[/random]
		[random]
			value="841310394"
		[/random]
		[random]
			value="1463365117"
		[/random]
		[random]
			value="177044108"
		[/random]
		[random]
			value="776380163"
		[/random]
		[random]
			value="394639974"
		[/random]
		[random]
			value="1368241430"
		[/random]
		[random]
			value="1883744028"
		[/random]
		[random]
			value="1770667304"
		[/random]
		[random]
			value="1546964535"
		[/random]
		[random]
			value="1807111344"
		[/random]
		[random]
			value="395436099"
		[/random]
		[random]
			value="1868678907"
		[/random]
		[random]
			value="1739900497"
		[/random]
		[random]
			value="174623394"
			[results]
				checksum="afk10b5br.kQp.+wk<Ab-239eel1N5llg71o3Xl17<1,5g7Z-k6kZlaGnZ68p4>gn6n3e1iafnb5+9fn4>73a+>+.57mc,6d1edjnNmi-f,a8gbj+B.awWJe+,PQ3hpQ"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="5"
			x="20"
			y="20"
		[/recruit]
		[random]
			value="1584156961"
		[/random]
		[random]
			value="1382202400"
		[/random]
		[random]
			value="1128365656"
		[/random]
		[random]
			value="1305352220"
		[/random]
		[random]
			value="974619249"
		[/random]
		[random]
			value="1302989050"
		[/random]
		[random]
			value="453566090"
		[/random]
		[random]
			value="1792274751"
		[/random]
		[random]
			value="1086535723"
		[/random]
		[random]
			value="1010584478"
		[/random]
		[random]
			value="299035602"
		[/random]
		[random]
			value="1883433344"
		[/random]
		[random]
			value="224226425"
		[/random]
		[random]
			value="1052010913"
		[/random]
		[random]
			value="1650423743"
			[results]
				checksum="gfk10b5br.kQp.+wk<Ab-239eel1N5llg71o3Xl17<1,5g7Z-k6kZlaGnZ68p4>gn6n3e1iafnb5+9et4>73a+>+.57mc,6d1edjnNmi-f,a8gbj+B.awWGe+,PQ3hpR"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="17,16,15,14,13,12"
			y="15,14,15,15,16,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="12"
				y="15"
			[/source]
			[destination]
				x="12"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="1941407862"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1624712667"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="486403604"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="11,11,11,11,11"
			y="19,18,17,16,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="11"
				y="15"
			[/source]
			[destination]
				x="12"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="1487668681"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1124361526"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Rudanar_Firmus has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="16,15,14,13"
			y="14,15,14,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="13"
				y="15"
			[/source]
			[destination]
				x="12"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="971490222"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1686895017"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="18,18,18,17"
			y="19,18,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Sonnenwind has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="17,16,15"
			y="17,16,16"
		[/move]
	[/command]
	[command]
		[move]
			x="33,33,33,33,33"
			y="17,16,15,14,13"
		[/move]
	[/command]
	[command]
		[move]
			x="27,28,29,30,31"
			y="15,14,14,14,15"
		[/move]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,11,10,10"
			y="13,13,13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Craz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="10"
				y="14"
			[/source]
			[destination]
				x="11"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="27685"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="11026"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5974"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="11863"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="20904"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="12"
				y="14"
			[/source]
			[destination]
				x="11"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="11254"
			[results]
				chance="70"
				damage="15"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29557"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6725"
			[results]
				chance="70"
				damage="15"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Wayno has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,14,15,16"
			y="13,13,14,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,12,12"
			y="9,10,11,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12,12,12,12,13"
			y="8,8,9,10,11,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,13,12,12,12,12"
			y="7,8,8,9,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Kyleyman has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="24,24,25,25,26"
			y="5,6,7,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="23,24,24,24,25"
			y="5,5,6,7,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,29"
			y="8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="dethtoll has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,28,29,29,30"
			y="12,11,11,10,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="gouf has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Gruby has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Duke has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="33,33,33,33,32"
			y="13,12,11,10,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="32"
				y="9"
			[/source]
			[destination]
				x="31"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="67999077"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="235389539"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="42107441"
			[results]
				chance="70"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="31,31,31,31,31"
			y="16,15,14,13,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="gouf has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="angel has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="31,31,31,31,31,32"
			y="15,14,13,12,11,10"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="32"
				y="10"
			[/source]
			[destination]
				x="31"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="64990320"
			[results]
				chance="70"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="shelam has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Pesmerga has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,16,16,17,17,18"
			y="16,16,17,18,19,19"
		[/move]
	[/command]
	[command]
		[move]
			x="20,19,18,17,16,15,14,13"
			y="20,20,19,19,18,18,18,18"
		[/move]
	[/command]
	[command]
		[move]
			x="19,18,17,16,15,14,13,12"
			y="20,19,19,18,18,18,18,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tasssadar has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="13,13,12,11,11"
			y="15,16,16,16,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="11"
				y="15"
			[/source]
			[destination]
				x="12"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="1482889299"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1608105834"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="12,11,10"
			y="15,16,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="10"
				y="15"
			[/source]
			[destination]
				x="10"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="2008619794"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1979096622"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="333380594"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="2"
			x="19"
			y="20"
		[/recruit]
		[random]
			value="1285300376"
		[/random]
		[random]
			value="629826475"
		[/random]
		[random]
			value="2000243696"
		[/random]
		[random]
			value="1190767856"
		[/random]
		[random]
			value="212220202"
		[/random]
		[random]
			value="509163242"
		[/random]
		[random]
			value="1406237051"
		[/random]
		[random]
			value="855808841"
		[/random]
		[random]
			value="842543836"
		[/random]
		[random]
			value="827109586"
		[/random]
		[random]
			value="2047884332"
		[/random]
		[random]
			value="168469174"
		[/random]
		[random]
			value="1906295631"
		[/random]
		[random]
			value="235761995"
		[/random]
		[random]
			value="1586260181"
			[results]
				checksum="dyxuTOJUoJO8HNrG4rKqKKyCcwwqoNtRxBzMHwQmPyQBpPAuOCIG6zNHsCQFqzuGzwKqqyuyKqqR5RBJTuEm3frBwnBwBICTrpKGHCIsunwtfyIWc-MGO<7LH5>f,208"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Devas has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="StolleD has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,13,13,13,13"
			y="12,13,14,15,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="erebus has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="10"
				y="14"
			[/source]
			[destination]
				x="10"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="1839"
			[results]
				chance="70"
				damage="19"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="600"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5646"
			[results]
				chance="70"
				damage="19"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="16107"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="27784"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,12,12"
			y="11,12,13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="12"
				y="14"
			[/source]
			[destination]
				x="11"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="7963"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22974"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="27175"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1951"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17337"
			[results]
				chance="60"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="11606"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="BloodPolak has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="16,15,14,13,12"
			y="14,15,15,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="12"
				y="15"
			[/source]
			[destination]
				x="11"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="6942"
			[results]
				chance="70"
				damage="15"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,12,11"
			y="12,13,14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="11"
				y="15"
			[/source]
			[destination]
				x="10"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="9557"
			[results]
				chance="70"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29392"
		[/random]
		[random]
			value="24224"
		[/random]
		[random]
			value="10249"
		[/random]
		[random]
			value="10038"
		[/random]
		[random]
			value="20901"
		[/random]
		[random]
			value="27623"
		[/random]
		[random]
			value="23586"
		[/random]
		[random]
			value="27482"
		[/random]
		[random]
			value="1833"
		[/random]
		[random]
			value="23497"
		[/random]
		[random]
			value="6258"
		[/random]
		[random]
			value="23244"
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="King has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="yoyobuae has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Haldir898 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,30,29,29,30"
			y="9,10,11,12,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="30"
				y="12"
			[/source]
			[destination]
				x="31"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="22917"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="8751"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23211"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ck_ has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,27,27,28"
			y="8,9,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26,27,28"
			y="8,8,9,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="29,30,30,31"
			y="8,8,9,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="31"
				y="10"
			[/source]
			[destination]
				x="32"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="27635"
			[results]
				chance="60"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6837"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="24681"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="28317"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Stenen has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="12,11,10,9,9,9,10"
			y="17,17,16,16,15,14,13"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="10"
				y="13"
			[/source]
			[destination]
				x="10"
				y="14"
			[/destination]
		[/attack]
		[random]
			value="895280621"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Al-Rassan has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Shelam has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="32,31,30"
			y="9,9,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="30"
				y="9"
			[/source]
			[destination]
				x="31"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="871666725"
			[results]
				chance="70"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="knight_ruben has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="31,31,31"
			y="12,11,10"
		[/move]
	[/command]
	[command]
		[move]
			x="32,32,31,31,31,31"
			y="10,9,9,8,7,6"
		[/move]
	[/command]
	[command]
		[move]
			x="13,14,15,16,16,16,16"
			y="18,18,18,17,16,15,14"
		[/move]
	[/command]
	[command]
		[move]
			x="19,18,17,17,16"
			y="20,19,19,18,17"
		[/move]
	[/command]
	[command]
		[move]
			x="16,16,17"
			y="17,18,19"
		[/move]
	[/command]
	[command]
		[recruit]
			value="3"
			x="19"
			y="20"
		[/recruit]
		[random]
			value="1568489950"
		[/random]
		[random]
			value="517303996"
		[/random]
		[random]
			value="2075684580"
		[/random]
		[random]
			value="280553274"
		[/random]
		[random]
			value="1699398000"
		[/random]
		[random]
			value="1211234349"
		[/random]
		[random]
			value="573800"
		[/random]
		[random]
			value="1505936886"
		[/random]
		[random]
			value="1200543671"
		[/random]
		[random]
			value="279481573"
		[/random]
		[random]
			value="2059674666"
		[/random]
		[random]
			value="2039117076"
		[/random]
		[random]
			value="1597204567"
		[/random]
		[random]
			value="62240288"
		[/random]
		[random]
			value="1481161201"
			[results]
				checksum="80N696kdt17Q-aGPQ75eF4RIQSHu+GNvRCnIqFywJTCHmxqx1EwQVOxDmGODNOzCNSPAGPJrfzEDPJCs,8AqDwqDqPxMAuFRQxPzFwD4sc7wUX890qvi7pTKCPwx3xSB"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="BuBu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,17,16,15"
			y="19,20,20,20"
		[/move]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,11,10,9,9"
			y="15,16,15,15,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="9"
				y="14"
			[/source]
			[destination]
				x="10"
				y="13"
			[/destination]
		[/attack]
		[random]
			value="31184"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="19735"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="8365"
			[results]
				chance="70"
				damage="12"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="8687"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12,11,10"
			y="16,15,15,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="10"
				y="14"
			[/source]
			[destination]
				x="10"
				y="13"
			[/destination]
		[/attack]
		[random]
			value="3764"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="8745"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="25018"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1628"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="13350"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,11"
			y="14,13,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="11"
				y="13"
			[/source]
			[destination]
				x="10"
				y="13"
			[/destination]
		[/attack]
		[random]
			value="27820"
			[results]
				chance="40"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="601"
			[results]
				chance="50"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29152"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="31571"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10867"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="10,11,12,12"
			y="15,15,14,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="11,12,13,13"
			y="15,14,14,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Roethteor has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Thecippis has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Azmar has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,30,30,30,31"
			y="12,13,14,15,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="bodak has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,27,26"
			y="9,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,27,26,26"
			y="10,9,9,8,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="scorpion3652 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="31,30,29,28,27,26"
			y="6,5,6,6,7,6"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="26"
				y="6"
			[/source]
			[destination]
				x="26"
				y="7"
			[/destination]
		[/attack]
		[random]
			value="826876378"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1345230050"
			[results]
				chance="70"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="875583187"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="31,30,29,28,27,26"
			y="10,10,10,9,9,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="1"
			[source]
				x="26"
				y="9"
			[/source]
			[destination]
				x="26"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="1069875731"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="2041569252"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="792356936"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1116434043"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1781265397"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="857258240"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="30,29,28,27"
			y="9,10,10,10"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="27"
				y="10"
			[/source]
			[destination]
				x="26"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="1025468735"
			[results]
				chance="70"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="408348395"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="653731497"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="16,15,15,14,13,12,11"
			y="14,14,13,12,12,11,11"
		[/move]
	[/command]
	[command]
		[move]
			x="10,10,10,10,9,9,9,10"
			y="13,12,11,10,10,9,8,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Vandarr has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="19,19,19,18,17,17,16,16,15"
			y="20,19,18,17,17,16,15,14,14"
		[/move]
	[/command]
	[command]
		[move]
			x="17,17,17,17,16,16"
			y="19,18,17,16,15,14"
		[/move]
	[/command]
	[command]
		[move]
			x="15,16,17,18"
			y="20,19,20,19"
		[/move]
	[/command]
	[command]
		[recruit]
			value="2"
			x="19"
			y="20"
		[/recruit]
		[random]
			value="1465082479"
		[/random]
		[random]
			value="1179833535"
		[/random]
		[random]
			value="963327577"
		[/random]
		[random]
			value="261773820"
		[/random]
		[random]
			value="1033579686"
		[/random]
		[random]
			value="1439912102"
		[/random]
		[random]
			value="1305933415"
		[/random]
		[random]
			value="1091213290"
		[/random]
		[random]
			value="842410226"
		[/random]
		[random]
			value="894851045"
		[/random]
		[random]
			value="578858433"
		[/random]
		[random]
			value="1800122517"
		[/random]
		[random]
			value="1611090588"
		[/random]
		[random]
			value="1201557786"
		[/random]
		[random]
			value="2128451515"
			[results]
				checksum="dyxuTOIUoJO8HNrG4rKqKKyCcwwqoNtRxBzMHwQmPyQBpPAuOCIG6zNHsCQFqzuGzwKqqyuyKqpO5RBJTuEm3frBwnBwBICTrpKGHCIsunwtfyIWc-MGO<7LH5>c-208"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="18,19,20"
			y="19,20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="FoxViper has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Spookyspider has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="9,10,11,12,13"
			y="14,14,15,14,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Lodgers has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tharicsin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="kit1980 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="11,12,13,13,12"
			y="13,12,12,11,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="12"
				y="10"
			[/source]
			[destination]
				x="11"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="7983"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="9349"
			[results]
				chance="60"
				damage="1"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="9140"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29850"
			[results]
				chance="60"
				damage="1"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="4426"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12,12"
			y="13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="12"
				y="11"
			[/source]
			[destination]
				x="11"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="21039"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5770"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="27514"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3350"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="7024"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19530"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tesafilmchen has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,11"
			y="13,12,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="11"
				y="12"
			[/source]
			[destination]
				x="11"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="32745"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10154"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="8065"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="26200"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="20059"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17462"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ThunderStrike has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="10,10,11"
			y="14,13,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="13,12"
			y="14,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,25,24,23,22"
			y="7,8,8,9,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="31,31,31,31,31,30"
			y="16,17,18,19,20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="joueur has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="10,10,11,11,12"
			y="7,6,6,5,4"
		[/move]
	[/command]
	[command]
		[move]
			x="26,25,24,23,22"
			y="9,9,8,9,8"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="1"
			[source]
				x="22"
				y="8"
			[/source]
			[destination]
				x="22"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="1491307156"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="2032959970"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1703043886"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1642916938"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="89337952"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="978498817"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="27"
				y="10"
			[/source]
			[destination]
				x="26"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="1032983989"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1111954144"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="2070026235"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="26,25,24,24,23"
			y="6,7,7,8,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="23"
				y="9"
			[/source]
			[destination]
				x="22"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="428400629"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1649340690"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1179663166"
			[results]
				chance="70"
				damage="4"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Blindman has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,21,22,23,24"
			y="20,21,20,20,19"
		[/move]
	[/command]
	[command]
		[recruit]
			value="1"
			x="23"
			y="20"
		[/recruit]
		[random]
			value="1526035978"
		[/random]
		[random]
			value="2136823175"
		[/random]
		[random]
			value="142104660"
		[/random]
		[random]
			value="1507235187"
		[/random]
		[random]
			value="965273902"
		[/random]
		[random]
			value="844718892"
		[/random]
		[random]
			value="1014838732"
		[/random]
		[random]
			value="1443065318"
		[/random]
		[random]
			value="1337383740"
		[/random]
		[random]
			value="426672290"
		[/random]
		[random]
			value="288101189"
		[/random]
		[random]
			value="991355333"
		[/random]
		[random]
			value="1500121607"
		[/random]
		[random]
			value="1803433265"
		[/random]
		[random]
			value="1305200592"
			[results]
				checksum="KFLvyin74-,rpeaEvE02ij,1f-H<ltHpHl.4.Zv+KOuxJJEBpQwGOLzIDBBrtvLGpNIMjJxOsDGJKEAIFmsFKnyPOyvu3tJHxVzEnyVqOuyLwrBF>8AJxGsqutBis5-V"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="19,18,18,17,17,16,16,15"
			y="20,19,18,18,17,16,15,15"
		[/move]
	[/command]
	[command]
		[move]
			x="16,15,14,14,13,12"
			y="14,14,13,12,12,12"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="12"
				y="12"
			[/source]
			[destination]
				x="12"
				y="13"
			[/destination]
		[/attack]
		[random]
			value="2092557512"
			[results]
				chance="50"
				damage="9"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="398480444"
			[results]
				chance="50"
				damage="9"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1919308730"
			[results]
				chance="50"
				damage="9"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="11"
				y="11"
			[/source]
			[destination]
				x="11"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="314419728"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1378144796"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="2011537842"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="98046724"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="184450673"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="334429641"
			[results]
				chance="70"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="15,14,14,14,13"
			y="14,13,12,11,11"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="13"
				y="11"
			[/source]
			[destination]
				x="12"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="667822178"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="443832340"
			[results]
				chance="70"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="81100240"
			[results]
				chance="60"
				damage="9"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Ranger has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Panda_ has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,12,12,12,12"
			y="10,9,8,7,6,5"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Diviciaco has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="12"
				y="5"
			[/source]
			[destination]
				x="12"
				y="4"
			[/destination]
		[/attack]
		[random]
			value="26602"
			[results]
				chance="50"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="brad has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,30,30,30,30,31"
			y="20,19,18,17,16,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tim has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="11,10,10"
			y="13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="10"
				y="11"
			[/source]
			[destination]
				x="11"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="24082"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="32559"
			[results]
				chance="60"
				damage="1"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="31038"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29740"
			[results]
				chance="60"
				damage="1"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23422"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="11"
				y="12"
			[/source]
			[destination]
				x="11"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="6689"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14582"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10238"
			[results]
				chance="40"
				damage="7"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="23,24,25"
			y="20,19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Argos has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="25,26,27,28,29"
			y="19,18,18,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Zakeni has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="0"
			x="23"
			y="20"
		[/recruit]
		[random]
			value="638986314"
		[/random]
		[random]
			value="809137850"
		[/random]
		[random]
			value="1790389147"
		[/random]
		[random]
			value="1735098981"
		[/random]
		[random]
			value="177330094"
		[/random]
		[random]
			value="774889436"
		[/random]
		[random]
			value="1371842018"
		[/random]
		[random]
			value="1112223782"
		[/random]
		[random]
			value="1419867990"
		[/random]
		[random]
			value="2125505547"
		[/random]
		[random]
			value="584391830"
		[/random]
		[random]
			value="2117674567"
		[/random]
		[random]
			value="464512477"
		[/random]
		[random]
			value="1937178330"
		[/random]
		[random]
			value="2114604919"
			[results]
				checksum=">UABwPGKRFs+RPQ0VDMFU5szDKhwNqBscwwqoNtRxBzMHwQmPyPvpPAuOCIG6zNHsCQFqzuGzwKqqyuyKqqV5RBJTuEm3frBwnBwBICTrpKGHCIsunwtfyIWcjMGO<Yo"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="24,25,26,27,28"
			y="19,19,18,18,17"
		[/move]
	[/command]
	[command]
		[move]
			x="15,14,13,12,12,12,11"
			y="15,14,14,13,12,11,11"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="11"
				y="11"
			[/source]
			[destination]
				x="11"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="2001935389"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="502208303"
			[results]
				chance="70"
				damage="2"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="12,12,12,12,12,12,12"
			y="12,11,10,9,8,7,6"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="12"
				y="6"
			[/source]
			[destination]
				x="12"
				y="5"
			[/destination]
		[/attack]
		[random]
			value="448235973"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="822034034"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1720930772"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1880725118"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="396274430"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="13,13,13,13,13,13"
			y="11,10,9,8,7,6"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="13"
				y="6"
			[/source]
			[destination]
				x="12"
				y="5"
			[/destination]
		[/attack]
		[random]
			value="1354678920"
			[results]
				chance="60"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1053479860"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1698685849"
			[results]
				chance="60"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1517732008"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="22,21,20,19,18,17"
			y="8,8,7,7,6,7"
		[/move]
	[/command]
	[command]
		[move]
			x="23,22,21,20,19,18,17"
			y="9,8,8,8,8,7,8"
		[/move]
	[/command]
	[command]
		[move]
			x="27,26,25"
			y="10,9,10"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="25"
				y="10"
			[/source]
			[destination]
				x="26"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="340057296"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="243141169"
			[results]
				chance="70"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="416844885"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,12,13,14"
			y="5,4,4,4"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="31,31,31,30,30"
			y="16,15,14,13,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="gg"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="rematch ?"
			side="1"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="i think if you didnt use your leader to attack, you would have won it"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="10,9,9,10,11"
			y="11,11,10,9,9"
		[/move]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="no today :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="26"
				y="10"
			[/source]
			[destination]
				x="25"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="10729"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="28371"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="12625"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="10905"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="ok"
			side="1"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="tomorro again? :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="ok"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="28,28,29,29,30"
			y="17,18,19,20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="thermophilus"
			message="bb"
			side="1"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="WackererWichtel2"
			message="gg"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="thermophilus has left the game."
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="WackererWichtel2 has been chosen as the new host."
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="WackererWichtel2 takes control of side 1."
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="AI sides transferred to host."
		[/speak]
	[/command]
[/replay]
[snapshot]
[/snapshot]
[replay_start]
	current_tod="0"
#textdomain wesnoth-multiplayer
	description=_ "These caves were once the lair of Chak'kso Ney'yks, a legendary Elder Basilisk. The petrified forms of his victims remain as monuments to his savage power."
	experience_modifier="70"
	hash="McPgEzp.LJt7h.t1Qr.c0wdN6DSMrFSDz4LpPy.MjaHg-SJ4NO6RN7,AJkIOwBZE.K6Gt>F,tbOGluI+4Fgcg7SDu,wQihAGrihF1c3lurN0vQXAvq<LoFHYPrX2RHE1"
	id="multiplayer_Basilisk"
	map_data="border_size=1
usage=map

_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm^Xm       , Mm^Xm       , Mm^Xm       , Gs^Fp       , Mm^Xm       , Gs^Fp       , Hh          , Gs^Fms      , Ww          , Ww          , Ww          , Gs^Fp       , Gs^Fms      , Hh          , Mm^Xm       , Gs^Fp       , Mm^Xm       , Mm^Xm       , Mm          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs^Fp       , Mm          , Gg^Fet      , Mm          , Gs^Fp       , Mm^Xm       , Gs^Fms      , Gg^Ve       , Gg          , Hh          , Mm          , Ww          , Gs^Fp       , Hh          , Gg          , Mm          , Gg^Fet      , Mm^Xm       , Mm          , Mm          , Hh          , Gs^Fp       , Ggf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Hh          , Ggf         , Gg          , Hh          , Gg^Ve       , Hh          , Gs^Fms      , Mm          , Mm          , Ggf         , Gg          , Gg          , Ch          , 1 Kh        , Ch          , Gg          , Hh          , Gg          , Gg          , Gs^Fp       , Gg          , Gg          , Gg          , Gg          , Gs^Fms      , Wwf         , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Xu          , Wwf         , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Kh          , Ch          , Gg          , Wwf         , Gg          , Ch          , Kh          , Gs^Fp       , Mm          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Mm          , Wwf         , Xu          , Xu          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Xu          , Xu          , Wwf         , Wwf         , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Re          , Gg          , Re          , Gg          , Gg          , Gg          , Gg          , Wwf         , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Hh          , Gs^Fp       , Gg^Ve       , Gg          , Ggf         , Mm          , Wwf         , Xu          , Xu          , Xu          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Xu          , Xu          , Xu          , Wwf         , Gg          , Gg          , Gs^Fp       , Hh          , Gs^Fp       , Gg          , Gg          , Re          , Re          , Xu          , Re          , Re^Uf       , Gg          , Re          , Wwf         , Gg          , Gs^Fms      , Gg          , Re          , Re          , Re          , Xu          , Gg          , Gg          , Hh          , Gg          , Gg          , Gs^Fp       , Wwf         , Wwf         , Xu          , Uh          , Xu          , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Xu          , Wwf         , Wwf         , Mm          , Gg          , Gg          , Re^Uf       , Mm          , Gg          , Re          , Re          , Ww          , Xu          , Uh          , Uu^Vud      , Xu          , Re          , Wwf         , Wwf         , Re          , Gg          , Re          , Re          , Wwf         , Xu          , Xu          , Re^Uf       , Re          , Gg          , Gg          , Hh          , Ggf         , Hh          , Wwf         , Xu          , Wwf         , Uu          , Uu^Uf       , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Wwf         , Gs^Fp       , Hh          , Hh          , Gg          , Gg          , Hh          , Gs^Fms      , Gg          , Re          , Ww          , Wo          , Ww          , Wwf         , Wwf         , Uh          , Uu^Uf       , Wwf         , Ww          , Ss^Vhs      , Re          , Xu          , Wwf         , Ur          , Ur          , Re          , Re          , Gs^Fms      , Hh          , Gg^Uf       , Gg          , Gg          , Re          , Re^Uf       , Wwf         , Wwf         , Uu          , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Wwf         , Wwf         , Ggf         , Ggf         , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Re          , Ww          , Ww          , Ww          , Xu          , Uh          , Xu          , Ur          , Ww          , Ww          , Ww          , Xu          , Ww          , Uh          , Uu^Vu       , Re          , Gg          , Gg          , Gg          , Gg^Ve       , Gg          , Gg          , Gg          , Gg          , Re          , Gs^Fp       , Wwf         , Xu          , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Gs^Fms      , Gs^Fp       , Re^Uf       , Re          , Gg          , Gg          , Gg          , Gg          , Gg          , Ss^Vhs      , Gg          , Re          , Wwf         , Uh          , Xu          , Ur          , Xu          , Wwf         , Ww          , Wo          , Uu          , Uh          , Ww          , Xu          , Xu          , Re          , Re          , Gg          , Gg          , Gg          , Gs^Fms      , Hh          , Hh          , Gg          , Gg          , Re          , Re          , Wwf         , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Mm          , Hh          , Re          , Re          , Gg          , Gg          , Hh          , Gs^Fp       , Ss          , Gg          , Hh          , Re          , Wwf         , Xu          , Xu          , Ur          , Wwf         , Wwf         , Ww          , Uu^Uf       , Ww          , Ww          , Wwf         , Uu^Uf       , Xu          , Uh          , Wwf         , Re          , Hh          , Hh          , Mm          , Gs^Fp       , Hh          , Gs^Fp       , Gg          , Re          , Re          , Wwf         , Wwf         , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Wwf         , Re^Uf       , Re          , Gg          , Gg          , Gs^Fp       , Re^Uf       , Gs^Fms      , Mm          , Gs^Fp       , Hh          , Re          , Re          , Uh          , Xu          , Uu^Uf       , Ww          , Ww          , Uu          , Uu^Uf       , Ww          , Wwf         , Xu          , Ur          , Xu          , Xu          , Wwf         , Re          , Re          , Gs^Fp       , Gg          , Ss          , Gg          , Gg          , Gg          , Gg          , Gg          , Re^Uf       , Mm          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Wwf         , Re          , Gg          , Gg          , Gg          , Gg          , Hh          , Gg          , Hh          , Gg          , Gg          , Gg          , Re          , Uu^Vu       , Xu          , Ww          , Uh          , Ww          , Wo          , Ww          , Wwf         , Xu          , Ur          , Xu          , Uh          , Ww          , Re          , Re          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Ggf         , Hh          , Hh          , Gs^Fp       , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Wwf         , Wwf         , Hh          , Hh          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Re          , Re          , Ur          , Uh          , Xu          , Xu          , Ss^Vhs      , Ww          , Wwf         , Ur          , Uh          , Uh          , Wwf         , Ww          , Wo          , Ww          , Re          , Re          , Gg          , Gg          , Gs^Fms      , Gg          , Gg          , Gg          , Gg          , Gs^Fp       , Wwf         , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Xu          , Wwf         , Gs^Fp       , Re          , Gg          , Ggf         , Gg          , Gg          , Gg          , Gg          , Gs^Fp       , Xu          , Ur          , Wwf         , Wwf         , Re          , Re          , Re          , Ww          , Wwf         , Uu^Uf       , Xu          , Wwf         , Uh          , Ww          , Ww          , Ww          , Re          , Ss^Vhs      , Gg          , Hh          , Mm          , Hh          , Re^Uf       , Gg          , Gg          , Wwf         , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Uu^Uf       , Uu          , Wwf         , Wwf         , Wwf         , Re          , Hh          , Mm          , Gs^Fp       , Gg          , Gg          , Uh          , Xu          , Xu          , Re          , Re          , Gg          , Gg          , Gg          , Wwf         , Re          , Re          , Re^Uf       , Uu^Vud      , Xu          , Xu          , Re          , Re          , Gg          , Gg          , Gg          , Gs^Fms      , Ggf         , Gs^Fp       , Gg          , Gg          , Wwf         , Wwf         , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , Xu          , Wwf         , Uh          , Xu          , Xu          , Wwf         , Re          , Re^Uf       , Ggf         , Gg^Uf       , Gs^Fp       , Gg          , Gg          , Re          , Gg          , Re          , Gg          , Gs^Fp       , Gg          , Wwf         , Gg          , Gg          , Gg          , Re          , Re          , Re          , Re          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Wwf         , Wwf         , Xu          , Xu          , Xu          , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Xu          , Xu          , Xu          , Xu          , Wwf         , Re          , Gs^Fms      , Gg          , Gg^Ve       , Ggf         , Gg          , Gg          , Gg          , Ggf         , Gg          , Kh          , Gg          , Gg          , Wwf         , Gg          , Gg          , Kh          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Wwf         , Xu          , Xu          , Xu          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Xu          , Xu          , Wwf         , Wwf         , Re          , Mm          , Hh          , Gg          , Gg          , Gg          , Gg^Ve       , Gg          , Gs^Fms      , Gg          , Ch          , Ch          , Wwf         , Ch          , Ch          , Gg          , Gg          , Gg          , Gg          , Gg^Fet      , Gg          , Gg^Ve       , Gg          , Gg          , Gs^Fp       , Gg          , Wwf         , Xu          , Xu          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Xu          , Wwf         , Re          , Re          , Gs^Fp       , Re          , Gg          , Hh          , Hh          , Gs^Fms      , Gg          , Gg          , Hh          , Mm          , 2 Kh        , Gs^Fp       , Gg          , Gg          , Gg^Ve       , Gs^Fp       , Gg          , Hh          , Hh          , Gs^Fp       , Hh          , Gs^Fms      , Gg          , Wwf         , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Re          , Re          , Re          , Gs^Fp       , Mm          , Mm          , Mm          , Mm          , Gs^Fms      , Gg^Fet      , Hh          , Ww          , Hh          , Hh          , Gs^Fms      , Hh          , Mm          , Hh          , Mm^Xm       , Mm          , Mm          , Hh          , Gs^Fp       , Mm          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm          , Hh          , Hh          , Mm^Xm       , Mm^Xm       , Mm^Xm       , Mm^Xm       , Mm^Xm       , Mm          , Mm^Xm       , Ww          , Ww          , Mm          , Mm^Xm       , Mm^Xm       , Mm^Xm       , Mm^Xm       , Mm          , Mm^Xm       , Mm          , Hh          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm^Xm       , _off^_usr   , Mm          , _off^_usr   , Gs^Fp       , _off^_usr   , Mm^Xm       , _off^_usr   , Ww          , _off^_usr   , Gs^Fp       , _off^_usr   , Hh          , _off^_usr   , Gs^Fp       , _off^_usr   , Mm^Xm       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
"
	mp_countdown="no"
	mp_countdown_action_bonus="13"
	mp_countdown_init_time="270"
	mp_countdown_reservoir_time="330"
	mp_countdown_turn_bonus="60"
	mp_fog="yes"
	mp_shroud="no"
	mp_use_map_settings="yes"
	mp_village_gold="2"
	name=_ "2p - Caves of the Basilisk"
	next_underlying_unit_id="0"
#textdomain wesnoth
	objectives=_ "Victory:
@Defeat enemy leader(s)"
	observer="yes"
	random_seed="31555"
	random_start_time="no"
	scenario="ladder"
	turns="-1"
	version="1.6.1"
	[time]
		green="-20"
		id="dawn"
		image="misc/schedule-dawn.png"
		name=_ "Dawn"
		red="-20"
		sound="ambient/morning.ogg"
	[/time]
	[time]
		id="morning"
		image="misc/schedule-morning.png"
		lawful_bonus="25"
		name=_ "Morning"
	[/time]
	[time]
		id="afternoon"
		image="misc/schedule-afternoon.png"
		lawful_bonus="25"
		name=_ "Afternoon"
	[/time]
	[time]
		blue="-20"
		green="-20"
		id="dusk"
		image="misc/schedule-dusk.png"
		name=_ "Dusk"
		sound="ambient/night.ogg"
	[/time]
	[time]
		blue="-10"
		green="-40"
		id="first_watch"
		image="misc/schedule-firstwatch.png"
		lawful_bonus="-25"
		name=_ "First Watch"
		red="-40"
	[/time]
	[time]
		blue="-10"
		green="-40"
		id="second_watch"
		image="misc/schedule-secondwatch.png"
		lawful_bonus="-25"
		name=_ "Second Watch"
		red="-40"
	[/time]
	[music]
		ms_before="12000"
		name="knolls.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="wanderer.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="battle.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="transience.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_king_is_dead.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="knalgan_theme.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_city_falls.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="nunc_dimittis.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="revelation.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="loyalists.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="breaking_the_chains.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="elvish-theme.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="legends_of_the_north.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="traveling_minstrels.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="underground.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="vengeful.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="frantic.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_dangerous_symphony.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="heroes_rite.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="suspense.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_deep_path.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="siege_of_laurelmor.ogg"
	[/music]
	[event]
		name="prestart"
		[music]
			ms_before="12000"
			name="knolls.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="wanderer.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="battle.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="transience.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="revelation.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="loyalists.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_king_is_dead.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="knalgan_theme.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_city_falls.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="nunc_dimittis.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="breaking_the_chains.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="elvish-theme.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="legends_of_the_north.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="traveling_minstrels.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="underground.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="vengeful.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="frantic.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_dangerous_symphony.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="heroes_rite.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="suspense.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_deep_path.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="siege_of_laurelmor.ogg"
		[/music]
	[/event]
	[era]
		id="era_default"
#textdomain wesnoth-multiplayer
		name=_ "Default"
		[multiplayer_side]
			flag_rgb="magenta"
			id="Random"
			image="units/random-dice.png"
			name=_ "Random"
			random_faction="yes"
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Loyalists"
			image="units/human-loyalists/lieutenant.png"
			leader="Lieutenant,Swordsman,Pikeman,Javelineer,Shock Trooper,Longbowman,White Mage,Red Mage"
			name=_ "Loyalists"
			random_leader="Lieutenant,Swordsman,Pikeman,Javelineer,Longbowman,Red Mage"
			recruit="Cavalryman,Horseman,Spearman,Fencer,Heavy Infantryman,Bowman,Mage,Merman Fighter"
			terrain_liked="Gg, Ww, Wo"
			type="Lieutenant"
			[ai]
				recruitment_pattern="fighter,fighter,fighter,archer,mixed fighter,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Rebels"
			image="units/elves-wood/captain.png"
			leader="Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,White Mage,Red Mage,Elder Wose"
			name=_ "Rebels"
			random_leader="Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,Red Mage"
			recruit="Elvish Fighter,Elvish Archer,Mage,Elvish Shaman,Elvish Scout,Wose,Merman Hunter"
			terrain_liked="Ff, Fa, Ss, Ww"
			type="Elvish Captain"
			[ai]
				recruitment_pattern="fighter,fighter,archer,archer,mixed fighter,healer,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Northerners"
			image="units/orcs/warrior.png"
			leader="Orcish Warrior,Troll,Troll Rocklobber,Orcish Crossbowman,Orcish Slayer"
			name=_ "Northerners"
			recruit="Orcish Grunt,Troll Whelp,Wolf Rider,Orcish Archer,Orcish Assassin,Naga Fighter,Goblin Spearman"
			terrain_liked="Hh, Ha, Mm, Ss"
			type="Orcish Warrior"
			[ai]
				recruitment_pattern="fighter,fighter,fighter,mixed fighter,archer,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Undead"
			image="units/undead-necromancers/dark-sorcerer.png"
			leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter,Necrophage"
			name=_ "Undead"
			random_leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter"
			recruit="Skeleton,Skeleton Archer,Walking Corpse,Ghost,Vampire Bat,Dark Adept,Ghoul"
			terrain_liked="Ss, Hh, Ha, Ww"
			type="Dark Sorcerer"
			[ai]
				recruitment_pattern="fighter,fighter,archer,fighter,scout,archer"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Knalgan Alliance"
			image="units/dwarves/steelclad.png"
			leader="Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Stalwart,Rogue,Trapper"
			name=_ "Knalgan Alliance"
			random_leader="Dwarvish Steelclad,Dwarvish Thunderguard,Rogue,Trapper"
			recruit="Dwarvish Guardsman,Dwarvish Fighter,Dwarvish Ulfserker,Dwarvish Thunderer,Thief,Poacher,Footpad,Gryphon Rider"
			terrain_liked="Hh, Ha, Mm"
			type="Dwarvish Steelclad"
			[ai]
				recruitment_pattern="fighter,fighter,fighter,mixed fighter,archer,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Drakes"
			image="units/drakes/flare.png"
			leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior,Saurian Oracle,Saurian Soothsayer"
			name=_ "Drakes"
			random_leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior"
			recruit="Drake Burner,Drake Clasher,Drake Glider,Drake Fighter,Saurian Skirmisher,Saurian Augur"
			terrain_liked="Hh, Ha, Ds, Ss"
			type="Drake Flare"
			[ai]
				recruitment_pattern="fighter,fighter,archer,healer,scout,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[event]
			name="prestart"
			[store_unit]
				kill="yes"
				variable="leaders_to_make_quick"
				[filter]
					canrecruit="yes"
					[filter_wml]
						max_moves="4"
					[/filter_wml]
				[/filter]
			[/store_unit]
			[set_variable]
				name="i"
				value="0"
			[/set_variable]
			[while]
				[variable]
					less_than="$leaders_to_make_quick.length"
					name="i"
				[/variable]
				[do]
					[set_variables]
						mode="merge"
						name="leaders_to_make_quick[$i].modifications"
						[literal]
							[trait]
#textdomain wesnoth
								female_name=_ "female^quick"
								id="quick"
								male_name=_ "quick"
								[effect]
									apply_to="movement"
									increase="1"
								[/effect]
								[effect]
									apply_to="hitpoints"
									increase_total="-5%"
								[/effect]
							[/trait]
						[/literal]
					[/set_variables]
					[clear_variable]
						name="leaders_to_make_quick[$i].max_moves,leaders_to_make_quick[$i].moves,leaders_to_make_quick[$i].max_hitpoints,leaders_to_make_quick[$i].hitpoints"
					[/clear_variable]
					[unstore_unit]
						variable="leaders_to_make_quick[$i]"
					[/unstore_unit]
					[set_variable]
						add="1"
						name="i"
					[/set_variable]
				[/do]
			[/while]
			[clear_variable]
				name="i"
			[/clear_variable]
			[clear_variable]
				name="leaders_to_make_quick"
			[/clear_variable]
		[/event]
	[/era]
	[side]
		allow_changes="yes"
		allow_player="yes"
		canrecruit="yes"
		colour="1"
		controller="human"
		current_player="thermophilus"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		id="thermophilus1"
		image="units/undead-necromancers/dark-sorcerer.png"
		income="0"
		leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter,Necrophage"
		mp_countdown="no"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="270"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="60"
		name="thermophilus"
		random_leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter"
		recruit="Skeleton,Skeleton Archer,Walking Corpse,Ghost,Vampire Bat,Dark Adept,Ghoul"
		save_id="thermophilus1"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="1"
		team_name="north"
		terrain_liked="Ss, Hh, Ha, Ww"
		type="Bone Shooter"
		user_team_name="wesnoth-multiplayerteamname^North"
		village_gold="2"
		[ai]
			recruitment_pattern="fighter,fighter,archer,fighter,scout,archer"
			villages_per_scout="8"
			[team_formula]
				rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
			[/team_formula]
		[/ai]
		[ai]
			villages_per_scout="8"
		[/ai]
	[/side]
	[side]
		allow_changes="yes"
		allow_player="yes"
		canrecruit="yes"
		colour="2"
		controller="network"
		current_player="WackererWichtel2"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		id="WackererWichtel22"
		image="units/drakes/flare.png"
		income="0"
		leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior,Saurian Oracle,Saurian Soothsayer"
		mp_countdown="no"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="270"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="60"
		name="WackererWichtel2"
		random_leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior"
		recruit="Drake Burner,Drake Clasher,Drake Glider,Drake Fighter,Saurian Skirmisher,Saurian Augur"
		save_id="WackererWichtel22"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="2"
		team_name="south"
		terrain_liked="Hh, Ha, Ds, Ss"
		type="Drake Flare"
		user_team_name="wesnoth-multiplayerteamname^South"
		village_gold="2"
		[ai]
			recruitment_pattern="fighter,fighter,archer,healer,scout,scout"
			villages_per_scout="8"
			[team_formula]
				rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
			[/team_formula]
		[/ai]
		[ai]
			villages_per_scout="8"
		[/ai]
	[/side]
	[side]
		allow_changes="yes"
		allow_player="no"
		canrecruit="no"
		colour="5"
		controller="ai"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		hidden="yes"
		id="ai3"
		image="units/drakes/flare.png"
		income="0"
		leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior,Saurian Oracle,Saurian Soothsayer"
		mp_countdown="no"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="270"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="60"
		name=_ "Computer player"
		no_leader="yes"
		random_leader="Drake Flare,Fire Drake,Drake Slasher,Drake Gladiator,Drake Warrior"
		recruit="Drake Burner,Drake Clasher,Drake Glider,Drake Fighter,Saurian Skirmisher,Saurian Augur"
		save_id="ai3"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="3"
		team_name="statues"
		terrain_liked="Hh, Ha, Ds, Ss"
		type="Drake Warrior"
		user_team_name="statues"
		village_gold="2"
		[unit]
#textdomain wesnoth-multiplayer
			description=_ "The winds of the dark sky blew so cold,
The moon was high, the night was old,
Brave was the drake that dared forsake
His home to steal the Basilisk's gold.

On that dark night, the skies so churned,
He disregarded what he had learned,
Foolish but brave, to the Basilisk's cave,
He flew, and the fire within him burned.

Alas, that fire burns no more,
For the Basilisk, with one mighty roar,
Chilled him to the bone, and he turned to stone,
And so he stays forevermore.

The winds of the sky blow so cold,
The years pass by, the days are old,
Here stands that drake, who dared forsake
His home to steal the Basilisk's gold.
(inscribed by Flametrooper)"
			random_traits="no"
			type="Sky Drake"
			unrenamable="yes"
			x="27"
			y="14"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Xikkrisx of Syrsszk was a powerful Saurian warrior, sent to this region by the Elders of the Rysssrylosszkk Clan (translation: ''The Hunts-Foes-In-Boiling-Rivers Clan''). The Elders were preparing to make war on a human outpost, and were in great need of the powerful magics of Oxsrrsk, a Saurian Mystic who had last been seen heading in the direction of Ruaskkolin Lake. Xikkrisx found the petrified body of Oxsrrsk, along with a carefully bound scroll that had apparently been dropped into a small crevice in the cave floor. He opened the scroll and read a brief passage from the middle of the text: ''After he was bound and cast from the Upper World, Chak'kso's enraged spirit sought release, and was able to exert a corrupting influence on certain regions of the Upper World, channeled through ''pathways of stone'' that extend from the surface into the depths of the Under Reaches. This rage altered the eggs of great lizards, shaping their bodies and spirits into implements of Chak'kso's hatred.'' Confused, Xikkrisx fixed his attention on the task at hand. Thinking that perhaps the Elders could find some way to restore Oxsrrsk, he began the long and strenuous task of hauling the statue back to the domain of the Rysssrylosszkk Clan. Exhausted, and not having traveled far from the lake, Xikkrisx set the statue down inside of a small cave, and lay down to rest. He was awoken by a bone-chilling roar."
			facing="sw"
			name=_ "Xikkrisx"
			random_traits="no"
			type="Saurian Flanker"
			unrenamable="yes"
			x="40"
			y="8"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Oxsrrsk was a powerful Saurian Oracle, who had, in a raid against the rival Xraxss Clan, acquired (from the vaults of the now-dead Oracle Hesx-Rzzak) a most fascinating scroll. The scroll was entitled ''Ney'yks of the Granite Gaze,'' and told of a creature known as the ''Chak'kso Ney'yks,'' a name which, in an ancient saurian tongue, meant ''Eldest Child of Chak'kso.'' Chak'kso was believed to have been a powerful demigod of the Under Reaches, described as a ''great demon of the earth'' in the Elvish Histories. According to these histories, Chak'kso had once sought to transform all life on the planet to stone; so great was his hatred for creatures of flesh. He was ultimately defeated and bound by powerful magics, but in the centuries following his banishment (to a realm far below the surface of the world) a new breed of creature began appearing in the Histories, a breed with the ability to turn any being of flesh into stone. There was a period when these Basilisks (as they came to be known) wreaked havoc on the world of the living, turning thousands to stone. One by one, and at great cost, the Basilisks were defeated. All, it would seem, but one; the Basilisk known as ''The Ney'yks,'' or ''The Eldest Child,'' in the modern tongue. Supremely convinced of his ability to locate and bind this powerful creature into his service, Oxsrrsk set out on his journey..."
			facing="sw"
			name=_ "Oxsrrsk"
			random_traits="no"
			type="Saurian Oracle"
			unrenamable="yes"
			x="39"
			y="8"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Slim of Stature, dexterous Hands
- - Seven Stones and Eleven
Left his Foes so slim a Chance
- - Seven Stones and Eleven
Marksman known as Dragonbane
'mongst the Statues here was slain
- - Seven Stones - and the Elven
(inscribed by Gauteamus)"
			random_traits="no"
			type="Elvish Marksman"
			unrenamable="yes"
			x="2"
			y="11"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Blum Duk was renowned among his goblin clan for having tamed one of the Dire Wolves of the mountains, and he had the courage to match. His leadership and skills alone were what kept the area's goblins alive despite human and elvish menaces. Rumor had it that his wolf had slain fifty men and a hundred Elves.
Thus, when he heard of the awful monster that was inhabiting the area, it was only natural that he ride out alone to face it. All the other goblins expected him to slay the creature easily and drag back its carcass to feast on.
He was in for quite a shock. As soon as he saw the Basilisk, Blum Duk cowered in fright. He tried to wheel his wolf around to run away, but it wouldn't move. As the creature stalked towards him, he screamed his last words: Good Gog, dog, are yer legs made of stone?!?
(inscribed by Elvish Pillager)"
			name=_ "Blum Duk"
			random_traits="no"
			type="Direwolf Rider"
			unrenamable="yes"
			x="10"
			y="17"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Rah Ihn Mar, Champion of the Burning Hills, made his way to the Ruaskkolin Lake region in pursuit of the Elvish Hero Terowydlithrol, known among Elves as ''The Dragonbane.'' It was said that Terowydlithrol had killed a Dragon of Fire that threatened an Elvish village, and initiated a ''counterattack'' in which some 37 Drakes, camping in a nearby ravine and believed to be in allegiance with the Dragon, were slaughtered. Knowing that these Drakes were innocent, Rah Ihn Mar came to Ruaskkolin Lake to hunt down and slay Terowydlithrol, who had been seen entering the region but a day ago. Burning for vengeance, Rah Ihn Mar began the hunt....."
			name=_ "Rah Ihn Mar"
			random_traits="no"
			type="Armageddon Drake"
			unrenamable="yes"
			x="11"
			y="14"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "He had lived there for ages upon ages, in the depths of the water, preying upon the various fish and frogs and merfolk that entered his domain. It was his lake, no other's, and though it was not large, he was its master. Then, the Basilisk came, and looked into the Serpent's eyes. And the Serpent had not died, but it was no longer alive. Thus the new lord of the lake had arrived.
(inscribed by Turin)"
			facing="sw"
			random_traits="no"
			type="Sea Serpent"
			unrenamable="yes"
			x="22"
			y="12"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "A brave hero of Wesnoth's Golden Age, this great rider and commander of men came to this evil place while on a raid against the orcs. Caught unaware by the foul creatures, many of his fellows were killed, but he fought valiantly, slaying many a foe. But alas! The foul Basilisk turned him to stone even as he slew the last orc. Now all that is left is a stark reminder of his once great bearing and strength.
(inscribed by Fynmiir)"
			facing="sw"
			random_traits="no"
			type="Grand Knight"
			unrenamable="yes"
			x="25"
			y="14"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Bramwythl the Wose was always considered a slow, taciturn fellow, even by other Woses. More than any other Wose, he enjoyed simply standing alone in the sun, arms upraised, admiring the beauty of the empty sky. Once, even, he confided in a fellow that his greatest wish was to be able to bask forever in the sun's glory.
However, not long after, the local wose community heard of the approach of a horrible monster, powerful enough to easily destroy the few woses that lived in the area. They quickly moved off (quickly for Woses, anyway), but Bramwythl was left behind - in their haste, no one had remembered to find him and tell him of the danger.
He was taken quite unawares by the Basilisk, and turned to stone before he even recognized the beast. His petrified form still stands there today, warmed by the sun's rays, under an open sky. His greatest wish has been granted.
(inscribed by Elvish Pillager)"
			name=_ "Bramwythl"
			random_traits="no"
			type="Elder Wose"
			unrenamable="yes"
			x="32"
			y="6"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "General Talael Ryndoc came to this place to fight a duel with the Grand Marshal Aethec Corryn, but the two men never found one another. "
			facing="sw"
			name=_ "Talael Ryndoc"
			random_traits="no"
			type="Iron Mauler"
			unrenamable="yes"
			x="34"
			y="11"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "The last words spoken by Grand Marshal Aethec Corryn: ''Talael Ryndoc! I am through searching for you! I shall make my way back to Haldric's Hall, and inform the court that you were too much of a coward to attend our duel! Your disgrace shall be more agonizing than the death I'd have given you!''

Perhaps he should not have shouted quite so loudly.... "
			facing="sw"
			name=_ "Aethec Corryn"
			random_traits="no"
			type="Grand Marshal"
			unrenamable="yes"
			x="15"
			y="11"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "This brave warrior, known as Rilhon among the Naga, heard tell of a fabulous treasure that had been lost in these watery caves- a spear whose head was said to have been fashioned from the tooth of Chak'kso Ney'yks, an Elder Basilisk slain long ago by the Elvish hero, Eloralduil. According to the legend, the weapon rested somewhere on the bottom of this very lake (Ruaskkolin Lake, named for a well-known Sea Serpent who made it his home). Having prepared himself for battle with the Serpent, Rilhon met with two rather large surprises. The first was the petrified form of Ruaskkolin the Serpent. The second was the very-much-alive Chak'kso Ney'yks, who was, oddly enough, in possession of all of his teeth.
(inscribed by Paterson)"
			name=_ "Rilhon"
			random_traits="no"
			type="Naga Myrmidon"
			unrenamable="yes"
			x="20"
			y="12"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "Through waves and rocky channels
blue and white
she pulled and pushed the tides
and taught the fishes how to speak to planets
silver green
with magic
running from her spirit into skins of kelp and shells of snails
a twisting of her tail and hands
she sent her songs to run on pin-tipped legs about the sands
and now
and now the strangest pause
for years and years
she hasn't moved her eyes

(inscribed by MJQ)"
			facing="sw"
			random_traits="no"
			type="Mermaid Siren"
			unrenamable="yes"
			x="17"
			y="11"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					id="remove_hp"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[ai]
			recruitment_pattern="fighter,fighter,archer,healer,scout,scout"
			[team_formula]
				rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

def sumarize_values( input_map )
	sum(
		values(input_map)
	);

def lowest_value( input_map )
	choose( input_map, -value ).value;

def highest_value( input_map )
	choose( input_map, value ).value;

def change_numbers_to_percents( input_map )
	map( input_map, 
		(value*100) / highest_value(input_map) 
	);

def add_number_to_values( input_map, number )
	map( input_map, 
		value + number 
	);

#make sure we have only positive values in a map #

def make_positive_only( input_map )
	if( lowest_value( input_map ) < 0, 
		add_number_to_values( 
			input_map, 
			abs(lowest_value(input_map))
		), 
		input_map 
	);

def sumarize_maps_values( map_A, map_B )
	map( map_A + map_B, 
		value + map_A[key]
	);

		#===== Evaluation how good unit is on a map ===== #

# ==1==  evaluate average defense #
#gives map where key is id of terrain, and value is number of hexes of that terrain on a gamemap#

def locations_map(ai*) 
	tomap( 
		map( 
			map.terrain, 
			id 
		) 
	);

#filters terrain map, min_percent it minimal % of map that terrain has to occupy to be considered in later evaluations# 

def filtered_locations_map(ai*, min_percent)
	filter( 
		locations_map(ai) , 
		value >  (map.w * map.h) / ( 100 / min_percent ) 
	);

#returns average defense of the unit #

def unit_average_defense(ai*, unit, terrain_min_percent )
	sum( 
		values( 
			map(
				filtered_locations_map(ai,terrain_min_percent), 
				defense_on( 
					unit, 
					find(map.terrain,id=key).loc
				) *
				value
			) 
		) 
	) / 
	sum(
		values(
			filtered_locations_map(
				ai,
				terrain_min_percent
			)
		)
	);

#returns map of units from units_list and their average defense (more -> better) #

def map_units_average_defense(ai*, units_list, terrain_min_percent) 
	tomap(
		map( 
			units_list, 
			id 
		), 
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	);

def units_average_defense(ai*, units_list, terrain_min_percent)
	sum(
		map( 
			units_list, 'unit', 
			unit_average_defense(
				ai, 
				unit, 
				terrain_min_percent 
			) 
		) 
	) /
	size(
		units_list
	);


# ==2== TODO: evaluate unit effectivness based on movement points and movement cost#


		#===== Evaluation of game state - how good is ai doing ===== #

# ==1== based on unit cost and current amount of gold #
# returns number between 0 and 100 where: 0 we are losing, 100 we are winning #

def units_cost_gold_eval(ai*)
	min(
		[
			(
				(
					sum(
						map(
							allies, 'team', 
							sum(
								map(
									units_of_side[team], 
									cost
								)
							) + 
							teams[team].gold 
						)
					) * 
					100
				) / 
				sum(
					map(
						enemies, 'team', 
						sum(
							map(
								units_of_side[team], 
								cost
							)
						) + 
						max(
							[teams[team].gold, 0]
						) 
					)
				)
			) / 2,
			100
		]
	);

# ==2== based on village possession #

def count_allied_villages(ai*)
	sum(
		map(
			allies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

def count_enemy_villages(ai*)
	sum(
		map(
			enemies, 'side', 
			size(
				villages_of_side[side]
			)
		)
	);

# multipled by 1000 to increase precision #

def village_evaluation(ai*)
	(
		50000 + 
		(
			count_allied_villages(ai) - 
			count_enemy_villages(ai)
		) * 
		(
			50000 /
			size(
				villages
			)
		)
	) /
	1000;

# ==3== combined 2 of the above #

def eval(ai*)
	( 
		units_cost_gold_eval(ai) + 
		village_evaluation(ai)
	) / 
	2;

		#===== Evaluation how effective my units are against the enemy ===== #

#==1==  basic evaluation #

# evaluate how much damage unit can inflict - how much damage unit can get#

def evaluate_attacker_against_opponents(ai*, unit, enemy_units)
	sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( unit, enemy_unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				) 
			)
		)
	);

def evaluate_defender_against_opponents(ai*, unit, enemy_units)
	-sum( 
		map( 
			enemy_units, 'enemy_unit', 
			sum(
				map(
					[
						max_possible_damage_with_retaliation( enemy_unit, unit )
					],
					max(
						[
							self[0] - self[2],
							self[1] - self[3]
						]
					)
				)
			)
		)
	);

def units_hp_map(ai*, units)
	tomap( 
		map(
			units, 
			id
		), 
		map( 
			units, 
			hitpoints
		)
	);

#in case side's gold is more than 50, add units that side can recruit to the side's unit list#

def create_side_unit_list(ai*, side)
	if( 
		teams[side].gold > 50, 
		recruits_of_side[side], 
		[]
	) + 
	units_of_side[side];

def evaluate_my_recruits_as_attackers(ai*)
	tomap( 
		map(
			my_recruits, 
			id
		), 
		map(
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_attacker_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai, 
							enemy_side
						)
					)
				)
			)
		)
	);

def evaluate_my_recruits_as_defenders(ai*)
	tomap(
		map(
			my_recruits, 
			id
		),
		map( 
			my_recruits, 'my_unit',
			sum(
				map(
					enemies, 'enemy_side',
					evaluate_defender_against_opponents(
						ai,
						my_unit,
						create_side_unit_list(
							ai,
							enemy_side
						)
					)
				)
			)
		)
	);


# === 2 ===  now consider abilities and weapon specials  #

def abilities_weights()
	['skirmisher' -> 15, 'ambush' -> 10, 'nightstalk' -> 20, 'regenerates' -> 20, 'healing' -> 15, 'curing' -> 10, 'leadership' -> 20, 'illumination' -> 15, 'teleport' -> 10, 'steadfast' -> 15 ];

def weapon_specials_weights()
	[ 'backstab' -> 20 ,'slow' -> 10 ,'berserk' -> 20 ,'stones' -> 60 ,'plague' -> 10 ,'marksman' -> 30 ,'magical' -> 40 ,'charge' -> 30 ,'drains' -> 30,  'firststrike' -> 10, 'poison' -> 25 ];

def apply_abilities_weights( units_map )
	map( 
		units_map, 
		value +
		(
			value * 
			max(
				map(
					get_unit_type( key ).abilities, 'ability',
					abilities_weights()[ability]
				)
			)
		) / 100
	);

def apply_weapon_specials_weights( units_map )
	map(
		units_map, 
		value +
		(
			value *
			max(
				map(
					get_unit_type( key ).attacks, 'attack',
					vars.weapon_specials[attack.special]
				)
			)
		) / 100
	);

# since undead units don't get random traits and are balanced with that, we need to lower their evaluation a bit to match fairly the living units #

def undead_malus( units_map )
	map( 
		units_map, 
		if(
			get_unit_type(key).undead,
			( value * 90 ) / 100,
			value 
		)
	);

# === 3 ===  pit 1 and 2 together  #

def evaluate_attackers(ai*)
	change_numbers_to_percents(
		apply_abilities_weights(
			apply_weapon_specials_weights(
				undead_malus( 
					make_positive_only(
						evaluate_my_recruits_as_attackers( ai )	
					)
				)
			)
		)
	);

def evaluate_defenders(ai*)
	map(
		map(
			change_numbers_to_percents(
				apply_abilities_weights(
					apply_weapon_specials_weights(
						undead_malus( 
							make_positive_only(
								evaluate_my_recruits_as_defenders( ai )	
							)
						)
					)
				)
			),
			value / 3
		), 
		value +
		map(
			change_numbers_to_percents(
				units_hp_map(
					ai,
					my_recruits
				)
			),
		value * 2 / 3
		)[key]
	);

	#=========== we have evaluation of game state and units, time to combine them: ==========#
		#=========	recruitment_list_builder	=========#

def rlb_apply_eval(eval, attackers_map, defenders_map, offset)
	map(
		sumarize_maps_values(
			map(
				attackers_map, 
				value * (eval+offset)
			),
			map(
				defenders_map,
				value * ( (100 - eval) - offset )
			)
		),
		value / 100
	);

def rlb_remove_lowest( input_map, percent)
	filter(
		input_map, 
		value > 
		(
			(
				percent * sumarize_values(input_map)
			) / 100
		)
	);

def rlb_first_step(eval, attackers_map, defenders_map, offset)
	rlb_remove_lowest(
		rlb_apply_eval(
			eval,
			attackers_map,
			defenders_map,
			offset
		),
		10
	);

def recruitment_list_builder(eval, attackers_map, defenders_map)
	map(
		rlb_first_step(
			eval,
			attackers_map,
			defenders_map,
			40
		),
		(
			(
				value * 100
			) / 
			sumarize_values(
				rlb_first_step(
					eval,
					attackers_map,
					defenders_map,
					40
				)
			)
		)
	);

		# ========== choose the unit to recruit now ========= #

def unit_chooser(ai*,unit_map) 
	choose(
		keys(unit_map), 'unit_type',
		unit_map[unit_type] - 
		(
			(
				100 * 
				size(
					filter(
						my_units, 
						type = unit_type
					)
				)
			) / 
			size(my_units)
		)
	);

def unit_map_cost_filter(ai*, unit_map)
	filter( unit_map,
		get_unit_type(key).cost < my_side.gold
	);

		# ==========	Main formula section 	========== #

def initialize_weapon_specials_map(ai*)
	if(vars.weapon_specials_init != turn,
		[
			set_var('weapon_specials_init', turn),
			set_var('weapon_specials',
				map(
					weapon_specials_weights(),
					if( key = 'magical',
						units_average_defense(ai, enemy_units, 10),
						if( key = 'marksman',
							units_average_defense(ai, enemy_units, 10) - 10,
							value
						)
					)
				)
			)
		],
		[]
	);

def create_recruits_map(ai*)
	if(vars.recruits_map_creator != turn,
		[
			set_var('recruits_map_creator', turn ),
			set_var('recruits_map',
				debug_print('final unit evaluation: ', recruitment_list_builder(
					debug_print('current AI evaluation (0-100): ', eval(ai)),
					debug_print('attackers evaluation: ',evaluate_attackers(ai)),
					debug_print('defenders evaluation: ',evaluate_defenders(ai))
				))
			)
		],
		[]
	);

def castle_space(ai*)
	filter( map( castle_locs( my_leader.loc ), 'location', if( unit_at( location ), 1, 0 ) ), self = 0  ).size;

if(vars.turn_initialized = turn,
		if( my_leader.loc = nearest_keep( my_leader.loc ),
			if( 
				get_unit_type(
					choose(
						vars.recruits_map,
						-get_unit_type(key).cost
					).key
				).cost <
				my_side.gold,
				if( castle_space(self),
					recruit(debug_print(
						unit_chooser(
							self,
							unit_map_cost_filter(
								self,
								vars.recruits_map
							)
						)
					)),
					fallback()
				),
				fallback() 
			),
			if( my_leader.movement_left > 0,
				move( my_leader.loc, nearest_keep( my_leader.loc ) ),
				fallback()
			)
		),
	[set_var(debug_print('turn_initialized'), turn)] +
	initialize_weapon_specials_map(self) +
	create_recruits_map(self)
)

faiend
"
			[/team_formula]
		[/ai]
	[/side]
[/replay_start]
[statistics]
	mid_scenario="yes"
	[scenario]
		scenario="2p - Caves of the Basilisk"
		[team]
			[recruits]
				Drake Burner="1"
				Drake Clasher="2"
				Drake Fighter="3"
				Drake Glider="1"
				Saurian Augur="4"
				Saurian Skirmisher="2"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
				Drake Fighter="1"
				Saurian Augur="2"
				Saurian Skirmisher="2"
			[/deaths]
			[killed]
				Dark Adept="3"
				Walking Corpse="5"
			[/killed]
			[attacks]
				[sequence]
					s0001="1"
					s1100="1"
					_num="40"
				[/sequence]
				[sequence]
					s111="1"
					_num="50"
				[/sequence]
				[sequence]
					s001="2"
					s01="3"
					s010="1"
					s1="1"
					s11="2"
					_num="60"
				[/sequence]
				[sequence]
					s01="1"
					s010="2"
					s011="2"
					s1="2"
					s100="1"
					s101="1"
					s1101="1"
					_num="70"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="1"
					_num="0"
				[/sequence]
				[sequence]
					s01="1"
					s11="1"
					_num="40"
				[/sequence]
				[sequence]
					s10="2"
					_num="50"
				[/sequence]
				[sequence]
					s="2"
					s0111="1"
					s11="3"
					s110="1"
					_num="60"
				[/sequence]
				[sequence]
					s="1"
					s0="1"
					s011="1"
					s1="1"
					s111="1"
					s1111="1"
					_num="70"
				[/sequence]
			[/defends]
			recruit_cost="220"
			recall_cost="0"
			damage_inflicted="263"
			damage_taken="232"
			expected_damage_inflicted="234610"
			expected_damage_taken="208931"
			turn_damage_inflicted="0"
			turn_damage_taken="0"
			turn_expected_damage_inflicted="0"
			turn_expected_damage_taken="0"
			save_id="WackererWichtel22"
		[/team]
		[team]
			[recruits]
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
			[/deaths]
			[killed]
			[/killed]
			[attacks]
			[/attacks]
			[defends]
			[/defends]
			recruit_cost="0"
			recall_cost="0"
			damage_inflicted="0"
			damage_taken="0"
			expected_damage_inflicted="0"
			expected_damage_taken="0"
			turn_damage_inflicted="0"
			turn_damage_taken="0"
			turn_expected_damage_inflicted="0"
			turn_expected_damage_taken="0"
			save_id="ai3"
		[/team]
		[team]
			[recruits]
				Dark Adept="3"
				Skeleton Archer="2"
				Walking Corpse="5"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
				Dark Adept="3"
				Walking Corpse="5"
			[/deaths]
			[killed]
				Drake Fighter="1"
				Saurian Augur="2"
				Saurian Skirmisher="2"
			[/killed]
			[attacks]
				[sequence]
					s00="1"
					s001="1"
					s01="1"
					s010="1"
					s011="1"
					s100="1"
					s11="2"
					_num="40"
				[/sequence]
				[sequence]
					s1="1"
					_num="50"
				[/sequence]
				[sequence]
					s001="1"
					s10="1"
					s111="1"
					_num="60"
				[/sequence]
				[sequence]
					s00="1"
					s01="1"
					s1="2"
					s11="2"
					_num="70"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="16"
					_num="0"
				[/sequence]
				[sequence]
					s01="1"
					_num="40"
				[/sequence]
				[sequence]
					s01="1"
					s1="1"
					s11="3"
					_num="70"
				[/sequence]
			[/defends]
			recruit_cost="116"
			recall_cost="0"
			damage_inflicted="232"
			damage_taken="263"
			expected_damage_inflicted="208931"
			expected_damage_taken="234610"
			turn_damage_inflicted="14"
			turn_damage_taken="4"
			turn_expected_damage_inflicted="5600"
			turn_expected_damage_taken="3200"
			save_id="thermophilus1"
		[/team]
	[/scenario]
[/statistics]
