predictor/source/Movements.js
2018-05-21 08:12:29 +03:00

24 lines
632 B
JavaScript

export default class Movements {
humanMovements = [];
robotMovements = [];
constructor(human = [], robot = []) {
this.humanMovements = human;
this.robotMovements = robot;
}
makeHumanMove(value) {
this.humanMovements.push(value === 1 ? value : 0);
}
makeRobotMove(value) {
this.robotMovements.push(value === 1 ? value : 0);
}
getLastMovements(humanCount, robotCount) {
const humanSlice = this.humanMovements.slice(-humanCount);
const robotSlice = this.robotMovements.slice(-robotCount);
return [].concat(robotSlice, humanSlice);
}
}