1
0
Fork 0
spacetac/src/core/ai/ContinuousAI.spec.ts

23 lines
770 B
TypeScript

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