-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ec7064e
Showing
10 changed files
with
762 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Evolving Beings | ||
|
||
## Conda environment | ||
|
||
### Create environment | ||
|
||
```bash | ||
conda env create -f environment.yml | ||
``` | ||
|
||
### Update environment after pulling new changes | ||
|
||
```bash | ||
conda env update --file environment.yml --prune | ||
``` | ||
|
||
### Update env file after dependencies: | ||
|
||
```bash | ||
conda env export > environment.yml | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: evolving | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- appnope=0.1.3=pyhd8ed1ab_0 | ||
- argon2-cffi=21.3.0=pyhd8ed1ab_0 | ||
- argon2-cffi-bindings=21.2.0=py38h33210d7_2 | ||
- asttokens=2.0.5=pyhd8ed1ab_0 | ||
- attrs=21.4.0=pyhd8ed1ab_0 | ||
- backcall=0.2.0=pyh9f0ad1d_0 | ||
- backports=1.0=py_2 | ||
- backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0 | ||
- beautifulsoup4=4.11.1=pyha770c72_0 | ||
- bleach=5.0.0=pyhd8ed1ab_0 | ||
- brotli=1.0.9=h1c322ee_7 | ||
- brotli-bin=1.0.9=h1c322ee_7 | ||
- bzip2=1.0.8=h3422bc3_4 | ||
- ca-certificates=2021.10.8=h4653dfc_0 | ||
- certifi=2021.10.8=py38h10201cd_2 | ||
- cffi=1.15.0=py38hc67bbb8_0 | ||
- cycler=0.11.0=pyhd8ed1ab_0 | ||
- debugpy=1.6.0=py38hea55cf5_0 | ||
- decorator=5.1.1=pyhd8ed1ab_0 | ||
- defusedxml=0.7.1=pyhd8ed1ab_0 | ||
- entrypoints=0.4=pyhd8ed1ab_0 | ||
- executing=0.8.3=pyhd8ed1ab_0 | ||
- flit-core=3.7.1=pyhd8ed1ab_0 | ||
- fonttools=4.33.3=py38he5c2ac2_0 | ||
- freetype=2.10.4=h17b34a0_1 | ||
- giflib=5.2.1=h27ca646_2 | ||
- importlib-metadata=4.11.3=py38h10201cd_1 | ||
- importlib_resources=5.7.1=pyhd8ed1ab_0 | ||
- ipykernel=6.13.0=py38h2cb4d76_0 | ||
- ipython=8.3.0=py38h10201cd_0 | ||
- ipython_genutils=0.2.0=py_1 | ||
- ipywidgets=7.7.0=pyhd8ed1ab_0 | ||
- jbig=2.1=h3422bc3_2003 | ||
- jedi=0.18.1=py38h10201cd_1 | ||
- jinja2=3.1.2=pyhd8ed1ab_0 | ||
- jpeg=9e=h1c322ee_1 | ||
- jsonschema=4.5.1=pyhd8ed1ab_0 | ||
- jupyter=1.0.0=py38h10201cd_7 | ||
- jupyter_client=7.3.1=pyhd8ed1ab_0 | ||
- jupyter_console=6.4.3=pyhd8ed1ab_0 | ||
- jupyter_core=4.9.2=py38h10201cd_0 | ||
- jupyterlab_pygments=0.2.2=pyhd8ed1ab_0 | ||
- jupyterlab_widgets=1.1.0=pyhd8ed1ab_0 | ||
- kiwisolver=1.4.2=py38h0f71543_1 | ||
- lcms2=2.12=had6a04f_0 | ||
- lerc=3.0=hbdafb3b_0 | ||
- libblas=3.9.0=14_osxarm64_openblas | ||
- libbrotlicommon=1.0.9=h1c322ee_7 | ||
- libbrotlidec=1.0.9=h1c322ee_7 | ||
- libbrotlienc=1.0.9=h1c322ee_7 | ||
- libcblas=3.9.0=14_osxarm64_openblas | ||
- libcxx=14.0.3=h6a5c8ee_0 | ||
- libdeflate=1.10=h3422bc3_0 | ||
- libffi=3.4.2=h3422bc3_5 | ||
- libgfortran=5.0.0.dev0=11_0_1_hf114ba7_23 | ||
- libgfortran5=11.0.1.dev0=hf114ba7_23 | ||
- liblapack=3.9.0=14_osxarm64_openblas | ||
- libopenblas=0.3.20=openmp_h2209c59_0 | ||
- libpng=1.6.37=hf7e6567_2 | ||
- libsodium=1.0.18=h27ca646_1 | ||
- libtiff=4.3.0=h77dc3b6_3 | ||
- libwebp=1.2.2=h0d20362_0 | ||
- libwebp-base=1.2.2=h3422bc3_1 | ||
- libxcb=1.13=h9b22ae9_1004 | ||
- libzlib=1.2.11=h90dfc92_1014 | ||
- llvm-openmp=14.0.3=hd125106_0 | ||
- lz4-c=1.9.3=hbdafb3b_1 | ||
- markupsafe=2.1.1=py38h33210d7_1 | ||
- matplotlib=3.5.2=py38h150bfb4_0 | ||
- matplotlib-base=3.5.2=py38hd7f6e49_0 | ||
- matplotlib-inline=0.1.3=pyhd8ed1ab_0 | ||
- mistune=0.8.4=py38hea4295b_1005 | ||
- munkres=1.1.4=pyh9f0ad1d_0 | ||
- nbclient=0.5.13=pyhd8ed1ab_0 | ||
- nbconvert=6.4.5=py38h10201cd_0 | ||
- nbformat=5.4.0=pyhd8ed1ab_0 | ||
- ncurses=6.3=h07bb92c_1 | ||
- nest-asyncio=1.5.5=pyhd8ed1ab_0 | ||
- notebook=6.4.11=pyha770c72_0 | ||
- numpy=1.22.3=py38h4084d66_2 | ||
- openjpeg=2.4.0=h062765e_1 | ||
- openssl=3.0.3=ha287fd2_0 | ||
- packaging=21.3=pyhd8ed1ab_0 | ||
- pandocfilters=1.5.0=pyhd8ed1ab_0 | ||
- parso=0.8.3=pyhd8ed1ab_0 | ||
- pexpect=4.8.0=pyh9f0ad1d_2 | ||
- pickleshare=0.7.5=py_1003 | ||
- pip=22.0.4=pyhd8ed1ab_0 | ||
- prometheus_client=0.14.1=pyhd8ed1ab_0 | ||
- prompt-toolkit=3.0.29=pyha770c72_0 | ||
- prompt_toolkit=3.0.29=hd8ed1ab_0 | ||
- psutil=5.9.0=py38h33210d7_1 | ||
- pthread-stubs=0.4=h27ca646_1001 | ||
- ptyprocess=0.7.0=pyhd3deb0d_0 | ||
- pure_eval=0.2.2=pyhd8ed1ab_0 | ||
- pycparser=2.21=pyhd8ed1ab_0 | ||
- pygments=2.12.0=pyhd8ed1ab_0 | ||
- pyparsing=3.0.8=pyhd8ed1ab_0 | ||
- pyrsistent=0.18.1=py38h33210d7_1 | ||
- python=3.8.13=hd3575e6_0_cpython | ||
- python-dateutil=2.8.2=pyhd8ed1ab_0 | ||
- python-fastjsonschema=2.15.3=pyhd8ed1ab_0 | ||
- python_abi=3.8=2_cp38 | ||
- pyzmq=22.3.0=py38h5f86631_2 | ||
- readline=8.1=hedafd6a_0 | ||
- send2trash=1.8.0=pyhd8ed1ab_0 | ||
- setuptools=62.2.0=py38h10201cd_0 | ||
- six=1.16.0=pyh6c4a22f_0 | ||
- soupsieve=2.3.1=pyhd8ed1ab_0 | ||
- sqlite=3.38.5=h40dfcc0_0 | ||
- stack_data=0.2.0=pyhd8ed1ab_0 | ||
- terminado=0.13.3=py38h10201cd_1 | ||
- testpath=0.6.0=pyhd8ed1ab_0 | ||
- tk=8.6.12=he1e0b03_0 | ||
- tornado=6.1=py38h33210d7_3 | ||
- traitlets=5.2.0=pyhd8ed1ab_0 | ||
- unicodedata2=14.0.0=py38h33210d7_1 | ||
- wcwidth=0.2.5=pyh9f0ad1d_2 | ||
- webencodings=0.5.1=py_1 | ||
- wheel=0.37.1=pyhd8ed1ab_0 | ||
- widgetsnbextension=3.6.0=py38h10201cd_0 | ||
- xorg-libxau=1.0.9=h27ca646_0 | ||
- xorg-libxdmcp=1.1.3=h27ca646_0 | ||
- xz=5.2.5=h642e427_1 | ||
- zeromq=4.3.4=hbdafb3b_1 | ||
- zipp=3.8.0=pyhd8ed1ab_0 | ||
- zlib=1.2.11=h90dfc92_1014 | ||
- zstd=1.5.2=h861e0a7_0 | ||
- pip: | ||
- arcade==2.6.13 | ||
- pillow==9.0.1 | ||
- pyglet==2.0a2 | ||
- pymunk==6.2.1 | ||
- pytiled-parser==2.0.1 | ||
- typing-extensions==4.2.0 | ||
prefix: /opt/homebrew/Caskroom/miniforge/base/envs/evolving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import arcade | ||
|
||
from src.world import World | ||
|
||
SCREEN_WIDTH = 500 | ||
SCREEN_HEIGHT = 500 | ||
SCREEN_TITLE = "Evolving Beings" | ||
|
||
|
||
class EvolvingBeings(arcade.Window): | ||
def __init__(self): | ||
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) | ||
|
||
self.world = World(250, 250) | ||
self.world.spawn(10) | ||
|
||
def setup(self): | ||
"""Sets up the world for the current simulation""" | ||
pass | ||
|
||
def on_key_press(self, key: int, modifiers: int): | ||
"""Processes key presses | ||
Arguments: | ||
key {int} -- Which key was pressed | ||
modifiers {int} -- Which modifiers were down at the time | ||
""" | ||
|
||
def on_key_release(self, key: int, modifiers: int): | ||
"""Processes key releases | ||
Arguments: | ||
key {int} -- Which key was released | ||
modifiers {int} -- Which modifiers were down at the time | ||
""" | ||
|
||
def on_update(self, delta_time: float): | ||
"""Updates the position of all game objects | ||
Arguments: | ||
delta_time {float} -- How much time since the last call | ||
""" | ||
pass | ||
|
||
def on_draw(self): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
window = EvolvingBeings() | ||
window.setup() | ||
arcade.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import numpy as np | ||
from math import cos, sin | ||
import random | ||
|
||
# Hyper-parameters | ||
ENERGY_LOSS_GENERAL = 0.1 | ||
ENERGY_LOSS_ACTIONS = 0.2 | ||
|
||
FOOD_TO_ENERGY = 0.1 | ||
WATER_TO_ENERGY = 0.1 | ||
|
||
# Rotation vectors for movement | ||
theta = np.deg2rad(45) | ||
rot_right = np.array([[cos(theta), -sin(theta)], [sin(theta), cos(theta)]]) | ||
rot_left = np.array([[cos(-theta), -sin(-theta)], [sin(-theta), cos(-theta)]]) | ||
|
||
|
||
class Being: | ||
""" | ||
Living being representation. If energy reaches 0 it will be dead | ||
Energy goes down when performing actions, low energy leads to lower happiness. | ||
""" | ||
# Subjective states (things the "brain" feels) | ||
happiness = 1 | ||
hunger = 0 | ||
thirst = 0 | ||
|
||
# Objective states (hidden from the "brain") | ||
food = 1 | ||
water = 1 | ||
energy = 1 | ||
|
||
direction = [1, 0] # vector from (0,0) (the being) to the direction its facing | ||
action_space = ['NOOP', 'TURN_LEFT', 'TURN_RIGHT', 'MOVE', 'EAT', 'DRINK'] | ||
|
||
def choose_action(self): | ||
action = random.choice(self.action_space) | ||
|
||
if action != 'NOOP': | ||
self.energy -= ENERGY_LOSS_ACTIONS | ||
|
||
if action == 'TURN_LEFT' or action == 'TURN_RIGHT': | ||
rot = rot_left if action == 'TURN_LEFT' else rot_right | ||
self.direction = np.round(np.dot(rot, self.direction), 0).astype(int) | ||
|
||
return action | ||
|
||
def step(self): | ||
self.energy -= ENERGY_LOSS_GENERAL | ||
|
||
if self.food > 0: | ||
self.food -= FOOD_TO_ENERGY | ||
self.energy += FOOD_TO_ENERGY | ||
|
||
if self.water > 0: | ||
self.water -= WATER_TO_ENERGY | ||
self.energy += WATER_TO_ENERGY | ||
|
||
def color(self): | ||
return 155 + self.energy * 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Cell: | ||
def __init__(self, x, y): | ||
self.x = x | ||
self.y = y | ||
self.type = 'NONE' | ||
self.content = None | ||
|
||
def update(self, type, content=None): | ||
self.type = type | ||
self.content = content | ||
|
||
def color(self): | ||
if self.type == 'NONE': | ||
return 0 | ||
|
||
if self.type == 'BEING': | ||
return self.content.color() |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.