A card game, like i.e. Poker possible?

HunnenkoenigHunnenkoenig Posts: 1,173Member
How would I start to make a poker game from the game logic side?

How can I do the math, which cards are played and compare them to each other?

I think, every card should have some attributes like color, points and such.

Which part of GS would I need to compare their attributes and calculate the math?


  • harrioharrio Posts: 234Member
    what's cookin,

    because you cannot 'see' the data from one actor to another you will more than likely have to process the physical card separately from the card logic. meaning you'll have to create attributes for the cards and process your game logic/rules with those attributes while separately processing the physical cards themselves as a result of the game logic.

    but i may be wrong. someone may figure out an elegant solution that combines the actor and the logic.

  • rebumprebump Posts: 1,058Member
    Everything would be controlled with game based (i.e. not actor based attributes) and the card actors would just be "clients" or the "view" if you will of the cards in the game core logic. You randomly set some card "slot" attributes to a random card, use the value there to display an appropriate imaged card, etc. The logic, in the current GS incarnation, would be pretty nightmarish given the way some logic and looping needs to be handled (think of how you would determine which card to display given GS's current if-then construct...pretty crazy).

    Array processing is not possible in GS so that adds to the frustration. Also, the "random()" function is currently not seedable in the traditional sense and must be worked with in a slightly funky manner as highlighted in another forum post on "random not being random" or something as such.

    As for scoring the hand, that is where the logic would get messy without some of the various features available to standard programming environments. I would think you would start by using a few counter and watermark variables to count items such as:

    - successive card count and if "5" counted store the high card (i.e. those that may comprise a straight)
    - one for matching pip count(s) (i.e. those that could comprise a flush)
    - and a few counters for matching card values and each set's value (i.e. those that could comprise a pair, three-of-a-kind, four-of-a-kind) depending on if your are doing 5 card, 7 card, etc.

    Then once you have your data from above you can test for hand possibilities starting from the top (i.e. Royal Flush on down to High Card) until you had a match for the given hand.

    During this, there would normally be logic methods and programming constructs that would make all that easier but with GS right now, it would be a bunch of successive and also nested if-then rules - lots of them.

    Then repeat the process for the AI hand or other player's hands to then allow another set of if-thens to determine who had the winning hand (i.e. you would want to assign a score to each winning hand type that would also take into account high card...different ways to handle this). Enumerations or an array hand indicators would normally help here.

    Blackjack would be a little easier but the whole dealing out cards would still be a crazy rule set.

    You'd probably run into either 4 rules with 13 nests, 13 rules with 4 nests, 52 rules, etc. just for dealing out the cards in either Poker or Blackjack, again, since arrays and such are not available.

    Hope that made sense...was typing this with a toddler going haywire next to me.
  • HunnenkoenigHunnenkoenig Posts: 1,173Member
    Thanks for the extensive explanation!
    I think, I pass on this then for this time :-)

    I already thought that it wouldn't be easy with GS :-)
This discussion has been closed.