Created
July 28, 2021 08:10
-
-
Save yitonghe00/786146a238020d68827017fc80e877c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
countSteps = (state, robot, memory) => { | |
for (let turn = 0;; turn++) { | |
if (state.parcels.length == 0) { | |
return turn; | |
} | |
let action = robot(state, memory); | |
state = state.move(action.direction); | |
memory = action.memory; | |
} | |
} | |
function compareRobots(robot1, memory1, robot2, memory2) { | |
// Your code here | |
let steps1 = 0, steps2 = 0; | |
for (let i = 0; i < 100; i++) { | |
const task = VillageState.random(); | |
steps1 += countSteps(task, robot1, memory1); | |
steps2 += countSteps(task, robot2, memory2); | |
} | |
console.log(`Robot1 usually takes ${steps1 / 100} steps`); | |
console.log(`Robot2 usually takes ${steps2 / 100} steps`); | |
} | |
compareRobots(routeRobot, [], goalOrientedRobot, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment