View previous topic :: View next topic |
Author |
Message |
webdaddy Contributor


Joined: 14 Nov 2004 Posts: 151 Location: Raleigh NC
|
Posted: Thu May 05, 2005 3:03 am Post subject: Keno Game and @RANDOM |
|
|
Im trying (unsuccessfully at this point) to write a Keno board game with the @random function. Is there any way to make @random not call the same number twice per each RANDOM seed?
I guess the answer is no to that since that would not be random. Does anybody have any quick tidbit of code that can do this. I could do a ton of if then statements but would prefer a cleaner method of doing this. _________________ K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux... |
|
Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu May 05, 2005 3:35 am Post subject: |
|
|
Hi Webdaddy,
I use :
Code: | random @datetime(ddhhnnss) |
Hooligan _________________ Hooligan
Why be normal? |
|
Back to top |
|
 |
webdaddy Contributor


Joined: 14 Nov 2004 Posts: 151 Location: Raleigh NC
|
Posted: Thu May 05, 2005 3:40 am Post subject: Got That Part |
|
|
I got that part down. But it will repeat the same numbers. What im trying to do is to have it not repeat any of the same 8 numbers each time my VDS script runs. In the game Keno for instance it picks 8 numbers out of the pool 1-80. The problem im having is that @random may pick the same number twice which cant happen in Keno. So basically I have to figure out how to pick 8 DIFFERENT numbers from 1-80 using @random.
Hopefully I explained that better this time. _________________ K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux... |
|
Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu May 05, 2005 3:51 am Post subject: |
|
|
Ah-ha! I see... The problem is not with the seed, but with knowing what has already been picked... That sounds like fun... I'll play with it and see if I can knock something out in the next half hour... (I've got an idea...)
Hooligan _________________ Hooligan
Why be normal? |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu May 05, 2005 4:06 am Post subject: |
|
|
I actually did this very thing for someone here a while back. I use VDS 3
so there's no @random() function.
Keep pressing the "test" button (without clearing) and you'll see it will
eventually pick all the numbers at random.
________________________________________________________________________________________________________
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Keno Test Program",-1,0,372,360
DIALOG ADD,STYLE,S1,MS Sans Serif,12,BC
DIALOG ADD,STYLE,S2,MS Sans Serif,12,BC,,CYAN
DIALOG ADD,BUTTON,Test,300,32,64,24,,S1
DIALOG ADD,BUTTON,Clear,300,276,64,24,,S1
%x = 1
%y = 1
%z = 1
REPEAT
DIALOG ADD,TEXT,T1%z,@prod(%y, 32),@prod(%x, 32),20,20,%z,,S1
DIALOG ADD,TEXT,T2%z,@prod(%y, 32),@prod(%x, 32),20,20,%z,,S2
DIALOG HIDE, T2%z
if @greater(10, %x)
%x = @succ(%x)
else
%x = 1
%y = @succ(%y)
end
%z = @succ(%z)
UNTIL @greater(%z, 80)
DIALOG ADD,STATUS,Stat
DIALOG SHOW
rem -- load our 80 numbers --
LIST CREATE, 1
%x = 1
REPEAT
LIST ADD, 1, %x
%x = @succ(%x)
UNTIL @greater(%x, 80)
:EVLOOP
WAIT EVENT
goto @event()
:TestBUTTON
%%shuffles = 3
REPEAT
WAIT ".1"
rem -- shuffle the numbers --
%x = @diff(@count(1), 1)
REPEAT
%t = @ext(@datetime())
rem -- get last 4 digits (use as rough random number) --
if @greater(@len(%t), 4)
%t = @substr(%t, @diff(@len(%t), 3), @len(%t))
rem -- number position --
%p = @mod(%t, @sum(%x, 1))
rem -- number to swap --
%n = @item(1, %p)
rem -- stored number --
%s = @item(1, %x)
LIST PUT, 1, %n
LIST SEEK, 1, %p
LIST PUT, 1, %s
%x = @pred(%x)
end
UNTIL @greater(1, %x)
%%shuffles = @pred(%%shuffles)
UNTIL @greater(1, %%shuffles)
rem -- show 20 top numbers in list 1 --
%x = 0
REPEAT
DIALOG SHOW, T2@item(1, %x)
%x = @succ(%x)
UNTIL @greater(%x, 19)
goto EVLOOP
:ClearBUTTON
%x = 1
REPEAT
DIALOG HIDE, T2%x
%x = @succ(%x)
UNTIL @greater(%x, 80)
goto EVLOOP
:CLOSE
EXIT
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu May 05, 2005 4:12 am Post subject: |
|
|
Well, Mac knocked that out a lot quicker than I could... (and nicer than my example would have been). Good job Mac!
Hooligan _________________ Hooligan
Why be normal? |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu May 05, 2005 4:21 am Post subject: |
|
|
Thanks, but I didn't just "knock that out" in a few minutes.
Don't remember how long it took, but it prolly took a while. For
one thing I had no idea how keno was played at the time...
The shuffle code is a mod of a card shuffle routine (written in "C")
that I've had for years.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
Back to top |
|
 |
webdaddy Contributor


Joined: 14 Nov 2004 Posts: 151 Location: Raleigh NC
|
Posted: Thu May 05, 2005 4:24 am Post subject: Great |
|
|
Thanks for that bit of code. I will work on seeing if this works for me. I'll send you a copy of the completed program when its finished if you want.
We should all write a casino system for this. You know the going rate for online poker is about 10G. Makes me want to delve into that pretty heavily. Im learning and fast. If anybody is interested would be cool for some of use to make some serious cash out of something like that. _________________ K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux... |
|
Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu May 05, 2005 2:57 pm Post subject: |
|
|
Quote: | Thanks, but I didn't just "knock that out" in a few minutes. |
That helps my ego a bit... Still, a nice bit of code.
Hooligan _________________ Hooligan
Why be normal? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|