Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Created October 10, 2020 13:15
Show Gist options
  • Save MCarlomagno/d72052a28787797d3412739645f1c084 to your computer and use it in GitHub Desktop.
Save MCarlomagno/d72052a28787797d3412739645f1c084 to your computer and use it in GitHub Desktop.
var playGame = async function () {
var subzeroIndex = 0;
var kanoIndex = 1;
startGame();
var state = getState(subzeroIndex);
// while both fighters keep alive.
while (state.myLife !== 0 && state.opponentLife !== 0) {
state = getState(subzeroIndex);
// they get closer until they are close enough to hit each other (x_distance < 60)
if (state.opponentPosition.x - state.myPosition.x < 60) {
dispatchAction(subzeroActions.HK);
dispatchAction(kanoActions.HK);
} else {
dispatchAction(subzeroActions.RIGHT);
dispatchAction(kanoActions.LEFT);
}
// every step in the game has 200ms duration
await sleep(200);
}
console.log('ROUND FINISHED');
console.log(state);
}
playGame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment