Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 11th, 2003, 10:46 AM
rwahdan rwahdan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 rwahdan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
vb card game question...please help

my question is simple but i gess it needs lots of coding...i have defined suits (S,H,C,D,AnySuit) and the game starts as AnySuit...player1 plays then second, third and forth...i have managed for all players to play a card from the same suit...i have managed for player1(human) to play differnt suit if he doesn't have any cards left from the current suit...my problems is having other players (computer) to play any card from any suit if they dont have cards from the current suit...they need to play a card of wich they have but when i do a code that will get a random card from 52 card deck then check if current player have it...if he does he will play it, if not it will random again untill it finds one...the problem is that it will random one time and wheter the player have that card or not it assumes he have it!!!! can you please try to help me...Thanx.

Reply With Quote
  #2  
Old December 12th, 2003, 12:43 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Hi,rwahdan!Do U need a random function to generate a card number and judge 3 player who has it??If u will not,Plz say your meaning fairly!

Reply With Quote
  #3  
Old December 12th, 2003, 02:55 AM
rwahdan rwahdan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 rwahdan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,

probably, if you take a look at my work you will see where the problem is...i have a rand function but everytime it gos through it, it searches for number (3)(club) only...at all time...and yes i am using randomize before the rand function....file attached. look at the function called

Private Sub TakeTurn(bytPlayer As Byte)

thanx.
Attached Files
File Type: zip test.zip (42.2 KB, 122 views)

Last edited by rwahdan : December 12th, 2003 at 02:57 AM.

Reply With Quote
  #4  
Old December 22nd, 2003, 05:53 PM
Lee Miles Lee Miles is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 7 Lee Miles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
code redesign

Sounds like your generating a random card EVERY time an player needs a card and then testing to see if other players have that card and if so making another random selection.

Would it not be better, (and would overcome your problem of playing any suit) if you set up a series of arrays, one for each player & another for the deck of cards. That way you just need to test the players array for a suit to play and if the suit is not there then play any card. ie.

Dim deck(3,52) as array
'column 1 records whether a card is in the deck or in a players hand ie 0=in deck number=the player number holding the card
'column 2 records the card description ie "Ace"
'column 3 records the card suit ie "Spades" or could be 1=Spades

you could find a players hand by doing something like

'check the deck
dim i,j as integer
for i = 1 to 52
if deck(1,i) = 1 then 'player 1 is holding the card
'do something for player1 here
endif
etc ....

next i

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > vb card game question...please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT