label="12042009 Orange_Dude vs Eliot game2"
version="1.6.1"
completion="victory"
campaign_type="multiplayer"
difficulty="NORMAL"
random_seed="28986"
random_calls="0"
next_underlying_unit_id="28"
end_text_duration="0"
[variables]
[/variables]
[replay]
	[command]
		[start]
		[/start]
	[/command]
	[command]
		[recruit]
			value="2"
			x="20"
			y="3"
		[/recruit]
		[random]
			value="9879"
		[/random]
		[random]
			value="15603"
		[/random]
		[random]
			value="9061"
		[/random]
		[random]
			value="10287"
		[/random]
		[random]
			value="4960"
		[/random]
		[random]
			value="16204"
		[/random]
		[random]
			value="9344"
		[/random]
		[random]
			value="26030"
		[/random]
		[random]
			value="3254"
		[/random]
		[random]
			value="24859"
		[/random]
		[random]
			value="11231"
		[/random]
		[random]
			value="18021"
		[/random]
		[random]
			value="20047"
		[/random]
		[random]
			value="6221"
		[/random]
		[random]
			value="7313"
			[results]
				checksum="5OmKwDKUXxq,TxsyxcPSqynxyiENEnLUmPIBJLzMORyvQtLtMsz3uNvNwJSpuLuGnUrzCuxIPMnkISuGzPSPQusvFwzsUDAquYfrOmRzwFyqJ9DMfDvHFKdeVs241d4."
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="2"
			x="17"
			y="5"
		[/recruit]
		[random]
			value="1174"
		[/random]
		[random]
			value="21885"
		[/random]
		[random]
			value="9746"
		[/random]
		[random]
			value="4012"
		[/random]
		[random]
			value="4416"
		[/random]
		[random]
			value="8200"
		[/random]
		[random]
			value="3349"
		[/random]
		[random]
			value="15861"
		[/random]
		[random]
			value="14002"
		[/random]
		[random]
			value="4112"
		[/random]
		[random]
			value="18465"
		[/random]
		[random]
			value="26270"
		[/random]
		[random]
			value="15755"
		[/random]
		[random]
			value="20040"
		[/random]
		[random]
			value="5490"
			[results]
				checksum="9CIQwCrz6RyeTTICy,HrVEsv8xKMwFuxzJDqOwQmKzmtMTEzPv,zPSmuOMoJAyLuJqKyRzLtHrjsLNtqqmLt5eGFJBAwBICTrpKGHCIsunwtfEIWcjGAO<cOO98<,0k3"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="1"
			x="18"
			y="3"
		[/recruit]
		[random]
			value="29787"
		[/random]
		[random]
			value="13802"
		[/random]
		[random]
			value="13946"
		[/random]
		[random]
			value="1732"
		[/random]
		[random]
			value="31463"
		[/random]
		[random]
			value="7848"
		[/random]
		[random]
			value="25943"
		[/random]
		[random]
			value="9251"
		[/random]
		[random]
			value="29990"
		[/random]
		[random]
			value="18460"
		[/random]
		[random]
			value="29358"
		[/random]
		[random]
			value="26699"
		[/random]
		[random]
			value="18536"
		[/random]
		[random]
			value="16994"
		[/random]
		[random]
			value="11764"
			[results]
				checksum="ACIByNSVYmLXPemyRXKFwqFrLmVQqEv0TwtBGgNMvJHtOMFtHrtKmNzMnuxEPDq6BPSLFIOJqR+ProSyETFwFyA9zumVnpCouMKPBb5oJGPbmz3o>.fjcflW4pf7m5p7"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="0"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="9257"
		[/random]
		[random]
			value="7298"
		[/random]
		[random]
			value="13070"
		[/random]
		[random]
			value="18642"
		[/random]
		[random]
			value="12992"
		[/random]
		[random]
			value="3319"
		[/random]
		[random]
			value="10562"
		[/random]
		[random]
			value="15041"
		[/random]
		[random]
			value="23956"
		[/random]
		[random]
			value="4056"
		[/random]
		[random]
			value="1729"
		[/random]
		[random]
			value="7961"
		[/random]
		[random]
			value="11332"
		[/random]
		[random]
			value="23004"
		[/random]
		[random]
			value="2744"
			[results]
				checksum="DB3s-,zQn1M2yLIrtl,yvEJs+TqLAH7qSCNCNSvmIJ>KNGxwmIQwSVVvQLyBGFwuCzBR9PMVRCroPzMEKTmSKvvPnFtw+QnBRSqBwbD3xFMMEJCCHO+YDPPnPywBn8FA"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="10472"
		[/random]
		[random]
			value="23193"
		[/random]
		[random]
			value="8872"
		[/random]
		[random]
			value="20428"
		[/random]
		[random]
			value="8795"
		[/random]
		[random]
			value="7916"
		[/random]
		[random]
			value="1514"
		[/random]
		[random]
			value="20110"
		[/random]
		[random]
			value="188"
		[/random]
		[random]
			value="30483"
		[/random]
		[random]
			value="6620"
		[/random]
		[random]
			value="23237"
		[/random]
		[random]
			value="11311"
		[/random]
		[random]
			value="2990"
		[/random]
		[random]
			value="363"
			[results]
				checksum="irp,4nc1oNO1LLyKmJLIEhoF>vyBA6mszOAMDTywuzyODCrTtRLwFwmIsr1QENmxPFHFw.RFKFnqypNKoM8mwoFomIhFlq1.CLW<<ddBfkHDONNHvMSO1I9LGCHpACmL"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="19,20,21,22"
			y="4,3,3,2"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Domestos has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="llhAnny has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="LULU has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="19"
			y="21"
		[/recruit]
		[random]
			value="23273"
		[/random]
		[random]
			value="24526"
		[/random]
		[random]
			value="14519"
		[/random]
		[random]
			value="30369"
		[/random]
		[random]
			value="9379"
		[/random]
		[random]
			value="24136"
		[/random]
		[random]
			value="13709"
		[/random]
		[random]
			value="30104"
		[/random]
		[random]
			value="11414"
		[/random]
		[random]
			value="2089"
		[/random]
		[random]
			value="503"
		[/random]
		[random]
			value="1129"
		[/random]
		[random]
			value="11567"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="bluey has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="4"
			x="20"
			y="21"
		[/recruit]
		[random]
			value="26279"
		[/random]
		[random]
			value="13740"
		[/random]
		[random]
			value="11275"
		[/random]
		[random]
			value="7449"
		[/random]
		[random]
			value="4641"
		[/random]
		[random]
			value="19550"
		[/random]
		[random]
			value="15320"
		[/random]
		[random]
			value="5190"
		[/random]
		[random]
			value="21019"
		[/random]
		[random]
			value="20529"
		[/random]
		[random]
			value="18529"
		[/random]
		[random]
			value="31976"
		[/random]
		[random]
			value="27321"
			[results]
				checksum="fEAwEAF+1Gub.aUZJ5kiOGDqZxM8i-LoLYEs-E3jSJv0zT>8cpf6b>5Im2-i0051mfOa-a-d4,d8b>dr3-aeWym.7BZSugG6.eC5RE539gmeoJZ4jM-lYWmgBNCho0u4"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="3"
			x="18"
			y="21"
		[/recruit]
		[random]
			value="3491"
		[/random]
		[random]
			value="9307"
		[/random]
		[random]
			value="26316"
		[/random]
		[random]
			value="860"
		[/random]
		[random]
			value="23285"
		[/random]
		[random]
			value="376"
		[/random]
		[random]
			value="9848"
		[/random]
		[random]
			value="19601"
		[/random]
		[random]
			value="16108"
		[/random]
		[random]
			value="3606"
		[/random]
		[random]
			value="29017"
		[/random]
		[random]
			value="19194"
		[/random]
		[random]
			value="4808"
			[results]
				checksum="wIq0h4Aje6ZNhfnNl+7b,Ha4jCJxd>Z4D>emIBh6hCW2BmtJ8j1v.9xmODNURxriEsBIuurvENcQBQBPqyPrRxP5tBQME,Ezpfu49w6JQVkN94JBwVAIsdMAIZHHpExA"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="5"
			x="18"
			y="20"
		[/recruit]
		[random]
			value="13074"
		[/random]
		[random]
			value="11605"
		[/random]
		[random]
			value="10051"
		[/random]
		[random]
			value="23045"
		[/random]
		[random]
			value="4110"
		[/random]
		[random]
			value="13112"
		[/random]
		[random]
			value="10586"
		[/random]
		[random]
			value="22978"
		[/random]
		[random]
			value="15120"
		[/random]
		[random]
			value="32451"
		[/random]
		[random]
			value="32576"
		[/random]
		[random]
			value="21431"
		[/random]
		[random]
			value="27261"
		[/random]
		[random]
			value="26589"
		[/random]
		[random]
			value="28693"
			[results]
				checksum="wmNOCQ,<jCB,xNaeN9c8kBjp>f.33i3,bi2g6odf4d42johapi+j5>4.,j0+4d89dk>9,2l6B.fc-I>-,WJ2j2m>8oQ0birbp4<4OkUyc1nTJvFiKQ-515ck2+Ih5Kjg"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="6"
			x="20"
			y="20"
		[/recruit]
		[random]
			value="15294"
		[/random]
		[random]
			value="14256"
		[/random]
		[random]
			value="6903"
		[/random]
		[random]
			value="18172"
		[/random]
		[random]
			value="28626"
		[/random]
		[random]
			value="9041"
		[/random]
		[random]
			value="8389"
		[/random]
		[random]
			value="15045"
		[/random]
		[random]
			value="26395"
		[/random]
		[random]
			value="7876"
		[/random]
		[random]
			value="32442"
		[/random]
		[random]
			value="21304"
		[/random]
		[random]
			value="7442"
			[results]
				checksum="RqMsBKzD0FKjsFwUULNJZmGIxrMqRUrwAqFDQBsGIPzPLBOztLbGuuQUIGIP7KIRwurIsmHBB+FVoqJyy6J8xkkBsfg-8bR7eEHFHBVJRlsCL4wQFtHLK,fBFKhGav7k"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="2"
			x="21"
			y="20"
		[/recruit]
		[random]
			value="15298"
		[/random]
		[random]
			value="15391"
		[/random]
		[random]
			value="10624"
		[/random]
		[random]
			value="19492"
		[/random]
		[random]
			value="16718"
		[/random]
		[random]
			value="12862"
		[/random]
		[random]
			value="30486"
		[/random]
		[random]
			value="1735"
		[/random]
		[random]
			value="3448"
		[/random]
		[random]
			value="9929"
		[/random]
		[random]
			value="9882"
		[/random]
		[random]
			value="2060"
		[/random]
		[random]
			value="13428"
			[results]
				checksum="TuuzMJvu3JOmTCCoKGpBJPA6SCMFtLEzKIxOCmtqSOKJLCFwmIsr1QENmxPFHFw.RFKFnqypNLqM8mwoForIhF8xkkBsH9ih>N4ftxqADyQNdDsofqQwNFrCg8vPGzPi"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="17,16,15,14,13,12"
			y="5,4,4,3,3,2"
		[/move]
	[/command]
	[command]
		[move]
			x="18,17,16,15,14,13"
			y="3,4,4,5,5,6"
		[/move]
	[/command]
	[command]
		[move]
			x="19,20,21,22,23,24"
			y="5,5,6,6,7,7"
		[/move]
	[/command]
	[command]
		[move]
			x="20,21,22,23,24,25,26,27,28"
			y="3,4,4,4,3,4,4,5,5"
		[/move]
	[/command]
	[command]
		[move]
			x="20,19,18,17,16,15"
			y="4,5,4,5,5,6"
		[/move]
	[/command]
	[command]
		[move]
			x="22,21,20,19"
			y="2,3,3,4"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17,16,15,15,14"
			y="20,20,19,19,18,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="elrionthedread has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,20,20,20"
			y="21,20,19,18,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="21,21,22"
			y="20,19,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,21,22,23,24"
			y="20,20,19,19,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,19,19"
			y="20,19,18,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,18,18,18,18,18"
			y="21,20,19,18,17,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="kos has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="13,12,11,10,9,8"
			y="6,5,6,5,6,5"
		[/move]
	[/command]
	[command]
		[move]
			x="15,14,13,12"
			y="6,5,6,5"
		[/move]
	[/command]
	[command]
		[move]
			x="12,12,12,11,11,11,11,11"
			y="2,3,4,5,6,7,8,9"
		[/move]
	[/command]
	[command]
		[move]
			x="24,23,22,21,20,19,18"
			y="7,8,8,8,8,9,9"
		[/move]
	[/command]
	[command]
		[move]
			x="28,28,28,28"
			y="5,6,7,8"
		[/move]
	[/command]
	[command]
		[move]
			x="28,28"
			y="8,9"
		[/move]
	[/command]
	[command]
		[move]
			x="28,28"
			y="9,10"
		[/move]
	[/command]
	[command]
		[move]
			x="28,28"
			y="10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="28,29"
			y="11,12"
		[/move]
	[/command]
	[command]
		[move]
			x="29,29,30"
			y="12,13,13"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,20"
			y="17,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,19,19,19,18"
			y="17,17,16,15,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="11,11,11"
			y="9,10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="11,11"
			y="11,12"
		[/move]
	[/command]
	[command]
		[move]
			x="11,11"
			y="12,13"
		[/move]
	[/command]
	[command]
		[move]
			x="11,11,11,11,11"
			y="13,12,11,10,9"
		[/move]
	[/command]
	[command]
		[move]
			x="12,13,14,15,16,17"
			y="5,6,5,6,5,6"
		[/move]
	[/command]
	[command]
		[move]
			x="8,9,10,11,12,13"
			y="5,6,5,6,5,6"
		[/move]
	[/command]
	[command]
		[move]
			x="30,29,29"
			y="13,14,15"
		[/move]
	[/command]
	[command]
		[move]
			x="29,29,29,29,29,30"
			y="15,16,17,18,19,19"
		[/move]
	[/command]
	[command]
		[move]
			x="18,18"
			y="9,10"
		[/move]
	[/command]
	[command]
		[move]
			x="18,18"
			y="10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="18,18,18"
			y="11,10,9"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Wiggles has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ben11 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="24,25"
			y="18,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26"
			y="19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,23,23,23,24,25"
			y="18,19,20,21,21,22"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17,16,15,14"
			y="16,17,16,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="11,11,11"
			y="9,10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="11,11"
			y="11,12"
		[/move]
	[/command]
	[command]
		[move]
			x="11,11,11,11"
			y="12,11,10,9"
		[/move]
	[/command]
	[command]
		[move]
			x="30,29"
			y="19,19"
		[/move]
	[/command]
	[command]
		[move]
			x="29,29,28,28,27"
			y="19,18,17,16,16"
		[/move]
	[/command]
	[command]
		[move]
			x="17,18,19,20,21,22"
			y="6,6,7,7,7,7"
		[/move]
	[/command]
	[command]
		[move]
			x="13,14,15,16,17,18"
			y="6,6,6,6,6,6"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="KlaW has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26"
			y="22,22"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,26,26,27"
			y="19,18,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="27"
				y="17"
			[/source]
			[destination]
				x="27"
				y="16"
			[/destination]
		[/attack]
		[random]
			value="3296"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="756"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1404"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="957"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29019"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Exia has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="14,13,12,11"
			y="15,15,15,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Mclovin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22,23"
			y="6,7,7,8,8,9"
		[/move]
	[/command]
	[command]
		[move]
			x="22,23,24,25,26,27"
			y="7,8,8,9,9,10"
		[/move]
	[/command]
	[command]
		[recruit]
			value="4"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="26133"
		[/random]
		[random]
			value="23122"
		[/random]
		[random]
			value="30816"
		[/random]
		[random]
			value="24593"
		[/random]
		[random]
			value="3291"
		[/random]
		[random]
			value="7830"
		[/random]
		[random]
			value="5644"
		[/random]
		[random]
			value="2792"
		[/random]
		[random]
			value="14095"
		[/random]
		[random]
			value="32023"
		[/random]
		[random]
			value="19314"
		[/random]
		[random]
			value="16188"
		[/random]
		[random]
			value="18114"
		[/random]
		[random]
			value="18738"
		[/random]
		[random]
			value="29132"
			[results]
				checksum="-n9yN+-Dy+EeNPrPbGMNQXtz0Ipzwss1tysRRKOwxuoVBywHrwxEqutHtKzE>BNMxHQOHFw.RFKFnqypNKAM8mwoFomIhFlq1.CL-<<ddBfkHDONNHvMSO1I9LGCHpAC"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="1"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="31981"
		[/random]
		[random]
			value="16230"
		[/random]
		[random]
			value="12756"
		[/random]
		[random]
			value="18734"
		[/random]
		[random]
			value="8866"
		[/random]
		[random]
			value="13677"
		[/random]
		[random]
			value="26252"
		[/random]
		[random]
			value="476"
		[/random]
		[random]
			value="8787"
		[/random]
		[random]
			value="11874"
		[/random]
		[random]
			value="13258"
		[/random]
		[random]
			value="4356"
		[/random]
		[random]
			value="12915"
		[/random]
		[random]
			value="24196"
		[/random]
		[random]
			value="13862"
			[results]
				checksum="ACIByNSVYoLXPemyRXKCwqFrLmVQqEv0TwtBGgNMvJHtOMFtHrtKmNzMnuxEPDq6BPSLFIOJqR+ProSyETFwFyA9BumVnpCouMKPBb5TJGPbmz3o>.fjcflW4pf7m5p7"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="3"
			x="20"
			y="3"
		[/recruit]
		[random]
			value="14749"
		[/random]
		[random]
			value="11377"
		[/random]
		[random]
			value="31037"
		[/random]
		[random]
			value="24500"
		[/random]
		[random]
			value="20401"
		[/random]
		[random]
			value="14272"
		[/random]
		[random]
			value="12526"
		[/random]
		[random]
			value="25864"
		[/random]
		[random]
			value="3773"
		[/random]
		[random]
			value="4293"
		[/random]
		[random]
			value="22949"
		[/random]
		[random]
			value="27856"
		[/random]
		[random]
			value="6621"
		[/random]
		[random]
			value="3897"
		[/random]
		[random]
			value="26887"
			[results]
				checksum="rQV6GBwD,UJ+7fMAQJ+xOoaC5U6DfS5lmb>+9w26zYBFaluj9yjnQ1omih>hik67n,e0IoZ07o9kcp0Ad568,m9n<X,+m-08797o60sxBFgnXEzrk-i.-tciji+H>s4C"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="17"
			y="5"
		[/recruit]
		[random]
			value="32174"
		[/random]
		[random]
			value="722"
		[/random]
		[random]
			value="18114"
		[/random]
		[random]
			value="23562"
		[/random]
		[random]
			value="10072"
		[/random]
		[random]
			value="22702"
		[/random]
		[random]
			value="11485"
		[/random]
		[random]
			value="20973"
		[/random]
		[random]
			value="12116"
		[/random]
		[random]
			value="23817"
		[/random]
		[random]
			value="16154"
		[/random]
		[random]
			value="24709"
		[/random]
		[random]
			value="18906"
		[/random]
		[random]
			value="30668"
		[/random]
		[random]
			value="30738"
			[results]
				checksum="iqp,4nc1oNO<LLyKmJLIEhoF>vyBA6mszOAMDTywuzyODCrTtRLwFwmIsr1QENmxPFHFw.RFKFnqypNKpM8mwoFomIhFlq1.CLW<<ddBfkHDONNHvHQO1I9LGCHpACmL"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Attilone has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="27"
				y="16"
			[/source]
			[destination]
				x="27"
				y="17"
			[/destination]
		[/attack]
		[random]
			value="5489"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="24173"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Jeremiah has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22,23,24"
			y="9,9,8,8,8,9,9"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,28,29,29,30"
			y="17,17,18,19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="KarmaSpender has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,18,18,18"
			y="14,13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="20"
			y="20"
		[/recruit]
		[random]
			value="11910"
		[/random]
		[random]
			value="29665"
		[/random]
		[random]
			value="21296"
		[/random]
		[random]
			value="22736"
		[/random]
		[random]
			value="2101"
		[/random]
		[random]
			value="30820"
		[/random]
		[random]
			value="12077"
		[/random]
		[random]
			value="11647"
		[/random]
		[random]
			value="24691"
		[/random]
		[random]
			value="15370"
		[/random]
		[random]
			value="4446"
		[/random]
		[random]
			value="18635"
		[/random]
		[random]
			value="27964"
		[/random]
		[random]
			value="3308"
		[/random]
		[random]
			value="32579"
			[results]
				checksum="xNa6Bryn.D--c-i+05ERoaOL-EyQovClJF7qE383X-fb-Zy1ji46+2f+9l+5<foc<nn6f23854.p5418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmIaF"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="1"
			x="20"
			y="21"
		[/recruit]
		[random]
			value="4420"
		[/random]
		[random]
			value="31882"
		[/random]
		[random]
			value="7272"
		[/random]
		[random]
			value="29164"
		[/random]
		[random]
			value="889"
		[/random]
		[random]
			value="17468"
		[/random]
		[random]
			value="24226"
		[/random]
		[random]
			value="654"
		[/random]
		[random]
			value="25055"
		[/random]
		[random]
			value="13662"
		[/random]
		[random]
			value="11902"
		[/random]
		[random]
			value="20601"
		[/random]
		[random]
			value="18918"
			[results]
				checksum="Dem>c1k,fFB3IPKDDy,IIVsrrz9qrFsKPmsAOVOPtQsRHOMGLquuPuNAtBx6AEqpsGOKxE8KFoBPRQNzSIM0NsInAEUrD<pd7wU07l,LsmkMRAyTOtHFLqpFUIIzsxsc"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="4"
			x="18"
			y="21"
		[/recruit]
		[random]
			value="256"
		[/random]
		[random]
			value="439"
		[/random]
		[random]
			value="7419"
		[/random]
		[random]
			value="6182"
		[/random]
		[random]
			value="4138"
		[/random]
		[random]
			value="14916"
		[/random]
		[random]
			value="22905"
		[/random]
		[random]
			value="26496"
		[/random]
		[random]
			value="28137"
		[/random]
		[random]
			value="12004"
		[/random]
		[random]
			value="32318"
		[/random]
		[random]
			value="27776"
		[/random]
		[random]
			value="4926"
			[results]
				checksum="fEAwEAF+1Gub.aUZJ5kiOGDqZxM8i-LoLYEs-E3jSJv0zT>8cpf6b>5Im2-i0051mfOa-a-d4,d8b>dr3-aeWym.7BZSugG6.eC5RE539gmeoJZ4jM-lYWmgBNCho0u4"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="jogador has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="27,28,29,29,30"
			y="16,16,17,18,18"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="30"
				y="18"
			[/source]
			[destination]
				x="30"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="6450"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29283"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="27,27,27,27,27,27"
			y="10,11,12,13,14,15"
		[/move]
	[/command]
	[command]
		[move]
			x="24,25,26,27,27,27,27"
			y="9,10,10,11,12,13,14"
		[/move]
	[/command]
	[command]
		[move]
			x="23,24,25,26,26,26"
			y="9,9,10,10,11,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="poteha has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,21,21,21,22,23"
			y="4,5,6,7,7,8"
		[/move]
	[/command]
	[command]
		[move]
			x="20,20,20,21,21,22"
			y="3,4,5,6,7,7"
		[/move]
	[/command]
	[command]
		[move]
			x="19,20,21,21,22,23,24"
			y="5,5,6,7,7,8,8"
		[/move]
	[/command]
	[command]
		[move]
			x="17,17,18,19,19,19,18"
			y="5,6,6,7,8,9,9"
		[/move]
	[/command]
	[command]
		[recruit]
			value="0"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="25438"
		[/random]
		[random]
			value="20761"
		[/random]
		[random]
			value="5839"
		[/random]
		[random]
			value="20583"
		[/random]
		[random]
			value="7455"
		[/random]
		[random]
			value="15720"
		[/random]
		[random]
			value="12398"
		[/random]
		[random]
			value="26155"
		[/random]
		[random]
			value="14645"
		[/random]
		[random]
			value="16714"
		[/random]
		[random]
			value="19359"
		[/random]
		[random]
			value="4689"
		[/random]
		[random]
			value="25814"
		[/random]
		[random]
			value="12907"
		[/random]
		[random]
			value="3954"
			[results]
				checksum="oxj+sAh20PB0JmsQ56tLoxNPdOFGJz.MMAvVvoQO,ECJMwDzBrzrTwAoECqSJHEvSS3IzTALqvFArEKTmSKvvPnFtw+MnBRSqBwbD3xFMMEJCCHO+YDPPnPywBn8EE25"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="1"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="4197"
		[/random]
		[random]
			value="25889"
		[/random]
		[random]
			value="5642"
		[/random]
		[random]
			value="31465"
		[/random]
		[random]
			value="5804"
		[/random]
		[random]
			value="4273"
		[/random]
		[random]
			value="30053"
		[/random]
		[random]
			value="24303"
		[/random]
		[random]
			value="27535"
		[/random]
		[random]
			value="31079"
		[/random]
		[random]
			value="18022"
		[/random]
		[random]
			value="1734"
		[/random]
		[random]
			value="28347"
		[/random]
		[random]
			value="7690"
		[/random]
		[random]
			value="29507"
			[results]
				checksum="ACIByNSVYmLXPemyRXKFwqFrLmVQqEv0TwtBGgNMvJHtOMFtHrtKmNzMnuxEPDq6BPSLFIOJqR+ProSyETFwFyA9zumVnpCouMKPBb5oJGPbmz3o>.fjcflW4pf7m5p7"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="19,19,19,19"
			y="4,5,6,7"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="quaintquark has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17"
			y="11,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,27,27,28,28,29"
			y="22,22,21,20,19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="29"
				y="19"
			[/source]
			[destination]
				x="30"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="1677"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="4976"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="9797"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1739"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6914"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="13557"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="archetype has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="30"
				y="19"
			[/source]
			[destination]
				x="30"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="8091"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7685"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7670"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="17805"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3699"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,21,22,23,24,25"
			y="20,20,19,19,19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,19,18,18,17,17,16"
			y="21,20,20,19,18,18,17,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,18,18,18,18,18"
			y="21,20,19,18,17,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Awalach has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="27,27,27,27,27,28"
			y="14,15,16,17,18,18"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="28"
				y="18"
			[/source]
			[destination]
				x="29"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="25699"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22580"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="28606"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="2160"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="27,27,28,28,29"
			y="15,16,16,17,18"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="29"
				y="18"
			[/source]
			[destination]
				x="29"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="23929"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="9128"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="4774"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Overlord has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="30"
				y="18"
			[/source]
			[destination]
				x="29"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="5782"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="18336"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1914"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="15816"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="20679"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="12891"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="26,26,26,26,27"
			y="12,13,14,15,16"
		[/move]
	[/command]
	[command]
		[move]
			x="24,24,25,26,26,26,26"
			y="8,9,10,10,11,12,13"
		[/move]
	[/command]
	[command]
		[move]
			x="23,24,24,25,26,26"
			y="8,8,9,10,10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="22,23,23,24,25,26"
			y="7,8,9,9,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Eli has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="19,20,21,21,22,23"
			y="5,5,6,7,7,8"
		[/move]
	[/command]
	[command]
		[move]
			x="20,21,21,21,22,23,24"
			y="4,5,6,7,7,8,8"
		[/move]
	[/command]
	[command]
		[move]
			x="18,17"
			y="9,10"
		[/move]
	[/command]
	[command]
		[move]
			x="19,19,19,18"
			y="7,8,9,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="17"
				y="10"
			[/source]
			[destination]
				x="17"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="32489"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10255"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="3121"
			[results]
				chance="70"
				damage="13"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12689"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="26160"
			[results]
				chance="70"
				damage="13"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5694"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="18,18"
			y="9,10"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="18"
				y="10"
			[/source]
			[destination]
				x="17"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="8801"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="4388"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="11530"
			[results]
				chance="50"
				damage="4"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26"
			y="19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="K has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="29"
				y="19"
			[/source]
			[destination]
				x="30"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="5058"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19275"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="17250"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="32570"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1066"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="12259"
			[results]
				chance="60"
				damage="4"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="30"
				y="19"
			[/source]
			[destination]
				x="30"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="11241"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12443"
		[/random]
		[random]
			value="14677"
		[/random]
		[random]
			value="19909"
		[/random]
		[random]
			value="15879"
		[/random]
		[random]
			value="30783"
		[/random]
		[random]
			value="11664"
		[/random]
		[random]
			value="4831"
		[/random]
		[random]
			value="32671"
		[/random]
		[random]
			value="7683"
		[/random]
		[random]
			value="9439"
		[/random]
		[random]
			value="31335"
		[/random]
		[random]
			value="19175"
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="K has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,27"
			y="19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="27"
				y="19"
			[/source]
			[destination]
				x="28"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="20301"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="18826"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17164"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="30011"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="27076"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29952"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="PAKIDEMON1 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="16,16,16,16,17,17,18"
			y="16,15,14,13,13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="18"
				y="11"
			[/source]
			[destination]
				x="18"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="6031"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="30657"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="9675"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="21038"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17437"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="28047"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="352"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="14,14,14,14,15,15,16,16,17"
			y="17,16,15,14,14,13,12,11,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="17"
				y="11"
			[/source]
			[destination]
				x="18"
				y="10"
			[/destination]
		[/attack]
		[random]
			value="28955"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19167"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7435"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="16318"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="4159"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="15502"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="PAKIDEMON1 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,19,19,19,19"
			y="21,20,19,18,17,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="17,18,19,19"
			y="10,9,10,11"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="19"
				y="11"
			[/source]
			[destination]
				x="18"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="9894"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="28703"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="26345"
			[results]
				chance="70"
				damage="9"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="28508"
			[results]
				chance="60"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="13629"
			[results]
				chance="70"
				damage="9"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="18"
				y="10"
			[/source]
			[destination]
				x="17"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="2017"
			[results]
				chance="40"
				damage="5"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="27,27,26,25,25,26"
			y="16,17,17,18,19,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="26"
				y="19"
			[/source]
			[destination]
				x="27"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="3391"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="12641"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="10308"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="24432"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="29,29,29,30,31"
			y="18,19,20,20,20"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="31"
				y="20"
			[/source]
			[destination]
				x="30"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="22266"
			[results]
				chance="70"
				damage="9"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12956"
			[results]
				chance="70"
				damage="9"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="28,29,30"
			y="18,19,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="30"
				y="19"
			[/source]
			[destination]
				x="30"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="22357"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3239"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="7629"
			[results]
				chance="60"
				damage="7"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="26,26,26,25,25,24"
			y="13,14,15,16,17,17"
		[/move]
	[/command]
	[command]
		[move]
			x="26,26,26,26,26,26"
			y="11,12,13,14,15,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Satyratron has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="26,26,26,26,26,26"
			y="10,11,12,13,14,15"
		[/move]
	[/command]
	[command]
		[move]
			x="24,24,25,26,26,26,26"
			y="8,9,10,10,11,12,13"
		[/move]
	[/command]
	[command]
		[move]
			x="23,23,24,25,26,26"
			y="8,9,9,10,10,11"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,20"
			y="15,14,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,19,19"
			y="16,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="alex_kr has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,19"
			y="15,14,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,21"
			y="13,12,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,19"
			y="16,17,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,19,19"
			y="18,17,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="24,23,22,21,20"
			y="17,17,16,16,15"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="20"
				y="15"
			[/source]
			[destination]
				x="19"
				y="15"
			[/destination]
		[/attack]
		[random]
			value="20307"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6542"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="2852"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21211"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5788"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14143"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1592"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="30,29,28,28,27,26"
			y="19,20,20,21,22,22"
		[/move]
	[/command]
	[command]
		[move]
			x="31,30,29,28,27,26"
			y="20,19,19,18,19,18"
		[/move]
	[/command]
	[command]
		[move]
			x="26,25,24,23,22,21"
			y="19,20,19,19,18,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Eliot"
			message="I cant talk because my keabord have a problem.ok?"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="26,25,25,24,23"
			y="15,16,17,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Orange_Dude"
			message="np"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,18"
			y="10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="19,18,18"
			y="11,11,12"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="18"
				y="12"
			[/source]
			[destination]
				x="19"
				y="13"
			[/destination]
		[/attack]
		[random]
			value="22033"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="24233"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="9937"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23448"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="14662"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="10286"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="18,18,18,19,19"
			y="11,10,9,9,8"
		[/move]
	[/command]
	[command]
		[move]
			x="26,25,24,23,22"
			y="11,11,10,11,11"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="11"
			[/source]
			[destination]
				x="21"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="6480"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="15325"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="9113"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17170"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29164"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="20944"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="26,26,26,25,24,23"
			y="13,12,11,11,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="PhonixCry has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="26,25,25,24,23,22"
			y="16,17,18,18,19,19"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="21,20,19"
			y="12,12,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="19"
				y="12"
			[/source]
			[destination]
				x="18"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="29338"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23335"
			[results]
				chance="80"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="19"
				y="13"
			[/source]
			[destination]
				x="18"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="19680"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14472"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="6602"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,19,20,20,21"
			y="15,14,13,12,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="2"
			[source]
				x="21"
				y="12"
			[/source]
			[destination]
				x="22"
				y="11"
			[/destination]
		[/attack]
		[random]
			value="16945"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19788"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="9712"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5416"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="14740"
			[results]
				chance="60"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="270000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Miki1989 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="19,19,19,19,19"
			y="8,7,6,5,4"
		[/move]
	[/command]
	[command]
		[recruit]
			value="2"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="4880"
		[/random]
		[random]
			value="13428"
		[/random]
		[random]
			value="7152"
		[/random]
		[random]
			value="8178"
		[/random]
		[random]
			value="19513"
		[/random]
		[random]
			value="10093"
		[/random]
		[random]
			value="6889"
		[/random]
		[random]
			value="409"
		[/random]
		[random]
			value="22735"
		[/random]
		[random]
			value="1358"
		[/random]
		[random]
			value="11671"
		[/random]
		[random]
			value="7899"
		[/random]
		[random]
			value="29287"
		[/random]
		[random]
			value="4269"
		[/random]
		[random]
			value="32329"
			[results]
				checksum="5OmKwDKUXxq,TxsyxcPSqynxyiENEnLUmPIBJLzMORyvQtLtMsz3uNvNwJSpuLuGnUrzCuxIPMnkISuGzPSPQusvFwzsUDAquYfrOmRzwFyqGfDMfDAHFKdeVs241d4."
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="2"
			x="19"
			y="5"
		[/recruit]
		[random]
			value="28544"
		[/random]
		[random]
			value="1092"
		[/random]
		[random]
			value="30689"
		[/random]
		[random]
			value="14781"
		[/random]
		[random]
			value="18114"
		[/random]
		[random]
			value="28121"
		[/random]
		[random]
			value="31826"
		[/random]
		[random]
			value="15132"
		[/random]
		[random]
			value="8146"
		[/random]
		[random]
			value="12133"
		[/random]
		[random]
			value="9402"
		[/random]
		[random]
			value="254"
		[/random]
		[random]
			value="32283"
		[/random]
		[random]
			value="15607"
		[/random]
		[random]
			value="23039"
			[results]
				checksum="9CIQwCrz6RyeTTICy,HrVEsv8xKMwFuxzJDqOwQmKzmtMTEzPv,zPSmuOMoJAyLuJqKyRzLtHrjyLNtqqmLt5eGFJBAwBICTrpKGHCIsunwtguIWcfGAO<cOO98<20k3"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="2"
			x="18"
			y="4"
		[/recruit]
		[random]
			value="8406"
		[/random]
		[random]
			value="27756"
		[/random]
		[random]
			value="14729"
		[/random]
		[random]
			value="14987"
		[/random]
		[random]
			value="22188"
		[/random]
		[random]
			value="23619"
		[/random]
		[random]
			value="22332"
		[/random]
		[random]
			value="13825"
		[/random]
		[random]
			value="4563"
		[/random]
		[random]
			value="8300"
		[/random]
		[random]
			value="12065"
		[/random]
		[random]
			value="12663"
		[/random]
		[random]
			value="17737"
		[/random]
		[random]
			value="1732"
		[/random]
		[random]
			value="9004"
			[results]
				checksum="9CIQwCrz6RyeTTICy,HrVEsv8xKMwFuxzJDqOwQmKzmtMTEzPv,zPSmuOMoJAyLuJqKyRzLtHrjzLNtqqmLt5eGFJBAwBICTrpKGHCIsunwtguIWcjGAO<cOO98<30k3"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="2"
			x="17"
			y="5"
		[/recruit]
		[random]
			value="3576"
		[/random]
		[random]
			value="17561"
		[/random]
		[random]
			value="30154"
		[/random]
		[random]
			value="19697"
		[/random]
		[random]
			value="2425"
		[/random]
		[random]
			value="18259"
		[/random]
		[random]
			value="18211"
		[/random]
		[random]
			value="8332"
		[/random]
		[random]
			value="15089"
		[/random]
		[random]
			value="9297"
		[/random]
		[random]
			value="31029"
		[/random]
		[random]
			value="22382"
		[/random]
		[random]
			value="13889"
		[/random]
		[random]
			value="15552"
		[/random]
		[random]
			value="21001"
			[results]
				checksum="5OmKwDKUXxq,TxsyxcPSqynxyiENEnLUmPIBJLzMORyvQtLtMsz3uNvNwJSpuLuGnUrzCuxIPMnkISuGzPSPQusvFwzsUDAquYfrOmRzwFyqJ9DMfDvHFKdeVs241d4."
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="vbvb has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="2"
			x="20"
			y="3"
		[/recruit]
		[random]
			value="13184"
		[/random]
		[random]
			value="5990"
		[/random]
		[random]
			value="3816"
		[/random]
		[random]
			value="31219"
		[/random]
		[random]
			value="21136"
		[/random]
		[random]
			value="4143"
		[/random]
		[random]
			value="731"
		[/random]
		[random]
			value="25196"
		[/random]
		[random]
			value="11881"
		[/random]
		[random]
			value="5652"
		[/random]
		[random]
			value="6428"
		[/random]
		[random]
			value="19227"
		[/random]
		[random]
			value="2122"
		[/random]
		[random]
			value="2534"
		[/random]
		[random]
			value="393"
			[results]
				checksum="5OmKwDKUXxq,TxsyxcPSqynxyiENEnLUmPIBJLzMORyvQtLtMsz3uNvNwJSpuLuGnUrzCuxIPMnkISuGzPSPQusvFwzsUDAquYfrOmRzwFyqGfDMfDAHFKdeVs241d4."
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="20,20,21,21"
			y="15,14,14,13"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="21"
				y="13"
			[/source]
			[destination]
				x="21"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="22547"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="7342"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3540"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21360"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="16648"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="2045"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="4606"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="hostO has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="22,22"
			y="11,12"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="12"
			[/source]
			[destination]
				x="21"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="11163"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="13338"
			[results]
				chance="50"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="28854"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3004"
			[results]
				chance="50"
				damage="5"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="X has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="23,23,22"
			y="11,12,12"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="22"
				y="12"
			[/source]
			[destination]
				x="21"
				y="12"
			[/destination]
		[/attack]
		[random]
			value="899"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="13576"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22554"
			[results]
				chance="60"
				damage="5"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="Orange_Dude"
			message="gg"
			side="1"
		[/speak]
	[/command]
[/replay]
[snapshot]
[/snapshot]
[replay_start]
	current_tod="0"
#textdomain wesnoth-multiplayer
	description=_ "The Freelands, also known to the people of the far east as The Land of No Kings, lie in between the Wilderlands and the Kingdom of Carorath, separating a land of absolute law from a land of absolute savagery. The people of the Freelands have been battling would-be conquerors of their land for hundreds of years, repelling great beasts from their western borders, and Carorathian Imperialists from their eastern borders."
	experience_modifier="70"
	hash="AZpjPHK9RkU0>,MQ5rgweyP<JzghTihOJuI7sg1ofROR9BWAOxx4eNCrLCAawpGy1PNS9jQpzls8f-x>JH6Z+AjIQoLdwN-L<ur6gO9uHgd>jKtxiiu590Q8hM4gox7."
	id="multiplayer_The_Freelands"
	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   , Mm^Xm       , _off^_usr   , Hh          , _off^_usr   , Gg^Fet      , _off^_usr   , Gs^Fp       , _off^_usr   , Mm          , _off^_usr   , Ww          , _off^_usr   , Ww          , _off^_usr   , Ggf         , _off^_usr   , Hh          , _off^_usr   , 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   , Mm^Xm       , Mm          , Mm^Xm       , Hh          , Gg^Ve       , Gs^Fp       , Hh          , Gg^Uf       , Gs^Fms      , Hh          , Wwf         , Wwf         , Ww          , Ww          , Ss^Vhs      , Gg          , Gs^Fp       , Gs^Fp       , Mm          , Hh^Uf       , Ggf         , Ss          , Gs^Fp       , _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         , Mm          , Hh          , Mm^Xm       , Mm          , Ggf         , Gg          , Gg          , Gg          , Ggf         , Rr          , Wwf         , Ch          , Wwf         , Ch          , Hh          , Gg          , Gg          , Gg          , Ss          , Gs^Fms      , Hh          , Gg          , Gg^Uf       , Gs^Fms      , Wwf         , Hh          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs^Fp       , Hh          , Wwf         , Gs^Fms      , Gs^Fp       , Gg^Uf       , Gg          , Gg          , Gg          , Gg          , Mm          , Rr          , Wwf         , Wwf         , Kh          , 1 Kh        , Ch          , Gg          , Gg          , Gg          , Ss          , Gg          , Gg          , Gg          , Hh          , Gg          , Wwf         , Wwf         , Gg^Fet      , Hh          , Mm          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gg          , Gg          , Wwf         , Wwf         , Ss^Vhs      , Gg          , Gg          , Gg          , Gg^Vh       , Gs^Fp       , Wwf         , Wwf         , Gg          , Ch          , Rr          , Ch          , Rr          , Gg          , Gs^Fp       , Ss          , Mm          , Ss          , Ss          , Gg          , Ss^Vhs      , Gs^Fp       , Wwf         , Wwf         , Wwf         , Wwf         , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Wwf         , Hh          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Wwf         , Gg          , Gs^Fp       , Gg          , Gg          , Rr          , Rr          , Gg          , Ss          , Hh          , Gs^Fp       , Hh^Uf       , Gs^Fp       , Gg          , Wwf         , Wwf         , Gg          , Gg          , Ggf         , Wwf         , Mm^Xm       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Gs^Fms      , Mm^Xm       , Gs^Fp       , Mm          , Ggf         , Wwf         , Wwf         , Wwf         , Wwf         , Gs^Fp       , Mm^Xm       , Mm^Xm       , Mm^Xm       , Hh          , Rr          , Gg          , Gg          , Gg          , Ggf         , Gg^Ve       , Hh          , Gg          , Wwf         , Wwf         , Wwf         , Gg          , Gg          , Hh          , Gs^Fms      , Mm^Xm       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Mm          , Gg^Uf       , Mm^Xm       , Hh          , Wwf         , Gg          , Gg          , Gg          , Gg          , Mm          , Hh^Uf       , Hh^Uf       , Mm^Xm       , Hh          , Rr          , Gg          , Gg          , Gg          , Gg          , Gg          , Gg          , Wwf         , Wwf         , Gg          , Gg          , Gg          , Gg^Uf       , Mm^Xm       , Mm^Xm       , Mm          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Gs^Fp       , Gg          , Ggf         , Wwf         , Wwf         , Gg          , Gg^Ve       , Gg          , Gg          , Hh          , Mm^Xm       , Gs^Fp       , Gs^Fp       , Hh^Vhh      , Rr          , Hh          , Hh          , Mm          , Gg^Fet      , Gg          , Gg          , Wwf         , Wwf         , Gg          , Gg          , Gg          , Hh          , Mm          , Mm^Xm       , Mm          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs^Fms      , Wwf         , Wwf         , Wwf         , Hh          , Gg          , Gg          , Gg          , Gg          , Gg          , Gs^Fp       , Mm^Xm       , Mm^Xm       , Hh          , Gg          , Rr          , Rr          , Gs^Fp       , Hh          , Hh          , Wwf         , Wwf         , Wwf         , Chr         , Chr         , Hh          , Gg          , Ggf         , Hh          , Mm^Xm       , Mm^Xm       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Hh          , Gg          , Wwf         , Mm          , Gs^Fp       , Gg          , Rr          , Gg          , Ggf         , Gg^Uf       , Mm^Xm       , Mm^Xm       , Mm          , Gs^Fp       , Gg          , Gg          , Wo          , Wo          , Wwf         , Wwf         , Mm^Xm       , Hh          , Gg          , Chw         , Wwf         , Gg^Fet      , Wwf         , Gg          , Gg          , Gs^Fp       , Gs^Fms      , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Wwf         , Wwf         , Hh          , Rr          , Rr          , Rr          , Gg          , Gg          , Gs^Fp       , Mm^Xm       , Mm^Xm       , Hh          , Gg          , Gg          , Ww          , Gg          , Gg          , Hh          , Rr          , Mm^Xm       , Mm          , Gg          , Rr          , Rr          , Wwf         , Rr          , Wwf         , Wwf         , Gg          , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gg^Fet      , Gg          , Gg          , Wwf         , Wwf         , Wwf         , Wwf         , Rr          , Gg          , Mm          , Mm^Xm       , Rr          , Wwf         , Gg          , Wo          , Ww          , Gg          , Gg          , Mm          , Mm^Xm       , Mm^Xm       , Gs^Fms      , Gg          , Gg          , Rr          , Rr          , Gs^Fms      , Hh          , Wwf         , Wwf         , Hh          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm^Xm       , Gs^Fp       , Hh          , Gg          , Gg          , Gs^Fp       , Chr         , Chw         , Wwf         , Hh          , Wwf         , Wwf         , Hh          , Wo          , Rr          , Gg          , Gg          , Gs^Fp       , Mm^Xm       , Mm^Xm       , Gs^Fp       , Gg^Uf       , Gg          , Gg          , Gg          , Gg          , Hh          , Mm          , Wwf         , Gg          , Gs^Fp       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm          , Mm^Xm       , Mm          , Ggf         , Gg          , Hh          , Gg          , Chr         , Wwf         , Wwf         , Gg          , Hh          , Mm          , Gg^Fet      , Hh          , Rr          , Hh^Vhh      , Hh          , Gs^Fp       , Mm^Xm       , Hh          , Ggf         , Gg          , Gg          , Gg          , Gg          , Wwf         , Wwf         , Gg          , Wwf         , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm          , Mm^Xm       , Mm^Xm       , Hh          , Ggf         , Gg          , Gg          , Wwf         , Wwf         , Gg          , Gg          , Gs^Fp       , Gg          , Hh          , Gg          , Rr          , Hh          , Gs^Fp       , Hh^Uf       , Mm^Xm       , Mm          , Gg          , Gg          , Gg^Ve       , Gg          , Wwf         , Hh          , Gg          , Gg^Uf       , Gg^Fet      , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm^Xm       , Mm^Xm       , Hh          , Gg^Uf       , Gg          , Gg          , Wwf         , Wwf         , Gg          , Gg          , Gg^Ve       , Gg          , Gg          , Gg          , Gg          , Rr          , Hh          , Mm^Xm       , Mm^Xm       , Hh^Uf       , Gs^Fp       , Gg          , Wwf         , Gg          , Wwf         , Wwf         , Mm          , Mm^Xm       , Mm^Xm       , Mm          , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm^Xm       , Gs^Fms      , Ggf         , Gg          , Gg          , Wwf         , Wwf         , Wwf         , Gs^Fms      , Hh          , Gs^Fp       , Ggf         , Ss          , Gg          , Rr          , Rr          , Gg          , Mm^Xm       , Gs^Fp       , Mm^Xm       , Wwf         , Wwf         , Gg          , Wwf         , Gg          , Gg          , Gg          , Gs^Fp       , Hh          , Gs^Fms      , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Wwf         , Wwf         , Gg          , Wwf         , Wwf         , Ss^Vhs      , Gg          , Ss          , Hh^Uf       , Mm          , Hh          , Gs^Fp       , Gg          , Rr          , Rr          , Rr          , Gg          , Gg          , Gg          , Wwf         , Gg          , Gg^Vh       , Gg          , Gg          , Gg          , Ss^Vhs      , Gg          , Wwf         , Wwf         , Gg          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Hh          , Wwf         , Gs^Fp       , Wwf         , Wwf         , Gs^Fp       , Hh          , Gg          , Gg          , Ss          , Ss          , Ss          , Gg          , Gg          , Ch          , Ch          , Kh          , Ch          , Wwf         , Wwf         , Mm          , Gs^Fms      , Gg          , Gg          , Gg          , Ggf         , Gs^Fp       , Wwf         , Wwf         , Gg          , Gs^Fp       , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm          , Hh          , Wwf         , Gs^Fms      , Gg          , Gg          , Gg          , Gs^Fp       , Gg          , Gg          , Gg          , Gg          , Gg          , Ch          , 2 Kh        , Ch          , Wwf         , Rr          , Rr          , Gg          , Gg          , Gg          , Gg          , Gs^Fp       , Gg^Uf       , Hh          , Gs^Fp       , Wwf         , 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   , Wwf         , Gs^Fp       , Gg^Uf       , Ggf         , Hh          , Mm          , Ss          , Gs^Fp       , Gg          , Ss^Vhs      , Hh          , Ww          , Wwf         , Wwf         , Wwf         , Hh          , Gg          , Ggf         , Gg          , Gg^Ve       , Ggf         , Mm^Xm       , 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   , Ss          , Mm          , Hh          , Gs^Fp       , Hh^Uf       , Ggf         , Ggf         , Ww          , Ww          , Ww          , Wwf         , Mm          , Gs^Fp       , Gs^Fp       , Gg^Uf       , Gs^Fp       , Gg^Fet      , Hh          , Hh          , 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   , _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   
"
	mp_countdown="yes"
	mp_countdown_action_bonus="20"
	mp_countdown_init_time="270"
	mp_countdown_reservoir_time="270"
	mp_countdown_turn_bonus="200"
	mp_fog="yes"
	mp_shroud="no"
	mp_use_map_settings="yes"
	mp_village_gold="2"
	name=_ "2p - The Freelands"
	next_underlying_unit_id="0"
#textdomain wesnoth
	objectives=_ "Victory:
@Defeat enemy leader(s)"
	observer="yes"
	random_seed="28986"
	random_start_time="no"
	scenario="Ladder: Orange_Dude's game"
	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="7"
		controller="human"
		current_player="Orange_Dude"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		id="Orange_Dude1"
		image="units/elves-wood/captain.png"
		income="0"
		leader="Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,White Mage,Red Mage,Elder Wose"
		mp_countdown="yes"
		mp_countdown_action_bonus="20"
		mp_countdown_init_time="270"
		mp_countdown_reservoir_time="270"
		mp_countdown_turn_bonus="200"
		name="Orange_Dude"
		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"
		save_id="Orange_Dude1"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="1"
		team_name="north"
		terrain_liked="Ff, Fa, Ss, Ww"
		type="Elvish Captain"
		user_team_name="wesnoth-multiplayerteamname^North"
		village_gold="2"
		[ai]
			recruitment_pattern="fighter,fighter,archer,archer,mixed fighter,healer,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="yes"
		canrecruit="yes"
		colour="2"
		controller="network"
		current_player="Eliot"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		id="Eliot2"
		image="units/undead-necromancers/dark-sorcerer.png"
		income="0"
		leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter,Necrophage"
		mp_countdown="yes"
		mp_countdown_action_bonus="20"
		mp_countdown_init_time="270"
		mp_countdown_reservoir_time="270"
		mp_countdown_turn_bonus="200"
		name="Eliot"
		random_leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter"
		recruit="Skeleton,Skeleton Archer,Walking Corpse,Ghost,Vampire Bat,Dark Adept,Ghoul"
		save_id="Eliot2"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="2"
		team_name="south"
		terrain_liked="Ss, Hh, Ha, Ww"
		type="Dark Sorcerer"
		user_team_name="wesnoth-multiplayerteamname^South"
		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]
[/replay_start]
[statistics]
	mid_scenario="yes"
	[scenario]
		scenario="2p - The Freelands"
		[team]
			[recruits]
				Dark Adept="1"
				Ghost="1"
				Ghoul="1"
				Skeleton="1"
				Skeleton Archer="2"
				Vampire Bat="1"
				Walking Corpse="2"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
				Dark Adept="1"
				Dark Sorcerer="1"
				Ghost="1"
				Ghoul="1"
				Skeleton Archer="1"
				Vampire Bat="1"
				Walking Corpse="3"
			[/deaths]
			[killed]
				Elvish Fighter="1"
				Elvish Scout="1"
				Mage="1"
			[/killed]
			[attacks]
				[sequence]
					s00="1"
					s001="1"
					s01="2"
					s1="2"
					s101="1"
					s11="1"
					s110="1"
					_num="60"
				[/sequence]
				[sequence]
					s11="2"
					_num="70"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="8"
					_num="0"
				[/sequence]
				[sequence]
					s010="1"
					_num="40"
				[/sequence]
				[sequence]
					s000="1"
					s11="1"
					_num="50"
				[/sequence]
				[sequence]
					s0="1"
					s10="1"
					s101="1"
					s11="1"
					s110="2"
					_num="60"
				[/sequence]
				[sequence]
					s0="1"
					_num="70"
				[/sequence]
			[/defends]
			recruit_cost="124"
			recall_cost="0"
			damage_inflicted="129"
			damage_taken="281"
			expected_damage_inflicted="125679"
			expected_damage_taken="258431"
			turn_damage_inflicted="46"
			turn_damage_taken="44"
			turn_expected_damage_inflicted="38929"
			turn_expected_damage_taken="36453"
			save_id="Eliot2"
		[/team]
		[team]
			[recruits]
				Elvish Archer="2"
				Elvish Fighter="3"
				Elvish Scout="7"
				Elvish Shaman="1"
				Mage="3"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
				Elvish Fighter="1"
				Elvish Scout="1"
				Mage="1"
			[/deaths]
			[killed]
				Dark Adept="1"
				Dark Sorcerer="1"
				Ghost="1"
				Ghoul="1"
				Skeleton Archer="1"
				Vampire Bat="1"
				Walking Corpse="3"
			[/killed]
			[attacks]
				[sequence]
					s00="1"
					s1="1"
					_num="40"
				[/sequence]
				[sequence]
					s11="1"
					_num="50"
				[/sequence]
				[sequence]
					s00="1"
					s0010="1"
					s01="2"
					s010="1"
					s0101="1"
					s0111="1"
					s1100="1"
					s111="1"
					s1111="1"
					_num="60"
				[/sequence]
				[sequence]
					s011="2"
					s11="1"
					s110="1"
					s111="1"
					_num="70"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="1"
					s010="1"
					s0101="1"
					_num="40"
				[/sequence]
				[sequence]
					s0110="1"
					_num="50"
				[/sequence]
				[sequence]
					s001="1"
					s011="2"
					s1101="1"
					s111="1"
					_num="60"
				[/sequence]
				[sequence]
					s0="1"
					_num="70"
				[/sequence]
				[sequence]
					s1="1"
					_num="80"
				[/sequence]
			[/defends]
			recruit_cost="277"
			recall_cost="0"
			damage_inflicted="281"
			damage_taken="129"
			expected_damage_inflicted="258431"
			expected_damage_taken="125679"
			turn_damage_inflicted="30"
			turn_damage_taken="18"
			turn_expected_damage_inflicted="24135"
			turn_expected_damage_taken="19536"
			save_id="Orange_Dude1"
		[/team]
	[/scenario]
[/statistics]
