Write more tests
This commit is contained in:
17
tests/PredictorTest.ts
Normal file
17
tests/PredictorTest.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import Predictor from '../src/Predictor';
|
||||
|
||||
describe('Predictor', function() {
|
||||
it('Get prediction for one daemon state', function() {
|
||||
const predictor = new Predictor({
|
||||
base: 2,
|
||||
supervisor_epsilon: 0.01,
|
||||
daemons: [{ robot: 1, human: 1, epsilon: 0.01 }],
|
||||
});
|
||||
const predicted = predictor.pass(1);
|
||||
expect(predicted).to.equals(0);
|
||||
expect(predictor.stepCount()).to.equals(1);
|
||||
});
|
||||
});
|
30
tests/SupervisorTest.ts
Normal file
30
tests/SupervisorTest.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import Supervisor from '../src/Supervisor';
|
||||
import Daemon from '../src/Daemon';
|
||||
import Journal from '../src/Journal';
|
||||
|
||||
describe('Supervisor', function() {
|
||||
it('Get prediction for one daemon state', function() {
|
||||
const supervisor = new Supervisor([new Daemon(2, 1, 1, 0.01)], 0.01);
|
||||
const journal = new Journal();
|
||||
|
||||
const human1 = 1;
|
||||
const predicted1 = supervisor.predict(journal);
|
||||
expect(0).to.equals(predicted1, 'First prediction for empty journal');
|
||||
|
||||
journal.makeMove(human1, predicted1);
|
||||
supervisor.adjust(journal, human1);
|
||||
|
||||
const human2 = 1;
|
||||
const predicted2 = supervisor.predict(journal);
|
||||
expect(1).to.equals(
|
||||
predicted2,
|
||||
`Second prediction for (${human1}, ${predicted1})`
|
||||
);
|
||||
|
||||
journal.makeMove(human2, predicted1);
|
||||
supervisor.adjust(journal, human2);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user