forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Keno Game and @RANDOM

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Thu May 05, 2005 3:03 am    Post subject: Keno Game and @RANDOM Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Thu May 05, 2005 3:35 am    Post subject: Reply with quote

Hi Webdaddy,

I use :


Code:
random @datetime(ddhhnnss)



Hooligan

_________________
Hooligan

Why be normal?
Back to top
View user's profile Send private message
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Thu May 05, 2005 3:40 am    Post subject: Got That Part Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Thu May 05, 2005 3:51 am    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu May 05, 2005 4:06 am    Post subject: Reply with quote

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. Wink
________________________________________________________________________________________________________
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 Smile

_________________
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
View user's profile Send private message Send e-mail
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Thu May 05, 2005 4:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu May 05, 2005 4:21 am    Post subject: Reply with quote

Thanks, but I didn't just "knock that out" in a few minutes. Wink

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... Embarassed

The shuffle code is a mod of a card shuffle routine (written in "C")
that I've had for years. Wink

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Thu May 05, 2005 4:24 am    Post subject: Great Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Thu May 05, 2005 2:57 pm    Post subject: Reply with quote

Quote:
Thanks, but I didn't just "knock that out" in a few minutes.


That helps my ego a bit... Wink Still, a nice bit of code.

Hooligan

_________________
Hooligan

Why be normal?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group