|
-
Hello Jack-
I am trying to follow your code, and understand what you really are wanting. All the bingo games I played were on a 5x5 board with a wild space in the middle. It looks like you are playing a slightly different type of bingo.
If I were to approach the problem:
1) I would start by creating arrays that hold the numbers for each columns (an array for 10's 20's 30's 40's etc)
2) I would randomize the arrays like you are doing,
3) I would create a single function that would populate each 9x3 box
a) the rows are built by splicing from each array. (the first column is from 10s, second column from 20 etc)
b) you need to use logic that for each row of nine, you will only place a number 5 times for each row and the other for will be blank spaces.
c) you can force a column position to be a space, when that array is empty
4) as far as the sum of numbers being equal in each table, I would need to think a little more about that. It seems like every time the number would always be 455. (I got that number by adding all the numbers from 1-90 and then dividing that by 9.)
When you are building each row, you can start with a variable goalNumber:uint= 455, and then minus each cell from goalNumber for each row. When as you are in the final row, use logic to say if the goalNumber is Large, then pick a large # from the array for each column... or conversely if the goalNumber is small, you could choose a small number from each of the column arrays.
I hope that helps- I have started by populating and randomizing the column arrays for you. Good luck!
Code:
var array10s:Array = []
var array20s:Array = []
var array30s:Array = []
var array40s:Array = []
var array50s:Array = []
var array60s:Array = []
var array70s:Array = []
var array80s:Array = []
var array90s:Array = []
var array100s:Array = []
for(var i:uint;i<99;i++){
//trace(i);
if(i<10){
array10s.push(i);
}
if(i<20&&i>=10){
array20s.push(i);
}
if(i<30&&i>=20){
array30s.push(i);
}
if(i<40&&i>=30){
array40s.push(i);
}
if(i<50&&i>=40){
array50s.push(i);
}
if(i<60&&i>=50){
array60s.push(i);
}
if(i<70&&i>=60){
array70s.push(i);
}
if(i<80&&i>=70){
array80s.push(i);
}
if(i<90&&i>=80){
array90s.push(i);
}
if(i<100&&i>=90){
array100s.push(i);
}
}
function shuffle(a,b):Number {
var num:Number = Math.round(Math.random()*2)-2;
return num;
}
array10s.sort(shuffle);
array20s.sort(shuffle);
array30s.sort(shuffle);
array40s.sort(shuffle);
array50s.sort(shuffle);
array60s.sort(shuffle);
array70s.sort(shuffle);
array80s.sort(shuffle);
array90s.sort(shuffle);
array100s.sort(shuffle);
trace(array10s,
array20s,
array30s,
array40s,
array50s,
array60s,
array70s,
array80s,
array90s,
array100s);
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
|