Add history for predictor moves

This commit is contained in:
2020-03-22 14:38:05 +03:00
parent 9e06a1c630
commit 49bb3da4bb
6 changed files with 108 additions and 31 deletions

View File

@ -3,23 +3,32 @@ import { expect } from 'chai';
import Daemon from '../src/Daemon';
import Journal from '../src/Journal';
import Move from '../src/Move';
describe('Daemon', function() {
it('Get prediction for beginning', function() {
const journal = new Journal();
const daemon = new Daemon(2, 1, 1);
const predicted = daemon.predict(journal);
expect(predicted).to.equals(0);
const daemon = new Daemon('d1', 2, 1, 1);
expect('d1').to.equals(daemon.id);
const predicted = daemon.predict(new Journal());
expect(0).to.equals(predicted);
});
it('Can get power', function() {
const d = new Daemon(2, 5, 8);
expect(d.power).to.eqls(13);
const d = new Daemon('d1', 2, 5, 8);
expect(13).to.eqls(d.power);
});
it('Can adjust', function() {
const journal = new Journal([new Move(0, 0), new Move(0, 0)]);
const daemon = new Daemon('d1', 2, 1, 1, 0.1);
daemon.adjust(journal, 1);
expect({ '0:0:1': 1.1 ** 2 }).to.eqls(daemon.getWeights());
});
it('Daemon 1-1', function() {
const journal = new Journal();
const daemon = new Daemon(2, 1, 1, 0.1);
const daemon = new Daemon('d1', 2, 1, 1, 0.1);
const steps = [
{

View File

@ -7,7 +7,10 @@ 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 supervisor = new Supervisor(
[new Daemon('d1', 2, 1, 1, 0.1)],
0.1
);
const journal = new Journal();
const human1 = 1;
@ -26,5 +29,7 @@ describe('Supervisor', function() {
journal.makeMove(human2, predicted1);
supervisor.adjust(journal, human2);
expect({ d1: 1.1 ** 2 }).to.eqls(supervisor.rates());
});
});