algorithm - Shuffle and deal a deck of card with constraints -


here facts first.

in game of bridge there 4 players named north, south, east , west.

all 52 cards dealt 13 cards each player.

there honour counting systems. ace=4 points, king=3 points, queen=2 points , jack=1 point.

i'm creating "card dealer" constraints example might hand dealt north has have 5 spades , between 13 16 honour counting points, rest of hands random.

how accomplish without affecting "randomness" in best way , having effective code?

i'm coding in c# , .net idea in pseudo code nice!

depending on how fast computer is, might enough this:

  • repeat:
    • do random deal
  • until board meets constraints

as performance questions, thing try , see!

edit tried , saw:

done 1000000 hands in 12914 ms, 4424 ok 

this without giving thought optimisation - , produces 342 hands per second meeting criteria of "north has 5 spades , 13-16 honour points". don't know details of application seems me might enough.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -