Created
October 10, 2020 13:15
-
-
Save MCarlomagno/d72052a28787797d3412739645f1c084 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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