(It is recommended that you write your code in a separate text editor, then copy-paste it here.)
(This does not submit your player to the tournament we're planning on having.)
Here is an example that just pops the first button it sees:
function userGetMove(poppingBalloonsPosition) {
var option = poppingBalloonsPosition.clone();
var numColumns = option.getWidth();
var numRows = option.getHeight();
for (var columnIndex = 0; columnIndex < numColumns; columnIndex++) {
for (var rowIndex = 0; rowIndex < numRows; rowIndex++) {
if (option.columns[columnIndex][rowIndex]) {
//there is an unpopped balloon at columns[columnIndex][rowIndex]
option.columns[columnIndex][rowIndex] = false;
return option;
}
}
}
console.log("Error: didn't find an unpopped balloon. Returning null.");
return null;
}
Popping Balloons is an impartial combinatorial game played on a rectangular array of balloons. On their turn, the current player chooses to pop some balloons. They can either pop any single balloon, or two adjacent balloons, or all balloons (2, 3, or 4) in a 2x2 square. We have a page where you can manually play Popping Balloons.
We are holding a computer player tournament as part of Sprouts 2022. People can use this to test their players. Instructions to submit a player are below.
I think 10x10 is pretty good, and 15 games seems to work pretty well.
The positions start with some balloons automatically popped, so they won't always be symmetric. I do think a symmetry player would fare pretty well, though. Submit it!
We'll need players to run efficiently. For the actual conference tournament, if we run this with a bunch of contestants at the same time as we're running Zoom, it will get bogged down quickly. (And Kyle's laptop is not very powerful.) Please make sure your player takes their turn in less than 4 seconds on a 10x10 board on your own machine. (If your machine isn't too overpowered, that should equate to about 10 seconds on my laptop.) If specific players are running too long, we'll have to exclude them from the tournament. (If you disagree with these rules, feel free to talk to me.)
Check out the instructions below. (After this EFAQ.)
Keep watching this space, or watch @CGTKyle (Twitter) for updates.
Oh yeah. I got it working, but I definitely need to clean it up. Please don't tell my software engineering students! I'll refactor it when I have time (famous last words).
If you get a player working as above, you'll need to make a few changes to get it working for the actual Sprouts tournament.
//author: <Your name or your team's name>, yourcontactemail@example.com
var <YourPlayerName> = Class.create(ComputerPlayer, {
initialize: function() {
//nothing needed here.
},
givePosition: function(playerIndex, position, referee) {
referee.moveTo(this.userGetMove(position));
},
userGetMove: function(poppingBalloonsPosition) {
//paste your code in here.
},
getName: function() {
return "<YourPlayerName>";
},
getAuthor: function() {
return "<Your name or your team's name>";
}
});