<jupyter_start><jupyter_text>TexturesScene Elements (and agents) can have different textures.We wil lreview them here.<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt

def plt_image(img):
    plt.axis('off')
    plt.imshow(img)
    plt.show()
from simple_playgrounds.playgrounds.layouts import SingleRoom
from simple_playgrounds.engine import Engine

my_playground = SingleRoom(size=(200, 200))

# we use the option replay=True to reset the environment if it terminates before time_limit.
engine = Engine(time_limit=10000, playground=my_playground, screen=False)

plt_image(engine.generate_playground_image(plt_mode=True))<jupyter_output>pygame 2.0.1 (SDL 2.0.14, Python 3.7.5)
Hello from the pygame community. https://www.pygame.org/contribute.html<jupyter_text>Color textureThe most basic texture is a uniform color.<jupyter_code>from simple_playgrounds.elements.collection.basic import Physical

elem = Physical(physical_shape='square', radius=10, texture=[123, 234, 0])
my_playground.add_element(elem, ((50, 50), 0))

plt_image(engine.generate_playground_image(plt_mode=True))<jupyter_output><empty_output><jupyter_text>Note that the texture parameters can be provided as a list/tuple, a dictionary of parameters, or a class.If a class is provided, it must be instanciated by giving the radius of the element as an additional parameter.<jupyter_code>from simple_playgrounds.common.texture import ColorTexture

elem = Physical(physical_shape='circle', radius=10, texture=ColorTexture(color=(222, 0, 0), size=10))
my_playground.add_element(elem, ((100, 50), 0))

elem = Physical(physical_shape='pentagon', radius=10, texture={'texture_type': 'color', 'color': (0, 0, 222), 'size': 10})
my_playground.add_element(elem, ((150, 50), 0))

plt_image(engine.generate_playground_image(plt_mode=True))<jupyter_output><empty_output><jupyter_text>Advanced TexturesSimple playgrounds includes already available textures:- ColorTexture: Unique color across the object- UniformTexture: Each pixel has a random color.- RandomTilesTexture: Texture composed of squared tiles- UniqueRandomTilesTexture: Generate N different RandomTilesTexture- PolarStripesTexture: Stripes centered- CenteredRandomTilesTexture: Random stripes centered- ListCenteredRandomTiles: Stripes come from a list<jupyter_code>from simple_playgrounds.common.texture import RandomUniformTexture, RandomTilesTexture

tex_uniform = RandomUniformTexture(color_min=(100, 100, 0), color_max=(200, 250, 0), size=10)
elem = Physical(physical_shape='pentagon', radius=10, texture=tex_uniform)
my_playground.add_element(elem, ((50, 100), 0))

tex_tiles = RandomTilesTexture(color_min=(150, 100, 0), color_max=(200, 250, 0), size_tiles=5, size=40)
elem = Physical(physical_shape='rectangle', size=(20, 30), texture=tex_tiles)
my_playground.add_element(elem, ((100, 100), 0))

plt_image(engine.generate_playground_image(plt_mode=True))
from simple_playgrounds.common.texture import CenteredRandomTilesTexture, MultipleCenteredStripesTexture

tex_polar = MultipleCenteredStripesTexture(color_1=(200, 100, 50), color_2=(100, 100, 150), size=20, n_stripes=5)
elem = Physical(physical_shape='pentagon', radius=20, texture=tex_polar)
my_playground.add_element(elem, ((50, 150), 0))

tex_random_tiles_centered = CenteredRandomTilesTexture(color_min=(100, 0, 100), color_max=(200, 0, 200), size=20, size_tiles=20)
elem = Physical(physical_shape='hexagon', radius=20, texture=tex_random_tiles_centered)
my_playground.add_element(elem, ((100, 150), 0))

plt_image(engine.generate_playground_image(plt_mode = True))
engine.terminate()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11120331950207468, 'fraction_numerical': 0.048132780082987554, 'mean_word_length': 8.668449197860962, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '200478', 'license': 'MIT', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1134, 'n_words': 275, 'path': 'tutorials/jupyter/04_Textures.ipynb', 'repo_name': 'embaba/simple-playgrounds', 'size': '3615'}