Last active
October 8, 2015 18:57
-
-
Save NotBobTheBuilder/f55e5588348c60254ca0 to your computer and use it in GitHub Desktop.
Rock-Paper-Scissors bot samples
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
var opponentName; | |
var nextHand = 'paper'; | |
function init(opponent) { | |
opponentName = opponent; | |
} | |
function play() { | |
return nextHand; | |
} | |
function result(data) { | |
nextHand = data[opponentName]; | |
} |
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
var dynamiteCount = 5; | |
function init(opponent) { | |
} | |
function play() { | |
if (dynamiteCount > 0) { | |
dynamiteCount--; | |
return 'dynamite'; | |
} else { | |
return 'paper'; | |
} | |
} | |
function result() { | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<script src="botfile.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
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
function init(opponent) { | |
// Runs once at the beginning of the game | |
// Only parameter is the name of your opponent as a String | |
} | |
function play() { | |
// Run for once for each of the 50 rounds in a game | |
// Takes no parameters | |
// Return 'rock', 'paper', 'scissors', 'water' or 'dynamite' | |
return 'paper'; | |
} | |
function result(data) { | |
// run after both bots have played their hands | |
// property 'winner' is the string name of the winning bot | |
// has a key for each bot containing the hand they played. | |
// EG: { | |
// 'winner': 'bot1', | |
// 'bot1': 'rock', | |
// 'bot2': 'scissors' | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment