Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
card shuffler
#18
ok now i got it. i added another checker to see if there were any repeats after i dealed them that would print out were the repeated cards were so i didnt have to check it all the time

Code:
declare function rndcard$()
cls

np=4 'Number of players. change to your needs

'dims the player array
'the first d is the number of players
'the second d is the number of in wich he gets the card
'(sorry cant explain think of any other way to explain that)
dim player$(np,52)

randomize timer




for p=1 to np ' does for number of players
for i=1 to (52/np) ' divides the deck
   1
   player$(p,i) = rndcard$() ' gets the card
    
   for a= 1 to np
   for n = 1 to (52/np)                          'this checks to make
      if a=p and n=i then n=n+1
      if player$ (p,i) = player$(a,n) then goto 1'sure the card isnt
   next                                          'repeated
   next
next
next


'the rest of this prints out the player and card names
c=1
oldp=0
for p=1 to np
r=1


locate r,c: print "Player "; p
r=r+1
for i= 1 to (52/np)
   r=r+1
   locate r,c: print player$(p,i)
next
c=c+18

next


'this just checks to make sure that there are no repeats
y=20
for p=1 to np
   for pa=1 to np
      for i=1 to 53/np
         for n=1 to 53/np
            if player$(p,i)=player$(pa,n) then
               if p<>pa and n<>i then
                  locate y,1: print "error @ player ";p;" card number ";i;" = player ";pa;" card number ";n;
                  y=y+1
               end if
            end if
         next
      next
   next
next









do:loop until inkey$=chr$(27)










function rndcard$()
    
   SS=int(rnd*4)+1 'this is selects the suit
   card=int(rnd*13)+1 ' this selects the card number
    
   'names the suits
   select case SS
   case 1
      suit$="Spades"
   case 2
      suit$="Clubs"
   case 3    
      suit$="Diamonds"
   case 4
      suit$="Hearts"
   end select
    
    
   'selects the card names
   select case card
   case 1
      cname$="Ace"
   case 11
      cname$="Jack"
   case 12
      cname$="Queen"
   case 13
      cname$="King"
   case else
      cname$=str(card)
   end select
    
   rndcard$=cname$ + " of " + suit$ 'puts it all together
    
    
end function
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Reply


Messages In This Thread
card shuffler - by neuro - 05-22-2005, 06:40 AM
card shuffler - by Z!re - 05-22-2005, 07:16 AM
card shuffler - by neuro - 05-22-2005, 09:08 AM
card shuffler - by Mango - 05-22-2005, 02:11 PM
card shuffler - by relsoft - 05-22-2005, 04:01 PM
card shuffler - by Anonymous - 05-22-2005, 04:07 PM
card shuffler - by Z!re - 05-22-2005, 08:15 PM
card shuffler - by Anonymous - 05-23-2005, 09:53 AM
card shuffler - by Z!re - 05-23-2005, 08:08 PM
card shuffler - by neuro - 05-24-2005, 04:43 AM
card shuffler - by Z!re - 05-24-2005, 05:00 AM
card shuffler - by Pyrokid - 05-24-2005, 06:43 AM
card shuffler - by neuro - 05-24-2005, 07:13 AM
card shuffler - by Anonymous - 05-24-2005, 10:49 AM
card shuffler - by Pyrokid - 05-24-2005, 04:02 PM
card shuffler - by aetherfox - 05-24-2005, 04:57 PM
card shuffler - by shiftLynx - 05-24-2005, 09:05 PM
card shuffler - by Pyrokid - 05-24-2005, 09:56 PM
card shuffler - by phycowelder - 11-04-2005, 09:44 AM
card shuffler - by stylin - 11-04-2005, 12:07 PM
card shuffler - by Moneo - 11-05-2005, 07:08 AM
card shuffler - by Dr_Davenstein - 11-05-2005, 10:20 AM
card shuffler - by Torahteen - 11-05-2005, 10:22 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)