题目的意思在于,更高效的Collect Gold;然后合理的安排生产出来的士兵;
// This code runs once per frame. Build units and command peasants!// Destroy the ogre base within 180 seconds.// Run over 4000 statements per call and chooseAction will run less often.// Check out the green Guide button at the top for more info.var base = this;/// 1. Command peasants to grab coins and gems. ///// You can only command peasants, not fighting units.// You win by gathering gold more efficiently to make a larger army.// Click on a unit to see its API.var i1=0,i2=0,i3=0,i4=0;var n;var j=0;//对所有的钱分类排序的时候使用的var items = base.getItems();var item=null;var peasants = base.getByType('peasant');var tempItems=items;//缓存,用来记录宝石和金银币铜币 for(var i=0;i=peasants.length)//宝石的数量>=捡钱兵种的数量 { for(i=0;i =peasants.length)//宝石的数量+金币的数量>=捡钱兵种的数量 { for(i=0;i =peasants.length)//宝石、金币、银币的数量>=捡钱兵种的数量 { for(i=0;i = base.buildables[type].goldCost) base.build(type);// 'peasant': Peasants gather gold and do not fight.// 'soldier': Light melee unit.// 'knight': Heavy melee unit.// 'librarian': Support spellcaster.// 'griffin-rider': High-damage ranged attacker.// 'captain': Mythically expensive super melee unit.// See the buildables documentation below for costs and the guide for stats.