The week­end was great! We couldn’t have asked for bet­ter weather, but I could have asked for more sun­screen. We ended up hav­ing 5 teams for the annual tour­na­ment. Iron­i­cally, the ran­dom pair­ings by my pro­gram pro­duced three repeat pair­ings from last year, but that’s life. My lit­tlest sis­ter wasn’t par­tak­ing but wanted to enter in the scores. She jumped the gun in the first round and updated the scores before all the games had been com­pleted in the round so only one team got a win while every­one else received a loss and the two teams that weren’t fin­ish received zero points. Since the teams were ran­domly paired, I pan­iced for a minute think­ing we might have to back to keep­ing score by hand because I had no idea how to repro­duce the teams if we restarted. After a deep breath, it was really just a 30 sec­ond fix:

The teams are formed by “pop­ping” the last ele­ment of the play­ers array into the team array.

teams[i][1] = players.pop(); // team­mate 1
teams[i][2] = players.pop(); // team­mate 2

Obvi­ously the play­ers array is ran­dom­ized by this line:

players.sort( ran­dOrd ); // ran­dom­ize players

So to restart the script and make sure the teams stayed the same, I first wrote down the play­ers names in a reverse list on a piece of paper (play­ers from Team 1 were on the bot­tom of the list … play­ers from Team 5 were on the top of the list). Then, I com­mented out the line that ran­dom­ized the play­ers and entered the player names in the order I had my list (play­ers for Team 5 were entered first … play­ers for Team 1 were entered last).

This recre­ated the teams we had orig­i­nally and we were able to con­tinue the tour­na­ment with­out any other interup­tions. The tour­ney did end with two teams tied with the same record and same num­ber of points so we had to go to the sud­den death play­off but instead of one hand they wanted to play an entire game. My brother and aunt won it all while my grand­mother and I came in last place (but we had the most fun).