MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / compareRobots

Function compareRobots

code/solutions/07_1_measuring_a_robot.js:10–19  ·  view source on GitHub ↗
(robot1, memory1, robot2, memory2)

Source from the content-addressed store, hash-verified

8}
9
10function compareRobots(robot1, memory1, robot2, memory2) {
11 let total1 = 0, total2 = 0;
12 for (let i = 0; i < 100; i++) {
13 let state = VillageState.random();
14 total1 += countSteps(state, robot1, memory1);
15 total2 += countSteps(state, robot2, memory2);
16 }
17 console.log(`Robot 1 needed ${total1 / 100} steps per task`)
18 console.log(`Robot 2 needed ${total2 / 100}`)
19}
20
21compareRobots(routeRobot, [], goalOrientedRobot, []);

Callers 1

Calls 1

countStepsFunction · 0.85

Tested by

no test coverage detected