Пример #1
0
    def dist_player_stats(cls, stats, strength=False):
        """Order the stats to create distribution
        previously 'hand strength'"""
        # logger.info('distributing the player stats')
        dist = SortedDict(pos, {0: 'f'})
        p = 0
        for o in ['f', 's', 'l', 'k', 'c', 'b', 'r', 'a']:
            if o in stats:
                dist[p] = o
                p += max(0.01, stats[o])
                dist[p - 0.001] = o
        dist[1] = 'a'
        logger.info(f'dist = {dist}')

        logger.debug(f'strength? {strength}')
        if strength is False:
            return dist

        r = ''
        logger.debug(f'dist = {type(dist)}')
        for _ in range(20):
            p = _ * 5 / 100
            i_pos = dist.bisect_key_left(p)
            logger.debug(f'i_pos {i_pos} / {len(dist)}')
            k = dist.iloc[i_pos]
            v = dist[k]
            r += v.upper() if (1 - strength) <= p <= 1 else v.lower()
            logger.debug(f'bisected {v} from {k} at {r}%')
        logger.debug(f'dist_stats {r}')
        return r
Пример #2
0
    def dist_player_stats(cls, stats, strength=False):
        """Order the stats to create distribution
        previously 'hand strength'"""
        # logger.info('distributing the player stats')
        dist = SortedDict(pos, {0: 'f'})
        p = 0
        for o in ['f', 's', 'l', 'k', 'c', 'b', 'r', 'a']:
            if o in stats:
                dist[p] = o
                p += max(0.01, stats[o])
                dist[p - 0.001] = o
        dist[1] = 'a'
        logger.info(f'dist = {dist}')

        logger.debug(f'strength? {strength}')
        if strength is False:
            return dist

        r = ''
        logger.debug(f'dist = {type(dist)}')
        for _ in range(20):
            p = _ * 5 / 100
            i_pos = dist.bisect_key_left(p)
            logger.debug(f'i_pos {i_pos} / {len(dist)}')
            k = dist.iloc[i_pos]
            v = dist[k]
            r += v.upper() if (1 - strength) <= p <= 1 else v.lower()
            logger.debug(f'bisected {v} from {k} at {r}%')
        logger.debug(f'dist_stats {r}')
        return r
Пример #3
0
def test_bisect_key2():
    temp = SortedDict(modulo, 7, ((val, val) for val in range(100)))
    assert all(
        temp.bisect_key(val) == ((val % 10) + 1) * 10 for val in range(10))
    assert all(
        temp.bisect_key_right(val) == ((val % 10) + 1) * 10
        for val in range(10))
    assert all(
        temp.bisect_key_left(val) == (val % 10) * 10 for val in range(10))
def test_bisect_key2():
    temp = SortedDict(modulo, 7, ((val, val) for val in range(100)))
    assert all(temp.bisect_key(val) == ((val % 10) + 1) * 10 for val in range(10))
    assert all(temp.bisect_key_right(val) == ((val % 10) + 1) * 10 for val in range(10))
    assert all(temp.bisect_key_left(val) == (val % 10) * 10 for val in range(10))