module TK.SpaceTac.Specs { class FixedPlan extends AIPlan { constructor(score: number) { super(); this.score = score; } } testing("AbstractAI", test => { test.acase("keeps track of the best produced plan so far", async check => { const battle = new Battle(); const ai = new AbstractAI(battle, battle.fleets[0].player); ai.timer = Timer.synchronous; const producer = (...scores: number[]) => imap(iarray(scores), score => new FixedPlan(score)); check.patch(ai, "getPlanProducer", () => producer(1, -8, 4, 3, 7, 0, 6, 1)); check.patch(ai, "getPlanScoring", () => (plan: AIPlan) => (plan instanceof FixedPlan) ? plan.score : -Infinity); await ai.play(); const played = await ai.getPlan(); check.equals(played.score, 7); }); }); }