• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

VB6 Yahtzee game

 
Rancher
Posts: 1171
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I come from a java background, but start a new job tommorow, where everything still is written in vb6.
To get myself a bit familierd with the language I started to make a simple yathzee game.
Everything works great, but somethings take way more could as they should.
For example I included the code I use to check if the player has a three of a kind...



Take note of the second if statement, there most be a easier way to do this...?
 
Bartender
Posts: 5546
213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not familiar with yahtzee, but in poker I make a frequency table of a hand. If the table has 3 keys, and one of the key values = 3, then it is three of a kind. (the other two keys must have values 1). The points is then simply 3 times the value of the card, ot in your case the caption of your label.

By the way: in your current routine, must you not also check that the other two cards are not a pair? You would have full house in that case (if applicable to yahtzee).
 
Daniel Demesmaecker
Rancher
Posts: 1171
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A full house is still three of a kind, if the player chooses to put it at three of a kind instead of full house, cause for example he already has filled in full house, he should be able to.
Poker and yahtzee are about the same, one is with dice, the other with cards...
 
Piet Souris
Bartender
Posts: 5546
213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see.

If the values of the table contain a 3, then if there are three keys, it's three of a kind, otherwise it's full house.. This made it very easy for me to characterize a hand of poker, keeping away from all those ifs in the code, and reducing the methods that check for a certain combination. How many subs รก la lblThreeOfPl1_Click do you have?

Edit: switched three of  a kind and full house into their correct places.
 
Daniel Demesmaecker
Rancher
Posts: 1171
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There would be six
 
Piet Souris
Bartender
Posts: 5546
213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Less than in poker, I guess there is no such thing as a street flush or two pairs. Well, I hope that such a ft makes the coding of yahtzee easier, wit much less if's. If not, let me know where an ft fails for yahtzee.
 
I was her plaything! And so was this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic