Housie Board
I made this mini app during those lockdown days of 2020, fun and tiny. I remember that during my childhood, Housie used to be played late at night in our neighbourhood during Diwali festival time. When we were all inside due to lockdown, we played a number of board and card games, including housie. I had an old housie ticket book, initially I was using online boards to pick numbers, but got annoyed very fast with ads, so decided to build something local!
The app generates the complete sequency at the start of the game, which makes use of a worker thread to create a shuffled array using Fisher-Yates shuffle for proper randomness, and then just spits out numbers sequentially from the array when requested, since the array lives in worker memory. Which would be a good approach for an online game, but maybe, a bit overkill for my use case. The algorithm for generating the sequence isn’t that difficult actually -
Fisher-Yates shuffle
- Iterate from the last element (n-1) down to the first 1.
- In each step, generate a random index (j) between 0 and the current index (i), inclusive.
- Swap the element at the current index (i) with the element at the random index (j).
- Repeat until the array is fully traversed.
which becomes something like this -
function shuffle(array) {
var currentIndex = array.length,
temporaryValue,
randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
I made the game, slapped a random wallpaper I had for background, and put it on my home raspberry pi server, so it could be accessed with any device on home network. The game doesn’t have any extra bells and whistles, just number generation and reset; it’s just enough to enjoy a social game of housie / tambola with group.
Click to see demo or play housie / tambola 🎉