30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
module TK.SpaceTac.Specs {
|
|
testing("AIProducerTools", test => {
|
|
test.case("produces random moves", check => {
|
|
const battle = new Battle();
|
|
const ship = battle.fleets[0].addShip();
|
|
const engine = TestTools.addEngine(ship, 250);
|
|
|
|
const planning = new TurnPlanning(battle, ship.getPlayer());
|
|
|
|
check.in("random=0", check => {
|
|
AIProducerTools.addMove(planning, ship, engine, new SkewedRandomGenerator([0], true));
|
|
const plan = planning.getShipPlan(ship);
|
|
check.equals(plan.actions.length, 1);
|
|
check.equals(plan.actions[0].action, engine.id);
|
|
check.nears(nn(plan.actions[0].distance), engine.min_distance);
|
|
check.nears(nn(plan.actions[0].angle), 0);
|
|
});
|
|
|
|
check.in("random=1", check => {
|
|
AIProducerTools.addMove(planning, ship, engine, new SkewedRandomGenerator([1], true));
|
|
const plan = planning.getShipPlan(ship);
|
|
check.equals(plan.actions.length, 1);
|
|
check.equals(plan.actions[0].action, engine.id);
|
|
check.nears(nn(plan.actions[0].distance), 250);
|
|
check.nears(nn(plan.actions[0].angle), Math.PI * 2);
|
|
});
|
|
});
|
|
});
|
|
}
|