<jupyter_start><jupyter_text>FieldsFields allow you to define an area where certain Scene Elements will appear randomlyThis can be interesting in foraging scenario, where an agents move around to collect rewards.<jupyter_code>from simple_playgrounds.playgrounds import SingleRoom
from simple_playgrounds import Engine

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

# we use the option screen=True to use a keyboard controlled agent later on.
engine = Engine(time_limit=10000, playground= my_playground, screen=True, replay=True)

engine.display_full_scene()<jupyter_output>pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Loading chipmunk for Linux (64bit) [/home/michael/.local/lib/python3.6/site-packages/pymunk/libchipmunk.so]<jupyter_text>Now that we have an empty playground, lets create a field that produces candies in the top-left area of the playground.<jupyter_code>from simple_playgrounds.entities.scene_elements import Candy
from simple_playgrounds.utils import PositionAreaSampler
from simple_playgrounds.entities.field import Field

area = PositionAreaSampler( center = (50, 150), area_shape='circle', radius= 30 )
field = Field(probability=0.1, limit=10, entity_produced=Candy, production_area=area)
my_playground.add_scene_element(field)<jupyter_output><empty_output><jupyter_text>Now we can let the playground run for some time, and see if the field produces candies.<jupyter_code>engine.run(with_screen=True)
engine.terminate()<jupyter_output><empty_output><jupyter_text>Finally, we can add an agent controlled by a keyboard.We see that the Candies are replaced little by little.<jupyter_code>from simple_playgrounds.controllers import Keyboard
from simple_playgrounds.entities.agents import BaseAgent

from simple_playgrounds.entities.scene_elements import Candy
from simple_playgrounds.utils import PositionAreaSampler
from simple_playgrounds.entities.field import Field

my_playground = SingleRoom(size=(200, 200))
engine = Engine(time_limit=10000, playground= my_playground, screen=True, replay=True)

area = PositionAreaSampler( center = (100, 100), area_shape='circle', radius= 100 )
field = Field(probability=0.1, limit=10, entity_produced=Candy, production_area=area)
my_playground.add_scene_element(field)

my_agent = BaseAgent(controller=Keyboard())
my_playground.add_agent(my_agent)


engine.run(with_screen=True)
engine.terminate()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0820280296784831, 'fraction_numerical': 0.021846661170651278, 'mean_word_length': 7.857664233576642, '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': '516483', 'license': 'MIT', 'n_tokens_mistral': 778, 'n_tokens_neox': 720, 'n_words': 198, 'path': 'tutorials/colab/05_Fields.ipynb', 'repo_name': 'Asjidkalam/simple-playgrounds', 'size': '2426'}