|
-
Sep 2nd, 2020, 08:18 PM
#1
Thread Starter
Junior Member
"Housie" Bingo card generator
Hey guys!
I'm having real difficulties writing an application to generate "Housie" Bingo cards. A "Housie" bingo card is used in the UK, and is different to the US Bingo card.
The rules that must be followed when creating a "Housie" Bingo card are as follows:
Code:
1. Each ticket comprises of 3 rows of 9 columns (totaling 27 boxes)
2. Each row must contain 5 numbers
3. No numbers can be repeated
4. Each column has a specified range of numbers (e.g. column 1 will contain numbers 1-9, column 2 will contain number 10-19, and so on, until you get to column 9 which will contain numbers 80-90)
5. No column can be completely blank over the 3 rows (e.g. column 5 rows 1 & 3 can be empty, but it then must have a number in row 2)
6. All 90 numbers will be used over 6 tickets (but only once)
I've tried using datatables, jagged arrays, multidimension, arrays List(Of), etc etc. And all my code has been garbage.
I've searched Google and Youtube extensively and all the results are either for the US Bingo, or written in C/C#/C++ or Java and I cannot understand a single line of that.
Has anyone got an idea, or knows where I can find something to get me started please?
Sorry, I don't have any code because it was literally just trying For Loops and that got me nowhere, it either didn't follow the rules (because I don't know how to implement them) or just hung when debugging.
-
Sep 2nd, 2020, 09:06 PM
#2
Re: "Housie" Bingo card generator
The first step is to stop trying to write code when you don't know what the code has to do. Solve the problem first, then write code to implement the solution. Start by doing it by hand. If you can do it by hand then you can work out what the steps are to do it and then you can write code to implement those steps. It's not always easy to go from just doing it to a formal algorithm because human beings are great at using "fuzzy logic" but that is the actual challenge you have to overcome. Start by just doing it however feels right. Then do it again and again and put some thought into how exactly you're doing it. What actions are you repeating and what decisions are you making? Detail and formalise the steps you perform until you have them to the point that you could hand them to a child with no prior knowledge of the problem and they could follow them to get the right result. Once you're at that stage, you have a working algorithm and THEN you can think about writing code specifically to implement that algorithm. If you have a problem in doing that then you can tell us exactly what step of the algorithm you are having issues with, exactly what you expect to happen and exactly what does happen.
-
Sep 2nd, 2020, 09:51 PM
#3
Re: "Housie" Bingo card generator
If your wanting to write this for fun, or just to be able to print a few off, then fine. But if your trying to do this to save money, it won't. Unless you have free paper or ink. If you look online the price is cheap. The reason I know is because I told my son I'd print cards for his club, I'd just got a new colored laser printer. After I did the math, I just bought him 750 cards. lol
-
Sep 2nd, 2020, 10:34 PM
#4
Re: "Housie" Bingo card generator
Yeah, I think I would try to break it down into steps, figuring out which rule should be easiest to accomplish first, and then which is easiest second, and so on.
For instance, you know you want to use each of the 90 numbers once across the six tickets, so you need a list of the numbers available, so you can remove it once you've used it, so you won't choose it again.
I think since each column has to have at least one number, that would be the first thing I would populate, i.e. for each column pick a random number from the list for that column, and place it in one of the three rows, randomly.
So, now you should have one number in each column in some random row.
Secondly, you need five numbers in each row, so now check to see if each row has 5 numbers. If they all have less than 5, you're in good shape. If one has more than five, then pick one of the extra values at random and move it to one of the other rows. Once you have 5 or less in each row, you just need to pick a row that is short, choose one one of the columns at random that has an empty spot in that row, and fill it with a random selection from the list for that column. Do the same with the other row that is short.
Or you could try to be more efficient.
You could just try to evenly distribute the numbers from the start, i.e. For the first column, pick one of three rows and place a random number in that row. Then for the second column, choose one of the two rows that doesn't have a number in it yet, and put a random number in that row, then for the third column place a random number in the remaining row. Then repeat for the 4,5, and 6, and again for the 7,8 and 9.
Now you have selected 9 numbers, and each column contains 1, and each row contains 3.
Now you just have to select two numbers for each row from the six columns that don't have numbers in them on that row, and put a number in them, and you're done.
I guess there is a bit more to it than that. You could choose the same random column of the six remaining more often than the others, so run out of numbers for a given column before you make it through all six cards,
So, for the first row you would choose two columns out of the six available.
Second row, choose two out of the four columns remaining.
Third row, choose a random number to put in the two columns left.
That should give you an even distribution of all the numbers over all the columns and rows over six cards.
If you can understand what I've said, then it should be fairly easy to work out the code.
Last edited by passel; Sep 2nd, 2020 at 10:45 PM.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 3rd, 2020, 04:04 AM
#5
Thread Starter
Junior Member
Re: "Housie" Bingo card generator
 Originally Posted by jmcilhinney
The first step is to stop trying to write code when you don't know what the code has to do. Solve the problem first, then write code to implement the solution. Start by doing it by hand. If you can do it by hand then you can work out what the steps are to do it and then you can write code to implement those steps. It's not always easy to go from just doing it to a formal algorithm because human beings are great at using "fuzzy logic" but that is the actual challenge you have to overcome. Start by just doing it however feels right. Then do it again and again and put some thought into how exactly you're doing it. What actions are you repeating and what decisions are you making? Detail and formalise the steps you perform until you have them to the point that you could hand them to a child with no prior knowledge of the problem and they could follow them to get the right result. Once you're at that stage, you have a working algorithm and THEN you can think about writing code specifically to implement that algorithm. If you have a problem in doing that then you can tell us exactly what step of the algorithm you are having issues with, exactly what you expect to happen and exactly what does happen.
As always, the voice of reason!
In terms of working it out I would go row by row to assign the 5 values, making sure to use all columns at least once.
The part where each column holds a specific range, I think won't be difficult to implement. It's just creating the grid of 15 valid "cells" within it
 Originally Posted by wes4dbt
If your wanting to write this for fun, or just to be able to print a few off, then fine. But if your trying to do this to save money, it won't. Unless you have free paper or ink. If you look online the price is cheap. The reason I know is because I told my son I'd print cards for his club, I'd just got a new colored laser printer. After I did the math, I just bought him 750 cards. lol
I'm literally just trying to accomplish it because in theory it's easy to understand, but in practice I'm finding it impossible to implement. But, my local boozer is just starting to get into running a bingo night, so it would be good to knock something together where they could print their own branded tickets - I'm currently building them a piece of calling software that's branded specifically for them so they can have it on the TVs in the pub. They can get their head office to do any printing etc - but for now, like I say it's just an exercise in trying to implement the logic
 Originally Posted by passel
Yeah, I think I would try to break it down into steps, figuring out which rule should be easiest to accomplish first, and then which is easiest second, and so on.
For instance, you know you want to use each of the 90 numbers once across the six tickets, so you need a list of the numbers available, so you can remove it once you've used it, so you won't choose it again.
I think since each column has to have at least one number, that would be the first thing I would populate, i.e. for each column pick a random number from the list for that column, and place it in one of the three rows, randomly.
So, now you should have one number in each column in some random row.
Secondly, you need five numbers in each row, so now check to see if each row has 5 numbers. If they all have less than 5, you're in good shape. If one has more than five, then pick one of the extra values at random and move it to one of the other rows. Once you have 5 or less in each row, you just need to pick a row that is short, choose one one of the columns at random that has an empty spot in that row, and fill it with a random selection from the list for that column. Do the same with the other row that is short.
Or you could try to be more efficient.
You could just try to evenly distribute the numbers from the start, i.e. For the first column, pick one of three rows and place a random number in that row. Then for the second column, choose one of the two rows that doesn't have a number in it yet, and put a random number in that row, then for the third column place a random number in the remaining row. Then repeat for the 4,5, and 6, and again for the 7,8 and 9.
Now you have selected 9 numbers, and each column contains 1, and each row contains 3.
Now you just have to select two numbers for each row from the six columns that don't have numbers in them on that row, and put a number in them, and you're done.
I guess there is a bit more to it than that. You could choose the same random column of the six remaining more often than the others, so run out of numbers for a given column before you make it through all six cards,
So, for the first row you would choose two columns out of the six available.
Second row, choose two out of the four columns remaining.
Third row, choose a random number to put in the two columns left.
That should give you an even distribution of all the numbers over all the columns and rows over six cards.
If you can understand what I've said, then it should be fairly easy to work out the code.
I understand your theory. The only issue I think with it is that each row having EXACTLY 5 numbers per row and at least 1 in each column in each ticket carry the same priority.
-
Sep 3rd, 2020, 02:17 PM
#6
Re: "Housie" Bingo card generator
Yeah, and the later supposition should take care of that easily. The first pass though you end up with one in each column and three in each row.
You've distributed nine numbers at this point. You have six more to distribute, two in each row, so the second pass is to do that, so now you've met the at least one in each column, and five in each row.
The trick is to make sure you continue to distribute the numbers in an even manner, so you don't run out of numbers that go in a column before you reach the last card.
For instance, assuming the distribution of numbers you mentioned is correct you only have nine numbers for the first column so you know you can't put two numbers from the first columns numbers on each card, that would require 12 numbers. So you will place one number on each card in the first column, which will use up six of your numbers. Three of the cards will have a second number. The total number of rows you're choosing from is 18, so you're distributing 9 numbers into those 18 rows.
For the middle eight columns, you have 10 numbers to distribute into those 18 rows, and the last column you have 11 numbers to distribute across the 18 rows.
It seems if you keep track of what row you put a number in, and don't use that same row again until you've distributed numbers to the other rows, it should work out, i.e. you can't put two many numbers in a given row or column, and the five numbers per row will fall out naturally.
I don't know. If I get interested enough, I might try to code up something for the fun of it, but I don't see it happening right away. Perhaps if I'm looking for something to do over the long labor day weekend coming up (I have Fri and Monday off, without taking any vacation, so its a five day weekend).
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 5th, 2020, 05:59 AM
#7
Re: "Housie" Bingo card generator
I've written a Bingo card generator before, but in Java...
http://www.scproject.biz/99_Java_Examples.php (contest 97)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|