Exemplo n.º 1
0
TRIALS = 100000
winners = [0 for p in range(players)]
start = time.time()
for t in range(TRIALS):
    fullhands = []
    ranks = []

    if len(boardinput) == 6:
        board = [board1, board2, board3] + random.sample(deck, 2)
    elif len(boardinput) == 8 and board4:
        board = [board1, board2, board3, board4] + random.sample(deck, 1)
    else:
        sys.exit(1)

    for h in hands:
        hand = Hand(h[0], h[1], board)
        fullhands.append(hand)
    for f in fullhands:
        rank = f.rank()
        ranks.append(rank)
    assert len(ranks) == players
    if ranks.count(max(ranks)) != 1:
        chop += 1
    else:
        win = ranks.index(max(ranks))
        winners[win] += 1

chop = round((chop / TRIALS) * 100, 2)
pcts = []
for number in winners:
    pct = round((number / TRIALS) * 100, 2)
Exemplo n.º 2
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.NO_BORDER,
                 name="AnalogClock",
                 clockStyle=DEFAULT_CLOCK_STYLE,
                 minutesStyle=TICKS_CIRCLE,
                 hoursStyle=TICKS_POLY):

        wx.PyWindow.__init__(self, parent, id, pos, size, style, name)

        # Base size for scale calc purposes.
        self.basesize = wx.Size(348, 348)

        # Store some references.
        self.clockStyle = clockStyle
        self.minutesStyle = minutesStyle
        self.hoursStyle = hoursStyle

        self.DrawHands = self._drawHands
        self.DrawBox = self._drawBox
        self.RecalcCoords = self._recalcCoords

        self.shadowOffset = 3

        self.allHandStyles = [
            SHOW_HOURS_HAND, SHOW_MINUTES_HAND, SHOW_SECONDS_HAND
        ]

        # Initialize clock face.
        #
        # By default we don't use colours or borders on the clock face.
        bg = self.GetBackgroundColour()
        face = Face(dyer=Dyer(bg, 0, bg))

        # Initialize tick marks.
        #
        # TickSet is a set of tick marks; there's always two TickSets defined
        # regardless whether they're being shown or not.
        ticksM = TickSet(self, style=minutesStyle, size=5, kind="minutes")
        ticksH = TickSet(self,
                         style=hoursStyle,
                         size=25,
                         kind="hours",
                         rotate=clockStyle & ROTATE_TICKS)

        # Box holds the clock face and tick marks.
        self.Box = Box(self, face, ticksM, ticksH)

        # Initialize hands.
        #
        # HandSet is the set of hands; there's always one HandSet defined
        # regardless whether hands are being shown or not.
        #
        # A 'lenfac = 0.95', e.g., means that the lenght of that hand will
        # be 95% of the maximum allowed hand lenght ('nice' maximum lenght).
        handH = Hand(size=7, lenfac=0.7)
        handM = Hand(size=5, lenfac=0.95)
        handS = Hand(size=1, lenfac=0.95)
        self.Hands = HandSet(self, handH, handM, handS)

        # Create the customization dialog.
        self.Setup = None

        # Make a context menu.
        popup1 = wx.NewId()
        popup2 = wx.NewId()
        cm = self.cm = wx.Menu()
        cm.Append(popup1, "Customize...")
        cm.Append(popup2, "About...")

        # Set event handlers.
        self.Bind(wx.EVT_SIZE, self._OnSize)
        self.Bind(wx.EVT_PAINT, self._OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda evt: None)
        self.Bind(wx.EVT_TIMER, self._OnTimer)
        self.Bind(wx.EVT_WINDOW_DESTROY, self._OnDestroyWindow)
        self.Bind(wx.EVT_CONTEXT_MENU, self._OnContextMenu)
        self.Bind(wx.EVT_MENU, self._OnShowSetup, id=popup1)
        self.Bind(wx.EVT_MENU, self._OnShowAbout, id=popup2)

        # Set initial size based on given size, or best size
        self.SetBestFittingSize(size)

        # Do initial drawing (in case there is not an initial size event)
        self.RecalcCoords(self.GetSize())
        self.DrawBox()

        # Initialize the timer that drives the update of the clock face.
        # Update every half second to ensure that there is at least one true
        # update during each realtime second.
        self.timer = wx.Timer(self)
        self.timer.Start(500)