Skip to content

Instantly share code, notes, and snippets.

@NotBobTheBuilder
Last active October 8, 2015 18:57
Show Gist options
  • Save NotBobTheBuilder/f55e5588348c60254ca0 to your computer and use it in GitHub Desktop.
Save NotBobTheBuilder/f55e5588348c60254ca0 to your computer and use it in GitHub Desktop.
Rock-Paper-Scissors bot samples
var opponentName;
var nextHand = 'paper';
function init(opponent) {
opponentName = opponent;
}
function play() {
return nextHand;
}
function result(data) {
nextHand = data[opponentName];
}
var dynamiteCount = 5;
function init(opponent) {
}
function play() {
if (dynamiteCount > 0) {
dynamiteCount--;
return 'dynamite';
} else {
return 'paper';
}
}
function result() {
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="botfile.js"></script>
</head>
<body>
</body>
</html>
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