<jupyter_start><jupyter_text>Playground  Beta law for fight evaluations - https://fr.wikipedia.org/wiki/Loi_b%C3%AAta- https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.beta.html<jupyter_code>from scipy.stats import beta
r = beta.rvs(10, 1, size=1000)
from ipywidgets import interact,IntSlider

@interact(a = IntSlider(min = 1,max = 10,value = 1,step = 1),b = IntSlider(min = 1,max = 10,value = 1,step = 1))
def explore(a,b):
    x = np.linspace(0,1,100)
    rv = beta(a, b)
    plt.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
    plt.show()
def win(a,b):
    return beta.rvs(a, b) > 0.5<jupyter_output><empty_output><jupyter_text>Env development  Dev decorators<jupyter_code>env.data
import functools



class Test:

    @staticmethod
    def decorator(func):
        @functools.wraps(func)
        def wrapper_decorator(*args, **kwargs):
            print("Something is happening before the function is called.")
            # Do something before
            value = func(*args, **kwargs)
            print("Something is happening after the function is called.")
            # Do something after
            return value
        return wrapper_decorator
    
    @self.decorator
    def __init__(self):
        pass
    
    @self.decorator
    def render(self):
        pass
    
    
class CTest(Test):
    pass
    
    
    
import functools


def decorator(func):
    @functools.wraps(func)
    def wrapper_decorator(self,*args, **kwargs):
        print("Something is happening before the function is called.")
        # Do something before
        print(func)
        value = func(self,*args, **kwargs)
        self.post_init()
        print("Something is happening after the function is called.")
        # Do something after
        return value
    return wrapper_decorator

class Test:
    
    @decorator
    def __init__(self):
        pass
    
    @decorator
    def render(self):
        pass
    
    def post_init(self):
        print("postinit1")
    
    
class CTest(Test):
    
    @decorator
    def __init__(self):
        
        super().__init__()
        
        
    def post_init(self):
        print("postinit2")
    
    
    
env.quit()
t = CTest()<jupyter_output>Something is happening before the function is called.
Something is happening before the function is called.
postinit2
Something is happening after the function is called.
postinit2
Something is happening after the function is called.<jupyter_text>Dev env<jupyter_code>class Player(BaseAgent):
    
    attrs = ["color","stacked"]
    
    def post_bind(self):
        self.stacked = 1
        self.other_color = RED if self.color == BLUE else BLUE
    
    @property
    def blocking(self):
        return False
    
    def step(self):
        self.wander()
        
    def render(self,screen):
        super().render(screen = screen)
        self.render_text(self.stacked,size = 25)
        
        
#     def prerender(self):

#         player1 = self.env.make_group({"color":RED})
#         player2 = self.env.make_group({"color":BLUE})
        
#         collision1 = self.collides_group(player1,method = "rect")
#         collision2 = self.collides_group(player2,method = "rect")
        
#         self.pop = 1 + (len(collision1) if self.color == RED else len(collision2))

        
class Environment(GridEnvironment):
    
    def count_stacked(self):
        
        count = self.data.groupby(["color","pos"])["stacked"].transform(lambda x : len(x))
        for obj,stacked in count.to_dict().items():
            self[obj].stacked = stacked
            
    def prerender(self):
        self.count_stacked()
        
        

spawner1 = lambda x,y : Player(x,y,color = RED)
spawner2 = lambda x,y : Player(x,y,color = BLUE)

env = Environment(width = 20,height = 10,cell_size=30,show_grid = True)
env.spawn(spawner1,20)
env.spawn(spawner2,20)

env.render()
env.get_img()
sim = Simulation(env,fps = 10)
sim.run_episode(n_steps = 20,replay = True,save = True)
class Player(BaseAgent):
    
    def step(self):
        self.wander()
        

spawner1 = lambda x,y : Player(x,y,color = BLUE,img_asset = "blob")

env = GridEnvironment(width = 20,height = 10,cell_size=30,show_grid = True)
env.spawn(spawner1,50)

env.render()
env.get_img()
sim = Simulation(env,fps = 3)
sim.run_episode(n_steps = 500,replay = True,save = False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11762024162297698, 'fraction_numerical': 0.016868019147481195, 'mean_word_length': 2.6324503311258276, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '4758', 'license': 'MIT', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1445, 'n_words': 319, 'path': 'notebooks/20200608 - Cataine dev.ipynb', 'repo_name': 'TheoLvs/westworld', 'size': '4387'}