label="donkey vs Den"
version="1.6"
completion="victory"
campaign_type="multiplayer"
difficulty="NORMAL"
random_seed="6088"
random_calls="0"
next_underlying_unit_id="33"
end_text_duration="0"
[variables]
[/variables]
[replay]
	[command]
		[start]
		[/start]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Gwledig has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="thibaud has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Tolkien has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="gl and have fun"
			side="1"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="4"
			x="20"
			y="28"
		[/recruit]
		[random]
			value="3981"
		[/random]
		[random]
			value="31888"
		[/random]
		[random]
			value="5872"
		[/random]
		[random]
			value="20677"
		[/random]
		[random]
			value="16604"
		[/random]
		[random]
			value="11907"
		[/random]
		[random]
			value="10164"
		[/random]
		[random]
			value="16866"
		[/random]
		[random]
			value="15753"
		[/random]
		[random]
			value="6581"
		[/random]
		[random]
			value="20158"
		[/random]
		[random]
			value="28204"
		[/random]
		[random]
			value="17079"
		[/random]
		[random]
			value="8516"
		[/random]
		[random]
			value="21245"
			[results]
				checksum="uyqOVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUFLDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcoe3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Test0sterone has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="4"
			x="18"
			y="28"
		[/recruit]
		[random]
			value="28849"
		[/random]
		[random]
			value="26274"
		[/random]
		[random]
			value="10962"
		[/random]
		[random]
			value="28454"
		[/random]
		[random]
			value="9902"
		[/random]
		[random]
			value="3324"
		[/random]
		[random]
			value="9235"
		[/random]
		[random]
			value="28343"
		[/random]
		[random]
			value="21826"
		[/random]
		[random]
			value="11176"
		[/random]
		[random]
			value="12819"
		[/random]
		[random]
			value="19180"
		[/random]
		[random]
			value="24906"
		[/random]
		[random]
			value="3043"
		[/random]
		[random]
			value="20907"
			[results]
				checksum="uyqOVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUFLDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcoe3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="19,18,17,16,15"
			y="28,27,27,27,27"
		[/move]
	[/command]
	[command]
		[recruit]
			value="4"
			x="15"
			y="28"
		[/recruit]
		[random]
			value="8223"
		[/random]
		[random]
			value="28950"
		[/random]
		[random]
			value="23354"
		[/random]
		[random]
			value="8353"
		[/random]
		[random]
			value="13351"
		[/random]
		[random]
			value="16599"
		[/random]
		[random]
			value="11696"
		[/random]
		[random]
			value="13402"
		[/random]
		[random]
			value="26347"
		[/random]
		[random]
			value="12539"
		[/random]
		[random]
			value="19759"
		[/random]
		[random]
			value="27225"
		[/random]
		[random]
			value="23226"
		[/random]
		[random]
			value="6763"
		[/random]
		[random]
			value="12178"
			[results]
				checksum="uyqNVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUFGDPxfDLuyOdqNHp2JuaZJrXGikJwc0bkdib+c.P93obZj,mcoj3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="7"
			x="14"
			y="28"
		[/recruit]
		[random]
			value="21789"
		[/random]
		[random]
			value="24932"
		[/random]
		[random]
			value="22519"
		[/random]
		[random]
			value="20217"
		[/random]
		[random]
			value="4846"
		[/random]
		[random]
			value="24721"
		[/random]
		[random]
			value="11734"
		[/random]
		[random]
			value="23407"
		[/random]
		[random]
			value="10905"
		[/random]
		[random]
			value="11432"
		[/random]
		[random]
			value="12682"
		[/random]
		[random]
			value="13475"
		[/random]
		[random]
			value="7497"
		[/random]
		[random]
			value="22519"
		[/random]
		[random]
			value="10939"
			[results]
				checksum="c4jbeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh1k<i8Sem73jI-oaGeRO,h0ybO20xxhh6<5,n30KE4<Yfd6-cbeDq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Blitzi has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="teg has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message=":) & for you :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="4"
			x="13"
			y="28"
		[/recruit]
		[random]
			value="1102"
		[/random]
		[random]
			value="27269"
		[/random]
		[random]
			value="6465"
		[/random]
		[random]
			value="4822"
		[/random]
		[random]
			value="22246"
		[/random]
		[random]
			value="29112"
		[/random]
		[random]
			value="16366"
		[/random]
		[random]
			value="15929"
		[/random]
		[random]
			value="31177"
		[/random]
		[random]
			value="4151"
		[/random]
		[random]
			value="27710"
		[/random]
		[random]
			value="18977"
		[/random]
		[random]
			value="10950"
		[/random]
		[random]
			value="26975"
		[/random]
		[random]
			value="23978"
			[results]
				checksum="FTxBwyUzhyBkwVHKQOq5AMPytSNtRJzMRsDuHBtnQvBFyQAVsL8qJTmQQNRqrWuTuTxCUFMDPxfDLuyOdqNHp2JuaZJrXGikJwc0bkdie+c.P93obZj,mcoh3b,IXl32"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Arkanos has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,15,15"
			y="27,26,25"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Pace has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="mishu1985 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Volstagg has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="5"
			x="20"
			y="3"
		[/recruit]
		[random]
			value="4640"
		[/random]
		[random]
			value="16319"
		[/random]
		[random]
			value="30653"
		[/random]
		[random]
			value="20001"
		[/random]
		[random]
			value="19725"
		[/random]
		[random]
			value="4721"
		[/random]
		[random]
			value="25209"
		[/random]
		[random]
			value="7611"
		[/random]
		[random]
			value="1559"
		[/random]
		[random]
			value="27142"
		[/random]
		[random]
			value="25822"
		[/random]
		[random]
			value="18264"
		[/random]
		[random]
			value="4632"
		[/random]
		[random]
			value="22977"
		[/random]
		[random]
			value="20410"
			[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="5"
			x="19"
			y="4"
		[/recruit]
		[random]
			value="30573"
		[/random]
		[random]
			value="20756"
		[/random]
		[random]
			value="26667"
		[/random]
		[random]
			value="22319"
		[/random]
		[random]
			value="19452"
		[/random]
		[random]
			value="19452"
		[/random]
		[random]
			value="1269"
		[/random]
		[random]
			value="29324"
		[/random]
		[random]
			value="22003"
		[/random]
		[random]
			value="1581"
		[/random]
		[random]
			value="2400"
		[/random]
		[random]
			value="6798"
		[/random]
		[random]
			value="21343"
		[/random]
		[random]
			value="28110"
		[/random]
		[random]
			value="29194"
			[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"
		[speak]
			id="server"
			message="gothi2 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="mishu1985 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Vorich has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Faris has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="20"
			y="4"
		[/recruit]
		[random]
			value="29981"
		[/random]
		[random]
			value="5569"
		[/random]
		[random]
			value="4714"
		[/random]
		[random]
			value="23330"
		[/random]
		[random]
			value="30093"
		[/random]
		[random]
			value="30342"
		[/random]
		[random]
			value="14627"
		[/random]
		[random]
			value="15906"
		[/random]
		[random]
			value="12370"
		[/random]
		[random]
			value="24361"
		[/random]
		[random]
			value="26526"
		[/random]
		[random]
			value="24515"
		[/random]
		[random]
			value="4471"
		[/random]
		[random]
			value="478"
		[/random]
		[random]
			value="25679"
			[results]
				checksum="LhGI28qHcsJn9Niqer4mpRo6wD4zsHnKP1Hy+wP.,jg1d-5cL>71745hhbgk5n1,oc<nn6f23854.p5418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmI"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="sauron has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,19,20,20,20,21,22"
			y="3,4,4,5,6,7,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="cvb has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="14,15,16,17,18,19,20,21"
			y="28,28,27,27,27,28,28,28"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Takaki has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,21,22,23,24,24,24,24"
			y="28,28,27,27,26,25,24,23"
		[/move]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22,23,24"
			y="28,28,27,27,26,26,25"
		[/move]
	[/command]
	[command]
		[move]
			x="15,15,16,17,18"
			y="28,27,26,26,25"
		[/move]
	[/command]
	[command]
		[move]
			x="13,14,14,14,14,14"
			y="28,27,26,25,24,23"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Burp has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,14,13,12,11,11,11"
			y="25,24,24,23,23,22,21"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Woodss has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="That statue - just obstacle? Can't hit& be destroyed?"
			side="2"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="just statues"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,23,24,25,26,27,28"
			y="7,7,7,8,8,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="super_rambo has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,19,18,17"
			y="3,3,3,3"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,18,17,16,15,14,13,12,11,10"
			y="4,4,5,5,6,6,7,7,8,7"
		[/move]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="wish you could hit them, though... 1 hp"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Diablo has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Korog has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,19,18"
			y="4,5,5"
		[/move]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="2"
			x="28"
			y="10"
		[/recruit]
		[random]
			value="31959"
		[/random]
		[random]
			value="737"
		[/random]
		[random]
			value="16153"
		[/random]
		[random]
			value="13854"
		[/random]
		[random]
			value="18931"
		[/random]
		[random]
			value="28661"
		[/random]
		[random]
			value="13535"
		[/random]
		[random]
			value="28417"
		[/random]
		[random]
			value="23785"
		[/random]
		[random]
			value="22906"
		[/random]
		[random]
			value="32604"
		[/random]
		[random]
			value="12198"
		[/random]
		[random]
			value="6888"
			[results]
				checksum="TuuzMJvu3JOmTCCoKGpBJPA6SCMFtLEzKIxOCmtqSOKJLCFwmIsr1QENmxPFHFw.RFKFnqypNLqM8mwoForIhF8xkkBsH9ih>N4ftxqADyQNdDsofqQwNFrCg8vPGzPi"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="5"
			x="28"
			y="9"
		[/recruit]
		[random]
			value="5659"
		[/random]
		[random]
			value="5996"
		[/random]
		[random]
			value="17865"
		[/random]
		[random]
			value="9461"
		[/random]
		[random]
			value="1302"
		[/random]
		[random]
			value="30330"
		[/random]
		[random]
			value="3303"
		[/random]
		[random]
			value="27137"
		[/random]
		[random]
			value="4352"
		[/random]
		[random]
			value="17101"
		[/random]
		[random]
			value="21495"
		[/random]
		[random]
			value="7156"
		[/random]
		[random]
			value="17407"
		[/random]
		[random]
			value="13449"
		[/random]
		[random]
			value="12000"
			[results]
				checksum="wmNOCQ,<jCB,xNaeN9c8kBjp>f.33i3,bi2g6odf4d42johapi+j5>4.,j0+4d89dk>9,2l6y.fc-I>-,WJ2j2m>8oQ0birbp4<4OkUyc1iTJvFiKQ-515ck2.Ih5Kjg"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="2"
			x="29"
			y="10"
		[/recruit]
		[random]
			value="6228"
		[/random]
		[random]
			value="17163"
		[/random]
		[random]
			value="29495"
		[/random]
		[random]
			value="13935"
		[/random]
		[random]
			value="899"
		[/random]
		[random]
			value="25151"
		[/random]
		[random]
			value="5519"
		[/random]
		[random]
			value="26822"
		[/random]
		[random]
			value="21661"
		[/random]
		[random]
			value="6611"
		[/random]
		[random]
			value="17522"
		[/random]
		[random]
			value="22658"
		[/random]
		[random]
			value="6267"
			[results]
				checksum="TuuzMJvu3JOmTCCoKGpBJPA6SCMFtLEzKIxOCmtqSOKJLCFwmIsr1QENmxPFHFw.RFKFnqypNLqM8mwoForIhF8xkkBsH9ih>N4ftxqADyQNdDsofqQwNFrCg8vPGzPi"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[move]
			x="21,22,23,24,24,24,24,24"
			y="28,27,27,26,25,24,23,22"
		[/move]
	[/command]
	[command]
		[move]
			x="24,24,25,26,27"
			y="25,24,24,23,24"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Thanks :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="24,25,25,25,25,25"
			y="23,23,22,21,20,19"
		[/move]
	[/command]
	[command]
		[move]
			x="18,18,18,18,18,18,19,19,20"
			y="25,24,23,22,21,20,20,19,18"
		[/move]
	[/command]
	[command]
		[move]
			x="14,15,16,17,18,18"
			y="23,23,22,22,21,20"
		[/move]
	[/command]
	[command]
		[move]
			x="11,10,9"
			y="21,21,21"
		[/move]
	[/command]
	[command]
		[recruit]
			value="4"
			x="9"
			y="19"
		[/recruit]
		[random]
			value="23373"
		[/random]
		[random]
			value="4018"
		[/random]
		[random]
			value="30680"
		[/random]
		[random]
			value="9938"
		[/random]
		[random]
			value="15700"
		[/random]
		[random]
			value="17004"
		[/random]
		[random]
			value="116"
		[/random]
		[random]
			value="10461"
		[/random]
		[random]
			value="26834"
		[/random]
		[random]
			value="6999"
		[/random]
		[random]
			value="4812"
		[/random]
		[random]
			value="3280"
		[/random]
		[random]
			value="5452"
		[/random]
		[random]
			value="4397"
		[/random]
		[random]
			value="12990"
			[results]
				checksum="uyqNVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUFJDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcok3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="7"
			x="8"
			y="19"
		[/recruit]
		[random]
			value="24973"
		[/random]
		[random]
			value="19844"
		[/random]
		[random]
			value="3951"
		[/random]
		[random]
			value="9389"
		[/random]
		[random]
			value="20134"
		[/random]
		[random]
			value="25488"
		[/random]
		[random]
			value="15486"
		[/random]
		[random]
			value="14878"
		[/random]
		[random]
			value="31158"
		[/random]
		[random]
			value="23675"
		[/random]
		[random]
			value="11952"
		[/random]
		[random]
			value="27377"
		[/random]
		[random]
			value="30274"
		[/random]
		[random]
			value="18944"
		[/random]
		[random]
			value="3041"
			[results]
				checksum="c4ibeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh0c<i8Sem73jI-oaGeRO,h>ybO20xxhh6<5,n30KE4<Yfd6-cbfLq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Lycan has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,8,7,6"
			y="21,20,20,19"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="physiognom has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="10,10,10"
			y="7,8,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="10,11,11"
			y="9,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="11,12"
			y="11,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Maroc47 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,18,18,18,18,18"
			y="5,6,7,8,9,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="17,17,18,19,19,20,20,21,21"
			y="3,4,4,5,6,6,7,8,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="21,22"
			y="9,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ruzguz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,27,26,25,24,23"
			y="10,11,11,11,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="29,28,28,27,27,27"
			y="10,10,11,12,13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Janitor has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Ankjell has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,28,28,28,29,29"
			y="9,10,11,12,13,14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="29,30"
			y="15,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Debock has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,30"
			y="15,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="1"
			x="28"
			y="10"
		[/recruit]
		[random]
			value="15578"
		[/random]
		[random]
			value="24653"
		[/random]
		[random]
			value="4495"
		[/random]
		[random]
			value="13604"
		[/random]
		[random]
			value="17864"
		[/random]
		[random]
			value="32100"
		[/random]
		[random]
			value="18155"
		[/random]
		[random]
			value="21104"
		[/random]
		[random]
			value="3074"
		[/random]
		[random]
			value="19865"
		[/random]
		[random]
			value="30174"
		[/random]
		[random]
			value="20004"
		[/random]
		[random]
			value="18813"
			[results]
				checksum="Dem>c1k,fFB3IPKDDy,IIVsrrz9qrFsKPmsAOVOPtQsRHOMGLquuPuNAtBx6AEqpsGOKxE8KFoBPRQNzSIM0NsInAEUrD<pd7wU07l,LsmkMRAyTOtHFLqpFUIIzsxsc"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="a13x has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,27,26"
			y="8,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="What is this tactic's name?"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,9,9,8,8,8"
			y="19,18,17,16,15,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Herco has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="??"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="8,9"
			y="14,14"
		[/move]
	[/command]
	[command]
		[move]
			x="8,9,9,9,10,11,12"
			y="19,19,18,17,16,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Fastrunners&thieves :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="6,7,8,9"
			y="19,20,20,21"
		[/move]
	[/command]
	[command]
		[recruit]
			value="4"
			x="9"
			y="19"
		[/recruit]
		[random]
			value="30887"
		[/random]
		[random]
			value="17996"
		[/random]
		[random]
			value="6447"
		[/random]
		[random]
			value="8198"
		[/random]
		[random]
			value="13360"
		[/random]
		[random]
			value="18451"
		[/random]
		[random]
			value="31737"
		[/random]
		[random]
			value="12169"
		[/random]
		[random]
			value="3389"
		[/random]
		[random]
			value="6244"
		[/random]
		[random]
			value="8666"
		[/random]
		[random]
			value="32170"
		[/random]
		[random]
			value="22223"
		[/random]
		[random]
			value="17936"
		[/random]
		[random]
			value="1775"
			[results]
				checksum="uyqOVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUFLDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcoe3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="7"
			x="8"
			y="19"
		[/recruit]
		[random]
			value="12140"
		[/random]
		[random]
			value="10407"
		[/random]
		[random]
			value="26277"
		[/random]
		[random]
			value="16525"
		[/random]
		[random]
			value="1118"
		[/random]
		[random]
			value="23738"
		[/random]
		[random]
			value="24302"
		[/random]
		[random]
			value="4718"
		[/random]
		[random]
			value="30150"
		[/random]
		[random]
			value="3493"
		[/random]
		[random]
			value="3584"
		[/random]
		[random]
			value="19444"
		[/random]
		[random]
			value="20537"
		[/random]
		[random]
			value="22392"
		[/random]
		[random]
			value="23108"
			[results]
				checksum="96Wmq3.,tb9Th9Xh+8Om3eb898egWbi26k39>2dlaZge0f-9iPif8c7h8k-+v7e7e8fh0c<i8Sem73jI-oaGeRO,h>ybO20xxhh6<5,n30KE4<Yfd6-cbfLq5.ql>pFA"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="HODOR :)"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="irt has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="27,28,28,29,30,30,31,31"
			y="24,23,22,22,21,20,20,19"
		[/move]
	[/command]
	[command]
		[move]
			x="24,25,26,27,27,28"
			y="22,22,21,21,20,19"
		[/move]
	[/command]
	[command]
		[move]
			x="18,18,18,17,16,16,16"
			y="20,19,18,18,17,16,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="El_Sartorio has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="The_Unforgiven has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Hm :) Can't translate it - what does it mean? :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="kuuuu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="nothing... just a name"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,21"
			y="18,18"
		[/move]
	[/command]
	[command]
		[move]
			x="21,22,23"
			y="18,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ridge has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Do you know, why is it so? :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="XimoT has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Soliton has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Masqurin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="LittleD has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="23,23,23,22,22,22"
			y="11,12,13,13,14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="SauR has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="it's the name of a character in a book"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,27,28"
			y="8,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,27"
			y="10,11,12"
		[/move]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="28"
			y="10"
		[/recruit]
		[random]
			value="31015"
		[/random]
		[random]
			value="31985"
		[/random]
		[random]
			value="9044"
		[/random]
		[random]
			value="29655"
		[/random]
		[random]
			value="27772"
		[/random]
		[random]
			value="25715"
		[/random]
		[random]
			value="13702"
		[/random]
		[random]
			value="15188"
		[/random]
		[random]
			value="4869"
		[/random]
		[random]
			value="5141"
		[/random]
		[random]
			value="28207"
		[/random]
		[random]
			value="9969"
		[/random]
		[random]
			value="19116"
		[/random]
		[random]
			value="19426"
		[/random]
		[random]
			value="16315"
			[results]
				checksum="LhGI28qHcsJn9Niqer4mpRo6wD4zsHnKP1Hy+wP.,jg1d-5cL>71745hhbgk5n1,oc<nn6f23854.p5418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmI"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Ortis has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Bane has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="zenit has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Amarant has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="BigSoft has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Bongo has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Masqurin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="I see :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="dur has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Berra has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="xXxJACKxXx has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="tanks has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Aaaa has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="zenit has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Iluxor has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Shu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,27,27,27,28"
			y="14,15,16,17,17"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,27,27,27,27,28"
			y="12,13,14,15,16,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="30,29,28,27"
			y="16,17,17,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="tim has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Morcalavin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Filadeus has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="18,17,16"
			y="10,11,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,21,20,19,18,17"
			y="9,10,10,11,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="12,13,14,15"
			y="11,11,10,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Berra has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="poli has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="15,16"
			y="11,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="innp has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,9,9,9,9,9,9,10"
			y="14,13,12,11,10,9,8,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Patrickz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="SoulFusion has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="16,15,14,14,13,12,12"
			y="15,15,14,13,13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="me has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="sauron has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,9,9,9,10,11,11"
			y="19,18,17,16,15,15,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Hm. You have 25th place... Is it okay that I'm playing with you? Not too boring? ;)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="8,9,9,9,10,10,11"
			y="19,19,18,17,16,15,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Edeon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Krimzon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="no game of Wesnoth is boring :)"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Quy has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message=":)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Okay"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="and I am not as good as my ranking :)"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="12,12,12,11,11,10"
			y="15,14,13,13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="montoto has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="sunwukong has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Patrickz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="25,26,26,27"
			y="19,18,17,17"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="27"
				y="17"
			[/source]
			[destination]
				x="27"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="8805"
			[results]
				chance="40"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5288"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="YOU wanted it yourself, so feel the NOOB'S FURY! :D"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="28,27"
			y="19,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="27"
				y="19"
			[/source]
			[destination]
				x="27"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="3766"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="15295"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="8015"
			[results]
				chance="40"
				damage="10"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="31,31,30,29,28,27,26,25"
			y="19,20,20,20,19,19,19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Janitor has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Attilone has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="23,24,25,26,27,28,29,29"
			y="17,16,16,15,15,14,15,16"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="1"
			weapon="1"
			[source]
				x="29"
				y="16"
			[/source]
			[destination]
				x="28"
				y="16"
			[/destination]
		[/attack]
		[random]
			value="11352"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="8236"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="32551"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29600"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22814"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Ahriman has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="SI has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="7"
			x="9"
			y="19"
		[/recruit]
		[random]
			value="7263"
		[/random]
		[random]
			value="12030"
		[/random]
		[random]
			value="32700"
		[/random]
		[random]
			value="30178"
		[/random]
		[random]
			value="5058"
		[/random]
		[random]
			value="19678"
		[/random]
		[random]
			value="28228"
		[/random]
		[random]
			value="21777"
		[/random]
		[random]
			value="27675"
		[/random]
		[random]
			value="32608"
		[/random]
		[random]
			value="19542"
		[/random]
		[random]
			value="24914"
		[/random]
		[random]
			value="15927"
		[/random]
		[random]
			value="26030"
		[/random]
		[random]
			value="16327"
			[results]
				checksum="c4jbeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh1b<i8Sem73jI-oaGeRO,h0ybO20xxhh6<5-i30KE4<Yfd6-cbeMq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Awia has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,9,9,9,9,9,9"
			y="21,20,19,18,17,16,15"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,23,24,25,26"
			y="15,16,15,16,16"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="26"
				y="16"
			[/source]
			[destination]
				x="27"
				y="17"
			[/destination]
		[/attack]
		[random]
			value="25435"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6890"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="4615"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22407"
			[results]
				chance="50"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="14832"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Nightfal has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Nephworks has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="MaKiro has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Damnation has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="28"
				y="16"
			[/source]
			[destination]
				x="27"
				y="17"
			[/destination]
		[/attack]
		[random]
			value="18777"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="25130"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29395"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="12866"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="19302"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Sonnenwind has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,27"
			y="17,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="27"
				y="18"
			[/source]
			[destination]
				x="27"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="11398"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="27911"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="7931"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="29813"
			[results]
				chance="40"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29057"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="3442"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,28,28,28"
			y="10,11,12,13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[recruit]
			value="0"
			x="28"
			y="10"
		[/recruit]
		[random]
			value="18009"
		[/random]
		[random]
			value="30892"
		[/random]
		[random]
			value="16024"
		[/random]
		[random]
			value="3418"
		[/random]
		[random]
			value="23032"
		[/random]
		[random]
			value="14881"
		[/random]
		[random]
			value="13709"
		[/random]
		[random]
			value="26050"
		[/random]
		[random]
			value="19240"
		[/random]
		[random]
			value="24725"
		[/random]
		[random]
			value="6245"
		[/random]
		[random]
			value="28126"
		[/random]
		[random]
			value="1831"
		[/random]
		[random]
			value="31969"
		[/random]
		[random]
			value="27364"
			[results]
				checksum="LhGI28qHcsJn9Niqer4ntRo6wD4zsHoKP1Hy+wP.,jg1d-5cL>71745hhbgk5n1,oc<nn6f23854.o1418om4H8bFWB0pjc+cZng<m8e6X68+vn>t55bKrqZdmOCaJmI"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="player11 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="wal has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Quetz has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="raphael has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,28,28,27,27,27"
			y="8,9,10,11,12,13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="16,17,18,19,20"
			y="11,12,12,13,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20"
			y="13,14"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="17,18,19,20,20,21,21,22"
			y="11,11,12,12,13,14,15,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Reaper has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="16,16,17,17"
			y="10,11,12,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="17,18,18,19"
			y="13,13,14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="19,20"
			y="15,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="a13x has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="wal has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="paso has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Emperess has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Penis has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="10,11,12,13,13,14,15,16,17"
			y="7,7,6,6,5,4,4,3,3"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="FrakItAll has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="suik has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="12,13,14,15,16,17,18"
			y="11,11,10,10,10,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Gallifax has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="10,11,12,13,14,15"
			y="11,11,10,10,9,9"
		[/move]
	[/command]
	[command]
		[move]
			x="9,10,10,11,11,11,11"
			y="15,14,13,13,12,11,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Pawn has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ego has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="innp has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="9,10,11,12,13,14,15,16"
			y="19,18,18,18,19,19,20,20"
		[/move]
	[/command]
	[command]
		[move]
			x="25,24,23,22,21,20,19"
			y="19,19,20,20,20,19,20"
		[/move]
	[/command]
	[command]
		[move]
			x="27,28"
			y="17,17"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="28"
				y="17"
			[/source]
			[destination]
				x="27"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="18719"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29637"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="29,30,30,30,31,31,31,31,31"
			y="16,16,17,18,19,20,21,22,23"
		[/move]
	[/command]
	[command]
		[move]
			x="27,27,27,27,27,27"
			y="19,20,21,22,23,24"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="zerog has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ixidor474 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="thibaud_ has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="11,12,12,12,12"
			y="15,14,13,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="grrr has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="11,12,13,14,14,14,15"
			y="14,14,15,15,16,17,18"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,29,30,30,29"
			y="14,15,16,16,17,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="29"
				y="18"
			[/source]
			[destination]
				x="28"
				y="17"
			[/destination]
		[/attack]
		[random]
			value="15484"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7422"
			[results]
				chance="60"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="3241"
			[results]
				chance="70"
				damage="12"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="PhoenixDragon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="PRO-CAP has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,26,25"
			y="18,18,19"
		[/move]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="lots of bats!"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Demonhands has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,27,27,27,26,26,27"
			y="14,15,16,17,17,18,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Odol has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,25,24,23,23"
			y="16,17,17,18,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,21,22,22,23"
			y="14,13,13,12,11,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="20,20,20,20,21,21"
			y="15,14,13,12,12,11"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="21,21,21,21,22"
			y="11,10,9,8,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,22,22,22,22,22,22,22,23,23"
			y="15,14,13,12,11,10,9,8,8,7"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="marcon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Merik has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="shannonk has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,28,28,27,26"
			y="10,9,8,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="28,29,30,30,31,31,32"
			y="16,17,17,18,19,20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Kos has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="32,33"
			y="20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Is it bad?"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,16,17,18,18,18"
			y="9,8,8,7,6,5"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="For me I mean :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="17,18"
			y="3,3"
		[/move]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22,22"
			y="3,4,4,5,5,6"
		[/move]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22"
			y="10,10,9,9,8"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="22"
				y="8"
			[/source]
			[destination]
				x="22"
				y="7"
			[/destination]
		[/attack]
		[random]
			value="23472"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="11583"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="22"
				y="6"
			[/source]
			[destination]
				x="22"
				y="7"
			[/destination]
		[/attack]
		[random]
			value="13998"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="18355"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="27,26"
			y="24,23"
		[/move]
	[/command]
	[command]
		[move]
			x="31,30,29,28,27"
			y="23,23,24,24,24"
		[/move]
	[/command]
	[command]
		[move]
			x="26,26,26,25,24,24"
			y="23,22,21,21,20,19"
		[/move]
	[/command]
	[command]
		[move]
			x="16,17,18,19,20,21,22"
			y="20,20,19,19,18,18,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="r3dGoblin has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,16,17,18,19,20,21"
			y="18,18,19,19,20,20,21"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="pikachu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="19,20,21,22,23"
			y="20,19,20,20,20"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="23"
				y="20"
			[/source]
			[destination]
				x="23"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="6245"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6507"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Arrgh - I can't catch them :D"
			side="2"
		[/speak]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="24"
				y="19"
			[/source]
			[destination]
				x="23"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="19542"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="15836"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="18622"
			[results]
				chance="60"
				damage="7"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="2960"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7037"
			[results]
				chance="60"
				damage="7"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="SylHar1 has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="hoho has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Sanzaemon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="war has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="27,26,25,24"
			y="24,23,24,23"
		[/move]
	[/command]
	[command]
		[move]
			x="12,13,14,15,16,17"
			y="11,12,12,13,12,12"
		[/move]
	[/command]
	[command]
		[move]
			x="11,12,12,13"
			y="10,9,8,8"
		[/move]
	[/command]
	[command]
		[recruit]
			value="7"
			x="15"
			y="8"
		[/recruit]
		[random]
			value="16507"
		[/random]
		[random]
			value="14800"
		[/random]
		[random]
			value="21942"
		[/random]
		[random]
			value="32005"
		[/random]
		[random]
			value="7683"
		[/random]
		[random]
			value="7796"
		[/random]
		[random]
			value="14930"
		[/random]
		[random]
			value="30940"
		[/random]
		[random]
			value="2497"
		[/random]
		[random]
			value="10422"
		[/random]
		[random]
			value="29020"
		[/random]
		[random]
			value="6029"
		[/random]
		[random]
			value="4737"
		[/random]
		[random]
			value="20286"
		[/random]
		[random]
			value="28078"
			[results]
				checksum="c4jbeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh1b<i8Sem73jI-oaGeRO,h0ybO20xxhh6<5-i30KE4<Yfd6-cbeMq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="7"
			x="14"
			y="7"
		[/recruit]
		[random]
			value="6411"
		[/random]
		[random]
			value="26469"
		[/random]
		[random]
			value="27526"
		[/random]
		[random]
			value="4808"
		[/random]
		[random]
			value="16003"
		[/random]
		[random]
			value="24955"
		[/random]
		[random]
			value="9742"
		[/random]
		[random]
			value="12309"
		[/random]
		[random]
			value="10797"
		[/random]
		[random]
			value="21775"
		[/random]
		[random]
			value="9178"
		[/random]
		[random]
			value="14418"
		[/random]
		[random]
			value="27341"
		[/random]
		[random]
			value="27749"
		[/random]
		[random]
			value="8818"
			[results]
				checksum="c4jbeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh1b<i8Sem73jI-oaGeRO,h0ybO20xxhh6<5-i30KE4<Yfd6-cbeMq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Luminara has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Mist has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[recruit]
			value="4"
			x="13"
			y="7"
		[/recruit]
		[random]
			value="11744"
		[/random]
		[random]
			value="15548"
		[/random]
		[random]
			value="28100"
		[/random]
		[random]
			value="19462"
		[/random]
		[random]
			value="32419"
		[/random]
		[random]
			value="23120"
		[/random]
		[random]
			value="6566"
		[/random]
		[random]
			value="7615"
		[/random]
		[random]
			value="24468"
		[/random]
		[random]
			value="12899"
		[/random]
		[random]
			value="10495"
		[/random]
		[random]
			value="4162"
		[/random]
		[random]
			value="28837"
		[/random]
		[random]
			value="26282"
		[/random]
		[random]
			value="29180"
			[results]
				checksum="FTxBwyUzhyBkwVHKQOq5AMPytSNtRJzMRsDuHBtnQvBFyQAVsL8qJTmQQNRqrWuTuTxCUFMDPxfDLuyOdqNHp2JuaZJrXGikJwc0bkdie+c.P93obZj,mcoh3b,IXl32"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="13,12,11,10"
			y="8,7,8,7"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26"
			y="19,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="29,28,27,26,25"
			y="18,18,19,18,19"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="25"
				y="19"
			[/source]
			[destination]
				x="24"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="3960"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22420"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="33,32,31,30,29,28,28,27"
			y="20,20,21,21,22,22,23,24"
		[/move]
	[/command]
	[command]
		sent="yes"
		[move]
			x="23,23,23"
			y="11,10,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="23"
				y="9"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="28443"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6739"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19836"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23091"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,25,24,23"
			y="8,8,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="23"
				y="8"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="186"
			[results]
				chance="70"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="26318"
			[results]
				chance="50"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="26945"
			[results]
				chance="70"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="592"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Anu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="tempodimaggio has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="7"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="3763"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="28215"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="19146"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="16460"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="23,24,24,24,23,22"
			y="7,7,8,9,10,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="9"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="9389"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="25749"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="9355"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7895"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Hirgwath_ has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="your play is not bad"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="26,26,25,24"
			y="19,18,18,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="24"
				y="18"
			[/source]
			[destination]
				x="24"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="15649"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10917"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="17462"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="748"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6183"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14595"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="although you are a bit unlucky :-/"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,26,26,25,24"
			y="19,19,20,21,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="24"
				y="20"
			[/source]
			[destination]
				x="23"
				y="20"
			[/destination]
		[/attack]
		[random]
			value="26702"
			[results]
				chance="40"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12662"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="31218"
			[results]
				chance="40"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="16196"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10158"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="10803"
			[results]
				chance="40"
				damage="10"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="15870"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Why? :) I mean - not bad :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="21,22,23,24"
			y="21,21,22,21"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="24"
				y="21"
			[/source]
			[destination]
				x="24"
				y="20"
			[/destination]
		[/attack]
		[random]
			value="15445"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="5505"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Griffonstone has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Thorkay has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="23,23"
			y="20,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="23"
				y="19"
			[/source]
			[destination]
				x="24"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="25210"
			[results]
				chance="50"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="30897"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="22,22,23,24"
			y="18,17,17,17"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="24"
				y="17"
			[/source]
			[destination]
				x="24"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="29359"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="30888"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1094"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="13967"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="28432"
			[results]
				chance="50"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12203"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="24"
				y="19"
			[/source]
			[destination]
				x="24"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="5539"
			[results]
				chance="50"
				damage="5"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[choose]
			value="0"
		[/choose]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="becenev has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="BuBu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="22,21"
			y="8,9"
		[/move]
	[/command]
	[command]
		[move]
			x="18,19,20,21,21,22"
			y="5,6,6,7,8,8"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="8"
			[/source]
			[destination]
				x="22"
				y="7"
			[/destination]
		[/attack]
		[random]
			value="28934"
			[results]
				chance="40"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22145"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="13647"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="17849"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="26281"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="22"
				y="6"
			[/source]
			[destination]
				x="22"
				y="7"
			[/destination]
		[/attack]
		[random]
			value="21216"
			[results]
				chance="40"
				damage="5"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="21,20,20,20,19,18"
			y="9,8,7,6,6,5"
		[/move]
	[/command]
	[command]
		[move]
			x="13,14,15,16,17,18,19,20"
			y="7,7,8,8,8,8,9,9"
		[/move]
	[/command]
	[command]
		[move]
			x="17,18,19,20,21,22,23"
			y="12,11,12,12,12,11,11"
		[/move]
	[/command]
	[command]
		[move]
			x="15,16,17,18,19,20,21,22"
			y="8,8,8,7,8,7,7,7"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="22"
				y="7"
			[/source]
			[destination]
				x="23"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="32476"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="30847"
			[results]
				chance="50"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="12996"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="14,15,16,17,17,18"
			y="7,8,8,9,10,10"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Lexxmar-rus has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="10,11,12,13"
			y="7,8,7,8"
		[/move]
	[/command]
	[command]
		[recruit]
			value="4"
			x="15"
			y="8"
		[/recruit]
		[random]
			value="27934"
		[/random]
		[random]
			value="28255"
		[/random]
		[random]
			value="3406"
		[/random]
		[random]
			value="2147"
		[/random]
		[random]
			value="4013"
		[/random]
		[random]
			value="20387"
		[/random]
		[random]
			value="4083"
		[/random]
		[random]
			value="2397"
		[/random]
		[random]
			value="32064"
		[/random]
		[random]
			value="5027"
		[/random]
		[random]
			value="777"
		[/random]
		[random]
			value="17173"
		[/random]
		[random]
			value="9832"
		[/random]
		[random]
			value="26491"
		[/random]
		[random]
			value="8910"
			[results]
				checksum="FTxBwyUzhyBkwVHKQOq5AMPytSNtRJzMRsDuHBtnQvBFyQAVsL8qJTmQQNRqrWuTuTxCUFLDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcoe3b,IXl32"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="7"
			x="14"
			y="7"
		[/recruit]
		[random]
			value="3739"
		[/random]
		[random]
			value="16948"
		[/random]
		[random]
			value="10378"
		[/random]
		[random]
			value="13204"
		[/random]
		[random]
			value="21509"
		[/random]
		[random]
			value="31478"
		[/random]
		[random]
			value="18054"
		[/random]
		[random]
			value="22302"
		[/random]
		[random]
			value="28205"
		[/random]
		[random]
			value="9840"
		[/random]
		[random]
			value="15750"
		[/random]
		[random]
			value="20501"
		[/random]
		[random]
			value="2721"
		[/random]
		[random]
			value="22342"
		[/random]
		[random]
			value="17325"
			[results]
				checksum="c4ibeoBjPXdN9277b82>Vg,h+ld6d5,0c<W-1<71YYc5-d+8873Gj8ibkh8k-+v7e7e8fh19<i8Sem73jI-oaGeRO,h>ybO20xxhh6<5-i30KE4<Yfd6-cbeOq5.ql>p"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="TromboneStar has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="13,12,11,10"
			y="8,7,8,7"
		[/move]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Godofmyth has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="I don't know, how to fight against it :) :D"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="1"
			weapon="0"
			[source]
				x="25"
				y="19"
			[/source]
			[destination]
				x="24"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="2831"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="31600"
			[results]
				chance="40"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="14505"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="15087"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7207"
			[results]
				chance="40"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="24,25"
			y="20,20"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="25"
				y="20"
			[/source]
			[destination]
				x="24"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="28737"
			[results]
				chance="40"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="29647"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="30585"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22092"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="20162"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="19319"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="9250"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="7891"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Boucman has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="it's hard to fight on big maps like this"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="27,27,27,27,27,26,26,25"
			y="24,23,22,21,20,19,18,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="25"
				y="18"
			[/source]
			[destination]
				x="24"
				y="17"
			[/destination]
		[/attack]
		[random]
			value="17148"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14678"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="21329"
			[results]
				chance="40"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="you should try it out sometime"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Monkkiller has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="buy lots of footpads and thieves"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="23"
				y="8"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="29111"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="6415"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="23"
				y="9"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="21646"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="7665"
			[results]
				chance="70"
				damage="8"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[move]
			x="22,22"
			y="9,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="dragonatic has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="and be sure to shout ""HODOR""! from time to time"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message=":D"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Okay - I will ;)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="24,24"
			y="17,18"
		[/move]
	[/command]
	[command]
		[move]
			x="24,24,25,26,26"
			y="19,20,21,20,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="26"
				y="19"
			[/source]
			[destination]
				x="25"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="8263"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="1269"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="31690"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="24"
				y="18"
			[/source]
			[destination]
				x="25"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="1932"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="8941"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="8212"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="24,23,23,24"
			y="21,21,20,19"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="24"
				y="19"
			[/source]
			[destination]
				x="25"
				y="20"
			[/destination]
		[/attack]
		[random]
			value="22146"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21573"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="24,25,26,26,26"
			y="23,23,22,21,20"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="26"
				y="20"
			[/source]
			[destination]
				x="25"
				y="20"
			[/destination]
		[/attack]
		[random]
			value="7882"
			[results]
				chance="60"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="3657"
			[results]
				chance="60"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="23,23,23,23,24,25,26,27"
			y="19,20,21,22,22,23,23,24"
		[/move]
	[/command]
	[command]
		[move]
			x="23,24,25,25,24"
			y="11,10,10,9,8"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="24"
				y="8"
			[/source]
			[destination]
				x="23"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="14943"
			[results]
				chance="50"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22932"
			[results]
				chance="50"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="23313"
			[results]
				chance="50"
				damage="8"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="LakeBass has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Thanks for playing & shoving new tactic :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22,23"
			y="10,10,10,11,10,10"
		[/move]
	[/command]
	[command]
		[move]
			x="22,23"
			y="7,8"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="23"
				y="8"
			[/source]
			[destination]
				x="23"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="32207"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21859"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14900"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="23"
				y="10"
			[/source]
			[destination]
				x="23"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="20391"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="25250"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="977"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="An dnew map ;)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="cRiS_tO has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="ego has logged into the lobby"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="yes, the first time I lost to this tactic, I was undead too"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="15,16,17,18,19,20,21"
			y="8,8,8,8,9,8,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="21"
				y="9"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="14331"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22790"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Yan has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="22,22,21,21,22"
			y="6,7,8,9,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="22"
				y="9"
			[/source]
			[destination]
				x="23"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="30203"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1602"
			[results]
				chance="40"
				damage="5"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="18,19,20,21,22"
			y="5,6,6,7,7"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="22"
				y="7"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="26077"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="18199"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Spyro has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="20,21,22,23,24,24"
			y="9,10,10,11,10,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="24"
				y="9"
			[/source]
			[destination]
				x="23"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="30367"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22087"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		[move]
			x="14,15,16,17,18,19,20"
			y="7,8,8,8,8,9,9"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="It's a fate :D"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="haha"
			side="1"
		[/speak]
	[/command]
	[command]
		[move]
			x="10,11,12,13"
			y="7,8,7,8"
		[/move]
	[/command]
	[command]
		[recruit]
			value="7"
			x="15"
			y="8"
		[/recruit]
		[random]
			value="9704"
		[/random]
		[random]
			value="18483"
		[/random]
		[random]
			value="32500"
		[/random]
		[random]
			value="21240"
		[/random]
		[random]
			value="14978"
		[/random]
		[random]
			value="13263"
		[/random]
		[random]
			value="26647"
		[/random]
		[random]
			value="6884"
		[/random]
		[random]
			value="17150"
		[/random]
		[random]
			value="15070"
		[/random]
		[random]
			value="11683"
		[/random]
		[random]
			value="1363"
		[/random]
		[random]
			value="28859"
		[/random]
		[random]
			value="4047"
		[/random]
		[random]
			value="9372"
			[results]
				checksum="96Wmq3.,tb9Th9Xh+8Om3eb898egWbi26k39>2dlaZge0f-9iPif8c7h8k-+v7e7e8fh0c<i8Sem73jI-oaGeRO,h>ybO20xxhh6<5,n30KE4<Yfd6-cbfLq5.ql>pFA"
			[/results]
		[/random]
	[/command]
	[command]
		[recruit]
			value="4"
			x="14"
			y="7"
		[/recruit]
		[random]
			value="19029"
		[/random]
		[random]
			value="10783"
		[/random]
		[random]
			value="23952"
		[/random]
		[random]
			value="21500"
		[/random]
		[random]
			value="25327"
		[/random]
		[random]
			value="12839"
		[/random]
		[random]
			value="6202"
		[/random]
		[random]
			value="21243"
		[/random]
		[random]
			value="25399"
		[/random]
		[random]
			value="6839"
		[/random]
		[random]
			value="32396"
		[/random]
		[random]
			value="11072"
		[/random]
		[random]
			value="30457"
		[/random]
		[random]
			value="20224"
		[/random]
		[random]
			value="17220"
			[results]
				checksum="uyqNVzDO<ExdHrVAAKrGB6qDQPwqLuEDUSNIMADRBGxxpOFSryqC1rOBpDQNRqrWuTuTxCUEQDPxfDLuyOdqNHp2JuaZMrXGikJwc0bkdib+c.P93obZj,mcpd3b,IXl"
			[/results]
		[/random]
	[/command]
	[command]
		[countdown_update]
			team="1"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Sanzaemon has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[move]
			x="25,26"
			y="18,18"
		[/move]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="26"
				y="18"
			[/source]
			[destination]
				x="26"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="1226"
			[results]
				chance="40"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21036"
			[results]
				chance="50"
				damage="2"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="24198"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="16086"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="11568"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="31667"
			[results]
				chance="50"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="25"
				y="19"
			[/source]
			[destination]
				x="24"
				y="18"
			[/destination]
		[/attack]
		[random]
			value="7769"
			[results]
				chance="70"
				damage="8"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="25"
				y="20"
			[/source]
			[destination]
				x="26"
				y="19"
			[/destination]
		[/attack]
		[random]
			value="5766"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="21336"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="21479"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="32445"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="22898"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="27728"
			[results]
				chance="60"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="27707"
			[results]
				chance="40"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="26465"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="if you could get your leader to that keep, we'd have a good game on our hands"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="BuBu has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="23"
				y="9"
			[/source]
			[destination]
				x="23"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="26768"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="28559"
			[results]
				chance="70"
				damage="8"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="MicroStar has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[attack]
			defender_weapon="0"
			weapon="0"
			[source]
				x="22"
				y="8"
			[/source]
			[destination]
				x="23"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="11813"
			[results]
				chance="30"
				damage="4"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="11382"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="14348"
			[results]
				chance="30"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="30557"
			[results]
				chance="40"
				damage="0"
				dies="no"
				hits="no"
			[/results]
		[/random]
		[random]
			value="22736"
			[results]
				chance="40"
				damage="3"
				dies="no"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[countdown_update]
			team="2"
			value="330000"
		[/countdown_update]
	[/command]
	[command]
		sent="yes"
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[end_turn]
		[/end_turn]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="0"
			[source]
				x="24"
				y="8"
			[/source]
			[destination]
				x="23"
				y="9"
			[/destination]
		[/attack]
		[random]
			value="13618"
			[results]
				chance="40"
				damage="10"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="n00bie has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[move]
			x="23,24,25,26"
			y="8,7,8,8"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="But I couldn't :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="24,23"
			y="9,9"
		[/move]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="23"
				y="9"
			[/source]
			[destination]
				x="22"
				y="8"
			[/destination]
		[/attack]
		[random]
			value="4505"
			[results]
				chance="40"
				damage="6"
				dies="no"
				hits="yes"
			[/results]
		[/random]
		[random]
			value="1914"
			[results]
				chance="40"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Too much fat guys :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="22,21,21,21,22,23"
			y="7,8,9,10,10,11"
		[/move]
	[/command]
	[command]
		[move]
			x="22,23,24,25,25,26,27,27,27"
			y="9,10,10,11,12,12,13,14,15"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="*fast :)"
			side="2"
		[/speak]
	[/command]
	[command]
		[move]
			x="21,21,21,21,21,22,22"
			y="9,10,11,12,13,13,14"
		[/move]
	[/command]
	[command]
		[move]
			x="23,24,25,25,26,27,27"
			y="10,10,11,12,12,13,14"
		[/move]
	[/command]
	[command]
		[move]
			x="20,20,21,22,22,23"
			y="9,10,11,11,12,13"
		[/move]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="Thanks again. & see you. :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Brall has logged into the lobby"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="on big maps, speed is very important"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="fortune has logged into the lobby"
		[/speak]
	[/command]
	[command]
		[attack]
			defender_weapon="-1"
			weapon="1"
			[source]
				x="26"
				y="20"
			[/source]
			[destination]
				x="25"
				y="20"
			[/destination]
		[/attack]
		[random]
			value="24004"
			[results]
				chance="60"
				damage="6"
				dies="yes"
				hits="yes"
			[/results]
		[/random]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="see you :)"
			side="1"
		[/speak]
	[/command]
	[command]
		undo="no"
		[speak]
			id="donkey_noob_trash"
			message="thanks for the game"
			side="1"
		[/speak]
	[/command]
	[command]
		sent="yes"
		undo="no"
		[speak]
			id="Den"
			message="U2 :)"
			side="2"
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="Den has left the game."
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="donkey_noob_trash takes control of side 2."
		[/speak]
	[/command]
	[command]
		sent="yes"
		[speak]
			id="server"
			message="donkey_noob_trash droids side 2."
		[/speak]
	[/command]
[/replay]
[snapshot]
[/snapshot]
[replay_start]
	current_tod="0"
#textdomain wesnoth-multiplayer
	description=_ "Flooded by the seas and battered by the winter elements, only ruins, water and ice now remain in the shadow of this once mighty empire."
	experience_modifier="70"
	hash="w0,+cAGFJ4mpQeLfM2okH4xJDZ,RHeHQMes8mkISo7Bb+0Jues<4aL3g7BRs93fxsSspDSy<lgboL.,AGypa0LE37KgRjKO.96Itvo2y51,oID3kluarbDjiIcfhR2US"
	id="multiplayer_Sullas_Ruins"
	map_data="border_size=1
usage=map

_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _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          , Gs^Fet      , Hh          , Hh          , Gs          , Gs          , Rd          , Mm^Vhh      , 2 Ke        , Gs^Fp       , Ce          , Gs^Fp       , Wwf         , Mm          , Gs^Fet      , Gs^Fp       , Gs          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Hh          , Mm          , Gs          , Gs          , Rd          , Ce          , Ke          , Ce          , Rd          , Gs          , Gs          , Ce          , Ce          , Wwf         , Ke          , Hh          , Ce          , Hh          , Rd          , Rd          , 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         , Gs          , Wwf         , Gs^Fet      , Gs          , Rd          , Hh          , Rd          , Gs^Fp       , Mm          , Gs^Fp       , Rd          , Gs^Vht      , Gs          , Wwf         , Wwf         , Wwf         , Ce          , Wwf         , Ce          , Ce          , Gs          , Wwf         , Wwf         , Gs          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs^Fp       , Hh          , Gs          , Wwf         , Chw         , Wwf         , Wwf         , Mm          , Gs          , Gs          , Ww          , Ww          , Ww          , Hh          , Wwf         , Wwf         , Rd          , Gs^Fp       , Gs          , Wwf         , Gs          , Wwf         , Wwf         , Wwf         , Mm          , Gs^Fp       , Gs          , Gs^Fet      , Hh          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Mm          , Gs          , Gs          , Gs          , Rr          , Gs          , Gs          , Gs^Vht      , Wwf         , Wwf         , Chw         , Chr         , Wo          , Ww          , Mm          , Wwf         , Hh          , Gs          , Rd          , Ss^Vhs      , Gs          , Rd          , Gs          , Gs          , Gs          , Gs          , Hh          , Gs          , Gs          , Wwf         , Mm          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs^Fp       , Rd          , Gs          , Gs          , Gs          , Gs          , Rd          , Hh          , Rr          , Wwf         , Khr         , Rr          , Chw         , Wwf         , Wwf         , Gs          , Gs          , Gs          , Rd          , Gs^Fp       , Hh          , Rd          , Gs          , Ss^Vhs      , Gs          , Khr         , Gs          , Gs          , Wwf         , Gs^Fp       , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs          , Chw         , Rd          , Gs          , Gs          , Mm          , Rd          , Gs          , Gs          , Gs          , Wwf         , Wwf         , Wwf         , Ww          , Ww          , Gs          , Gs          , Gs          , Gs          , Hh          , Mm          , Gs          , Ww          , Wo          , Ww          , Chw         , Wwf         , Wwf         , Wwf         , Gs^Fp       , Hh          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Hh          , Gs          , Gs          , Wwf         , Rr          , Wwf         , Gs          , Wwf         , Rr          , Gs          , Gs^Fp       , Gs          , Gs          , Ww          , Gs          , Ss^Vhs      , Gs^Fp       , Chw         , Gs          , Gs          , Gs          , Wwf         , Ww          , Ww          , Ww          , Chw         , Chw         , Gs          , Gs          , Gs          , Gs          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs          , Gs          , Gs          , Rr          , Wo          , Wo          , Chw         , Chw         , Wwf         , Gs^Vht      , Gs          , Gs          , Ww          , Gs          , Gs          , Gs          , Hh          , Gs          , Chw         , Gs          , Gs^Vht      , Gs^Fp       , Wwf         , Gs          , Wwf         , Wwf         , Rr          , Gs          , Gs          , Mm          , Wo          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Mm          , Hh          , Gs          , Gs          , Wwf         , Gs          , Rr          , Mm          , Gs          , Gs          , Gs^Fp       , Gs          , Ww          , Wwf         , Wwf         , Wwf         , Gs          , Rr          , Gs          , Gs          , Gs          , Wwf         , Wwf         , Gs          , Gs          , Gs^Fet      , Wwf         , Wwf         , Gs          , Wwf         , Hh          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Hh          , Gs^Fp       , Gs          , Gs          , Gs          , Gs^Fp       , Gs          , Gs          , Rd          , Rd          , Gs          , Wwf         , Wwf         , Ai          , Aa^Fpa      , Chw         , Wwf         , Wwf         , Rr          , Wwf         , Wwf         , Mm          , Hh          , Gs^Fp       , Rd          , Rd          , Hh          , Gs          , Wwf         , Gs^Fp       , Wwf         , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Wo          , Chw         , Gs          , Gs          , Gs          , Gs          , Gs^Fet      , Gs          , Hh          , Rd          , Hh          , Wwf         , Aa          , Aa^Fpa      , Ha          , Aa^Fpa      , Ai          , Wwf         , Wo          , Gs          , Gs^Fp       , Rd          , Gs          , Rd          , Chw         , Chw         , Rd          , Gs          , Gs          , Rr          , Hh          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Mm          , Rr          , Gs          , Gs          , Gs          , Rr          , Gs          , Chw         , Chw         , Chw         , Gs          , Chw         , Wwf         , Ha          , Ms          , Khr         , Ha          , Ha          , Wwf         , Chw         , Gs          , Chw         , Chw         , Rd          , Rd          , Gs          , Rd          , Gs          , Gs          , Hh          , Mm          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs^Fet      , Gs          , Gs          , Gs          , Rr          , Chw         , Rd          , Rd          , Rd          , Rd          , Gs          , Gs          , Wwf         , Wwf         , Ha          , Aa^Fpa      , Ms          , Aa^Fpa      , Wwf         , Wwf         , Gs          , Rd          , Rd          , Hh          , Gs          , Gs^Fp       , Gs          , Gs          , Gs          , Gs^Fet      , Wo          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Wwf         , Wwf         , Wwf         , Gs^Fp       , Hh          , Chw         , Gs          , Hh          , Mm          , Gs^Fp       , Wwf         , Wo          , Wwf         , Ai          , Chw         , Ha          , Ai          , Aa          , Wwf         , Hh          , Rd          , Hh          , Wwf         , Rd          , Hh          , Gs          , Gs          , Gs          , Rd          , Chw         , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Hh          , Gs          , Gs          , Gs          , Wwf         , Wwf         , Gs          , Wwf         , Wwf         , Wwf         , Wwf         , Gs          , Rr          , Rr          , Wwf         , Wwf         , Aa^Fpa      , Wwf         , Wwf         , Gs          , Rd          , Gs^Fp       , Gs          , Wwf         , Mm          , Wwf         , Gs          , Wwf         , Rr          , Gs          , Rd          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Wo          , Rd          , Gs^Fp       , Gs^Vht      , Gs          , Chw         , Chw         , Ww          , Ww          , Ww          , Gs          , Gs          , Gs          , Gs          , Gs          , Gs          , Wwf         , Gs          , Ww          , Gs          , Rd          , Rd          , Gs^Vht      , Gs          , Chw         , Chw         , Wo          , Wo          , Wwf         , Rr          , Gs          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs          , Hh          , Rd          , Gs          , Gs          , Rr          , Chw         , Ww          , Wo          , Ww          , Wwf         , Gs          , Chw         , Chw         , Hh          , Ss^Vhs      , Gs          , Ww          , Ww          , Gs          , Gs          , Rd          , Rd          , Gs          , Rr          , Gs^Fet      , Gs          , Gs          , Rr          , Chw         , Gs^Fp       , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Mm          , Gs^Fp       , Gs          , Gs          , Gs          , Gs          , Khr         , Wwf         , Ss^Vhs      , Gs          , Gs          , Gs          , Gs          , Gs          , Gs^Fp       , Gs          , Gs          , Ww          , Gs          , Gs^Fp       , Gs          , Gs^Fp       , Rd          , Rd          , Gs          , Mm          , Gs^Fp       , Gs          , Gs          , Gs          , Gs          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Wwf         , Wwf         , Gs          , Wwf         , Wwf         , Wwf         , Wwf         , Rr          , Gs          , Mm          , Hh          , Gs^Fp       , Mm          , Gs          , Gs          , Gs          , Wwf         , Wwf         , Ww          , Wwf         , Wwf         , Wwf         , Hh          , Gs          , Rd          , Gs          , Gs          , Gs          , Gs          , Gs^Fp       , Hh          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Gs          , Rr          , Wwf         , Gs          , Gs          , Gs          , Rr          , Gs          , Gs          , Gs          , Hh          , Ss^Vhs      , Rd          , Rd          , Gs          , Wwf         , Wwf         , Gs^Fp       , Wwf         , Chw         , Rr          , Khr         , Wwf         , Wwf         , Hh          , Gs          , Gs          , Gs          , Gs          , Gs          , Gs^Fp       , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Hh          , Gs^Fet      , Rr          , Gs          , Gs          , Gs          , Rr          , Chw         , Gs          , Gs^Fp       , Gs          , Rd          , Rd          , Hh          , Mm          , Wwf         , Hh          , Ww          , Ww          , Wo          , Chr         , Chw         , Rr          , Wwf         , Gs^Vht      , Gs          , Gs          , Wwf         , Gs          , Hh          , Hh          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , Mm          , Gs^Fp       , Gs          , Gs          , Gs          , Wwf         , Gs          , Wwf         , Ww          , Wwf         , Hh          , Wwf         , Gs          , Gs          , Wwf         , Gs^Vht      , Hh          , Gs          , Ww          , Ww          , Ww          , Gs          , Mm          , Gs          , Wwf         , Wwf         , Wwf         , Gs          , Wwf         , Wwf         , Mm          , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs          , Wwf         , Wwf         , Hh          , Wwf         , Gs^Fp       , Gs          , Gs          , Wwf         , Gs          , Wwf         , Wwf         , Wwf         , Gs^Fp       , Gs          , Rd          , Mm          , Gs          , Gs^Fp       , Gs          , Hh          , Gs          , Gs          , Hh          , Gs          , Gs          , Gs          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Mm          , Hh          , Rd          , Rd          , Gs          , Rd          , Mm          , Hh          , Ke          , Wwf         , Gs          , Gs          , Gs          , Gs          , Rd          , Gs          , Ke          , Gs          , Gs          , Hh          , Rd          , Mm          , 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   , _off^_usr   , _off^_usr   , Mm          , Gs^Fp       , Rd          , Ce          , Ce          , Ce          , Ce          , Wwf         , Mm          , Ce          , 1 Ke        , Ce          , Mm^Vhh      , Hh          , Ce          , Ce          , Rd          , Gs^Fp       , 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   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , Gs^Fet      , _off^_usr   , Gs^Fp       , _off^_usr   , Wwf         , _off^_usr   , Hh          , _off^_usr   , Gs^Fet      , _off^_usr   , Gs^Fp       , _off^_usr   , Mm          , _off^_usr   , Rd          , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   
_off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _off^_usr   , _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="13"
	mp_countdown_init_time="330"
	mp_countdown_reservoir_time="330"
	mp_countdown_turn_bonus="300"
	mp_fog="yes"
	mp_shroud="no"
	mp_use_map_settings="yes"
	mp_village_gold="2"
	name=_ "2p - Sulla's Ruins"
	next_underlying_unit_id="0"
#textdomain wesnoth
	objectives=_ "Victory:
@Defeat enemy leader(s)"
	observer="yes"
	random_seed="6088"
	random_start_time="no"
	scenario="ladder game"
	turns="-1"
	version="1.6"
	[time]
		green="-20"
		id="dawn"
		image="misc/schedule-dawn.png"
		name=_ "Dawn"
		red="-20"
		sound="ambient/morning.ogg"
	[/time]
	[time]
		id="morning"
		image="misc/schedule-morning.png"
		lawful_bonus="25"
		name=_ "Morning"
	[/time]
	[time]
		id="afternoon"
		image="misc/schedule-afternoon.png"
		lawful_bonus="25"
		name=_ "Afternoon"
	[/time]
	[time]
		blue="-20"
		green="-20"
		id="dusk"
		image="misc/schedule-dusk.png"
		name=_ "Dusk"
		sound="ambient/night.ogg"
	[/time]
	[time]
		blue="-10"
		green="-40"
		id="first_watch"
		image="misc/schedule-firstwatch.png"
		lawful_bonus="-25"
		name=_ "First Watch"
		red="-40"
	[/time]
	[time]
		blue="-10"
		green="-40"
		id="second_watch"
		image="misc/schedule-secondwatch.png"
		lawful_bonus="-25"
		name=_ "Second Watch"
		red="-40"
	[/time]
	[music]
		ms_before="12000"
		name="knolls.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="wanderer.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="battle.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="transience.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_king_is_dead.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="knalgan_theme.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_city_falls.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="nunc_dimittis.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="revelation.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="loyalists.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="breaking_the_chains.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="elvish-theme.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="legends_of_the_north.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="traveling_minstrels.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="underground.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="vengeful.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="frantic.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_dangerous_symphony.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="heroes_rite.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="suspense.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="the_deep_path.ogg"
	[/music]
	[music]
		append="yes"
		ms_before="12000"
		name="siege_of_laurelmor.ogg"
	[/music]
	[event]
		name="prestart"
		[music]
			ms_before="12000"
			name="knolls.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="wanderer.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="battle.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="transience.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="revelation.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="loyalists.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_king_is_dead.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="knalgan_theme.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_city_falls.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="nunc_dimittis.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="breaking_the_chains.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="elvish-theme.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="legends_of_the_north.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="traveling_minstrels.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="underground.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="vengeful.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="frantic.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_dangerous_symphony.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="heroes_rite.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="suspense.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="the_deep_path.ogg"
		[/music]
		[music]
			append="yes"
			ms_before="12000"
			name="siege_of_laurelmor.ogg"
		[/music]
	[/event]
	[era]
		id="era_default"
#textdomain wesnoth-multiplayer
		name=_ "Default"
		[multiplayer_side]
			flag_rgb="magenta"
			id="Random"
			image="units/random-dice.png"
			name=_ "Random"
			random_faction="yes"
		[/multiplayer_side]
		[multiplayer_side]
			flag_rgb="magenta"
			id="Loyalists"
			image="units/human-loyalists/lieutenant.png"
			leader="Lieutenant,Swordsman,Pikeman,Javelineer,Shock Trooper,Longbowman,White Mage,Red Mage"
			name=_ "Loyalists"
			random_leader="Lieutenant,Swordsman,Pikeman,Javelineer,Longbowman,Red Mage"
			recruit="Cavalryman,Horseman,Spearman,Fencer,Heavy Infantryman,Bowman,Mage,Merman Fighter"
			terrain_liked="Gg, Ww, Wo"
			type="Lieutenant"
			[ai]
				recruitment_pattern="fighter,fighter,fighter,archer,mixed fighter,scout"
				[team_formula]
					rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

faiend
"
				[/team_formula]
			[/ai]
		[/multiplayer_side]
		[event]
			name="prestart"
			[store_unit]
				kill="yes"
				variable="leaders_to_make_quick"
				[filter]
					canrecruit="yes"
					[filter_wml]
						max_moves="4"
					[/filter_wml]
				[/filter]
			[/store_unit]
			[set_variable]
				name="i"
				value="0"
			[/set_variable]
			[while]
				[variable]
					less_than="$leaders_to_make_quick.length"
					name="i"
				[/variable]
				[do]
					[set_variables]
						mode="merge"
						name="leaders_to_make_quick[$i].modifications"
						[literal]
							[trait]
#textdomain wesnoth
								female_name=_ "female^quick"
								id="quick"
								male_name=_ "quick"
								[effect]
									apply_to="movement"
									increase="1"
								[/effect]
								[effect]
									apply_to="hitpoints"
									increase_total="-5%"
								[/effect]
							[/trait]
						[/literal]
					[/set_variables]
					[clear_variable]
						name="leaders_to_make_quick[$i].max_moves,leaders_to_make_quick[$i].moves,leaders_to_make_quick[$i].max_hitpoints,leaders_to_make_quick[$i].hitpoints"
					[/clear_variable]
					[unstore_unit]
						variable="leaders_to_make_quick[$i]"
					[/unstore_unit]
					[set_variable]
						add="1"
						name="i"
					[/set_variable]
				[/do]
			[/while]
			[clear_variable]
				name="i"
			[/clear_variable]
			[clear_variable]
				name="leaders_to_make_quick"
			[/clear_variable]
		[/event]
	[/era]
	[side]
		allow_changes="yes"
		allow_player="yes"
		canrecruit="yes"
		colour="1"
		controller="human"
		current_player="donkey_noob_trash"
		flag_rgb="magenta"
		fog="yes"
		gender="female"
		gold="100"
		id="donkey_noob_trash1"
		image="units/dwarves/steelclad.png"
		income="0"
		leader="Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Stalwart,Rogue,Trapper"
		mp_countdown="yes"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="330"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="300"
		name="donkey_noob_trash"
		random_leader="Dwarvish Steelclad,Dwarvish Thunderguard,Rogue,Trapper"
		recruit="Dwarvish Guardsman,Dwarvish Fighter,Dwarvish Ulfserker,Dwarvish Thunderer,Thief,Poacher,Footpad,Gryphon Rider"
		save_id="donkey_noob_trash1"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="1"
		team_name="south"
		terrain_liked="Hh, Ha, Mm"
		type="Rogue"
		user_team_name="wesnoth-multiplayerteamname^South"
		village_gold="2"
		[ai]
			recruitment_pattern="fighter,fighter,fighter,mixed fighter,archer,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="Den"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		id="Den2"
		image="units/undead-necromancers/dark-sorcerer.png"
		income="0"
		leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter,Necrophage"
		mp_countdown="yes"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="330"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="300"
		name="Den"
		random_leader="Dark Sorcerer,Revenant,Deathblade,Bone Shooter"
		recruit="Skeleton,Skeleton Archer,Walking Corpse,Ghost,Vampire Bat,Dark Adept,Ghoul"
		save_id="Den2"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="2"
		team_name="north"
		terrain_liked="Ss, Hh, Ha, Ww"
		type="Deathblade"
		user_team_name="wesnoth-multiplayerteamname^North"
		village_gold="2"
		[ai]
			recruitment_pattern="fighter,fighter,archer,fighter,scout,archer"
			villages_per_scout="8"
			[team_formula]
				rulebase="fai 'recruitment.fai'
		# ===== Some general functions used later ==== #

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

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

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

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

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

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

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

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

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

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

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

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

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

#returns average defense of the unit #

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

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

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

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


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


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

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

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

# ==2== based on village possession #

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

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

# multipled by 1000 to increase precision #

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

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

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

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

#==1==  basic evaluation #

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

faiend
"
			[/team_formula]
		[/ai]
		[ai]
			villages_per_scout="8"
		[/ai]
	[/side]
	[side]
		allow_changes="yes"
		allow_player="no"
		canrecruit="no"
		colour="5"
		controller="ai"
		flag_rgb="magenta"
		fog="yes"
		gender="male"
		gold="100"
		hidden="yes"
		id="ai3"
		image="units/dwarves/steelclad.png"
		income="0"
		leader="Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Stalwart,Rogue,Trapper"
		mp_countdown="yes"
		mp_countdown_action_bonus="13"
		mp_countdown_init_time="330"
		mp_countdown_reservoir_time="330"
		mp_countdown_turn_bonus="300"
		name=_ "Computer player"
		no_leader="yes"
		random_leader="Dwarvish Steelclad,Dwarvish Thunderguard,Rogue,Trapper"
		recruit="Dwarvish Guardsman,Dwarvish Fighter,Dwarvish Ulfserker,Dwarvish Thunderer,Thief,Poacher,Footpad,Gryphon Rider"
		save_id="ai3"
		share_maps="no"
		share_view="yes"
		shroud="no"
		side="3"
		team_name="statues"
		terrain_liked="Hh, Ha, Mm"
		type="Dwarvish Thunderguard"
		user_team_name="statues"
		village_gold="2"
		[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]
		[unit]
#textdomain wesnoth-multiplayer
			description=_ "A stone-carved likeness of Sulla the Great, also known as Sulla the Just, Sulla the Tyrant, Empress of the Sinking Tower, Lady of the Walking Glacier, Sulla the Incinerator, Sulla the Proud and Sulla the Righteous."
			facing="se"
			gender="female"
			name="`~`" + 
				_ "Statue of Sulla"
			random_traits="no"
			type="Great Mage"
			unrenamable="yes"
			x="18"
			y="15"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					description=_ "This is a sculpture made of stone."
					id="remove_hp"
					name=_ "statue"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "A stone-carved likeness of Lhun-dup, Servant of Sulla."
			facing="sw"
			name="`~`" + 
				_ "Statue of Lhun-dup"
			random_traits="no"
			type="Yeti"
			unrenamable="yes"
			x="20"
			y="11"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					description=_ "This is a sculpture made of stone."
					id="remove_hp"
					name=_ "statue"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "A stone-carved likeness of Ri-nzen, Servant of Sulla."
			facing="sw"
			name="`~`" + 
				_ "Statue of Ri-nzen"
			random_traits="no"
			type="Yeti"
			unrenamable="yes"
			x="23"
			y="15"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					description=_ "This is a sculpture made of stone."
					id="remove_hp"
					name=_ "statue"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "A stone-carved likeness of Ten-zin, Servant of Sulla."
			facing="se"
			name="`~`" + 
				_ "Statue of Ten-zin"
			random_traits="no"
			type="Yeti"
			unrenamable="yes"
			x="13"
			y="16"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					description=_ "This is a sculpture made of stone."
					id="remove_hp"
					name=_ "statue"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
		[unit]
			description=_ "A stone-carved likeness of Lo-bsang, Servant of Sulla."
			facing="se"
			name="`~`" + 
				_ "Statue of Lo-bsang"
			random_traits="no"
			type="Yeti"
			unrenamable="yes"
			x="16"
			y="19"
			[status]
				stoned="on"
			[/status]
			[modifications]
				[trait]
					description=_ "This is a sculpture made of stone."
					id="remove_hp"
					name=_ "statue"
					[effect]
						apply_to="hitpoints"
						increase_total="-100%"
					[/effect]
					[effect]
						apply_to="movement"
						set="0"
					[/effect]
				[/trait]
			[/modifications]
		[/unit]
	[/side]
[/replay_start]
[statistics]
	mid_scenario="yes"
	[scenario]
		scenario="2p - Sulla's Ruins"
		[team]
			[recruits]
				Dark Adept="3"
				Ghost="1"
				Ghoul="2"
				Vampire Bat="3"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
				Dark Adept="2"
				Deathblade="1"
				Ghoul="2"
				Vampire Bat="3"
			[/deaths]
			[killed]
				Footpad="1"
				Thief="2"
			[/killed]
			[attacks]
				[sequence]
					s00="2"
					s000="1"
					s10="1"
					_num="30"
				[/sequence]
				[sequence]
					s000="1"
					s00010="1"
					s001="2"
					s100="1"
					s10000="1"
					s11010="1"
					s111="1"
					_num="40"
				[/sequence]
				[sequence]
					s01="2"
					s1="1"
					s11="6"
					_num="70"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="23"
					_num="0"
				[/sequence]
				[sequence]
					s0="1"
					s00="1"
					_num="30"
				[/sequence]
				[sequence]
					s="1"
					s001="1"
					s10="1"
					s111="1"
					_num="40"
				[/sequence]
			[/defends]
			recruit_cost="139"
			recall_cost="0"
			damage_inflicted="224"
			damage_taken="247"
			expected_damage_inflicted="177574"
			expected_damage_taken="218854"
			turn_damage_inflicted="38"
			turn_damage_taken="31"
			turn_expected_damage_inflicted="36507"
			turn_expected_damage_taken="22443"
			save_id="Den2"
		[/team]
		[team]
			[recruits]
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
			[/advances]
			[deaths]
			[/deaths]
			[killed]
			[/killed]
			[attacks]
			[/attacks]
			[defends]
			[/defends]
			recruit_cost="0"
			recall_cost="0"
			damage_inflicted="0"
			damage_taken="0"
			expected_damage_inflicted="0"
			expected_damage_taken="0"
			turn_damage_inflicted="0"
			turn_damage_taken="0"
			turn_expected_damage_inflicted="0"
			turn_expected_damage_taken="0"
			save_id="ai3"
		[/team]
		[team]
			[recruits]
				Footpad="9"
				Thief="8"
			[/recruits]
			[recalls]
			[/recalls]
			[advances]
				Rogue="1"
			[/advances]
			[deaths]
				Footpad="1"
				Thief="2"
			[/deaths]
			[killed]
				Dark Adept="2"
				Deathblade="1"
				Ghoul="2"
				Vampire Bat="3"
			[/killed]
			[attacks]
				[sequence]
					s00="4"
					s000="2"
					s01="1"
					s1="2"
					s10="2"
					s100="1"
					s101="2"
					s11="3"
					_num="40"
				[/sequence]
				[sequence]
					s00="1"
					s001="1"
					s010="1"
					s1="1"
					s10="1"
					s111="1"
					_num="50"
				[/sequence]
				[sequence]
					s01="1"
					s1="1"
					s10="1"
					s11="2"
					s111="1"
					_num="60"
				[/sequence]
			[/attacks]
			[defends]
				[sequence]
					s="6"
					_num="0"
				[/sequence]
				[sequence]
					s00="1"
					s001="1"
					s10="2"
					s101="1"
					s110="1"
					_num="40"
				[/sequence]
				[sequence]
					s01="1"
					s10="2"
					s100="1"
					s110="1"
					_num="50"
				[/sequence]
				[sequence]
					s00="1"
					s1="1"
					s101="1"
					s111="1"
					_num="60"
				[/sequence]
			[/defends]
			recruit_cost="230"
			recall_cost="0"
			damage_inflicted="247"
			damage_taken="224"
			expected_damage_inflicted="218854"
			expected_damage_taken="177574"
			turn_damage_inflicted="19"
			turn_damage_taken="0"
			turn_expected_damage_inflicted="12384"
			turn_expected_damage_taken="0"
			save_id="donkey_noob_trash1"
		[/team]
	[/scenario]
[/statistics]
