CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 24

Threaded View

  1. #1
    Join Date
    May 2012
    Posts
    57

    Which container to do what I need?

    Sorry for this long post but I don't know how to explain it in a shorter form.

    What container allows fast finding of a specific item -and- also allows scanning by using iterators that can be incremented in a "for" loop? My data:

    Code:
    Number of players:  4
    
    BetInfo for each player:
    ---------------------------
    Passline:  betAmount, coordX, coordY
    No Pass :  betAmount, coordX, coordy
    Field   :  betAmount, coordX, coordY
    Place4  :  betAmount, coordX, coordY
    Place5  :  betAmount, coordX, coordY
    
    --- continues for about 50 different bets ---
    QUESTION 1:
    When dice is rolled, the diceSum dictates which bet amount I need to access. For instance, if the diceSum is a 2 on the first roll, the Passline bet loses for all 4 players so I need to access the Passline betAmount for each player to see of a bet was made (betAmount > 0). Then handle it.

    (Player1 > Passline > betAmount), then
    (Player2 > Passline > betAmount), then
    (Player3 > Passline > betAmount), then
    (Player4 > Passline > betAmount)

    Which container will provide fast access to the betAmount for each player? Note that I have to do also do this for other bets like NoPass bets, Field bets, oneRoll2 bets, anyCrap bets, Horn bets and World bets to pay each player.

    ----------

    QUESTION 2:
    When a shooter 7's out, I need to pay some bets then zero all bets on the table for all 4 players. When I zero all bets on the table for 4 players, I would like to do it using iterators like in a "for" loop. So the container needs to be able to do this also. Which container can do #1 above and #2?

    ----------

    Hope my explanation is clear enough. I think I need to use a 3 dimensional array to hold all of the BetInfo.

    50 rows will be for each bet. (approximate)
    3 columns will be for betAmount, coordX, coordY.
    4 layers will be for the 4 players.

    Code:
    enum {Passline, NoPass, Field, Place4, Place5, ...etc.};   (bet-name)
    enum {BetAmount, CoordX, CoordY};                          (bet-data)
    enum {Player1, Player2, Player3, Player4};                 (player-number)
    
    int betInfo[bet-name][bet-data][player-number]

    But is there a better container to use to hold all of the betInfo, yet do what I need?

    Thanks,
    Raptor
    Last edited by raptor88; October 16th, 2012 at 11:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured