()
| 91 | } |
| 92 | |
| 93 | tick() { |
| 94 | let {direction, memory} = this.robot(this.worldState, this.robotState) |
| 95 | this.worldState = this.worldState.move(direction) |
| 96 | this.robotState = memory |
| 97 | this.turn++ |
| 98 | this.updateView() |
| 99 | if (this.worldState.parcels.length == 0) { |
| 100 | this.button.remove() |
| 101 | this.text.textContent = ` Finished after ${this.turn} turns` |
| 102 | this.robotElt.firstChild.src = this.imgPath + "robot_idle2x.png" |
| 103 | } else { |
| 104 | this.schedule() |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | schedule() { |
| 109 | this.timeout = setTimeout(() => this.tick(), 1000 / speed) |
no test coverage detected