Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / A quick question.....

Author
Message
Qualed Entertainment
20
Years of Service
User Offline
Joined: 17th Nov 2005
Location:
Posted: 6th Oct 2006 17:45
Hello again,
I'm working on a bingo game for a research paper in school, and I was wondering what coding I could use for the variables. I looked in the tutorials and I couldn’t find anything about using number and letter combinations to pick a space on the bingo board. I was also wondering if anyone has any suggestions as to what to put in the game.
Thank you all in advance,
Qualed Entertainment

CEO of Qualed Entertainment
Join the Qualed Code Group: email me at [email protected]
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Oct 2006 19:41
Well, as you know you can't calculate with strings. But you cannot store letters in an integer variable either. But it is possible to convert the one type to the other.

string$ = str$(number)
This command returns the number, but in a string type. So if number would contain 5, the command would return "5"

value = val(string$)
this command returns the value of a string. If the string was "13" then this command will return 13 as an integer.

Both commands work with floats too.

So to put a space between numbers, you'll have to use strings. (integers cannot contain spaces).
print str$(value1) + " " + str$(value2)

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Oct 2006 08:05
Hello Q,

First suggestion, write down everything you want the game to do on paper. Is the computer just going to pick numbers and then a human would fill them in on a BINGO card in the real world? Will the computer be running through a simulation where it creates the BINGO cards and fills them in as it picks numbers to show basic gaming AI?
Will it be all text? What kind of graphics? Sound? Music? Multiple players?

Whatever you decide, map it all out on paper. Then break it down into tasks and work on each piece.

Since this is a school paper, I'll give you a couple of hints, but no code.

Depending on how you plan to approach the program, Sven's given you some great ideas on how to mix strings with numbers.

But in BINGO, you really only have to worry about the letters B I N G O (strings) when the number is called out. Basically, the board is just a grid (a matrix) of numbers. I think it's 5x5 so that means you can use a 2 dimensional array. Check out this tutorial on arrays:

Array Tutorial

You'll have to figure out how to populate the array with random numbers.

As far as the B I N G O , I suggest checking out the CASE and SELECT commands to figure out a way to access and/or set individual cells. You might need to use some of the conversion suggestions Sven gave you.

Enjoy your day.
Qualed Entertainment
20
Years of Service
User Offline
Joined: 17th Nov 2005
Location:
Posted: 10th Oct 2006 17:50
Thank you both.
Latch, I was planning on having a bingo board as a background, and it is all going 2d, with graphics. I still have to find music for the background, but I really wanted to know how to get computer to randomly pull up, for example, B52. And that array tutorial helped.

Now, I don't suppose either of you have the DarkBASIC trial demo handy? I just need it so I can continue coding here at school, because I can't access my Gmail here at school. If you do have it handy, could you please send it to the Qualed Entertainment address, [email protected], in a zip file, because the school also blocks you from downloading exe files.

~Qualed

CEO of Qualed Entertainment
Join the Qualed Code Group: email me at [email protected]
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Oct 2006 03:49
@Q

Sorry, don't have the trial demo...

But here's a couple more hints for your project:

The RND(max) function returns a random whole number between 0 and max. If you want a specific range of numbers, say between 25 and 99, you have to do a little math. If the lowest number in your range is positive, you will add that onto the RND(max) function:

RND(max)+25

If the lowest number is negative, you will subtract that from the RND(max) function:

RND(max)-25

Now you also have to change the max. We'll say our max value should be 99, but if our lowest value is 25, we have to subtract 25 from max. Our new max would be 99-25=72. So to generate random numbers between 25 and 99 the function would look like:

RND(72)+25

If the lowest number is -25 max = 99 - -25 = 124 . The random function for a range of numbers between -25 and 99 then looks like:

RND(124)-25

To make your random numbers more "random" you should seed the random number generator with the RANDOMIZE function. At the top of your program include something like RANDOMIZE TIMER() - which will seed the random number generator with whatever the current value the timer has. This is a pretty good seed unless someone launches the program at exactly the same time to the ms everyday.

Since BINGO is 5 letters long, you could generate random numbers from 1 to 5. If the computer generates a 1, then that means the computer has picked B. If 2, I etc.

This works out nicely for your array.

Enjoy your day.

Login to post a reply

Server time is: 2026-07-07 05:39:39
Your offset time is: 2026-07-07 05:39:39