Code Monkey home page Code Monkey logo

Comments (4)

beyretb avatar beyretb commented on June 12, 2024

Hi Phil,

Again I think this has to do with the same issue (see here). After a fresh install and modifying your code as follows (I just changed the import for arena_config and the env.reset(arenas_configurations_input)):

from animalai.envs import UnityEnvironment
from animalai.envs.arena_config import ArenaConfig

arena_config_in = ArenaConfig('configs/obstacles.yaml')
env_name = 'env/AnimalAI'
train_mode = True
env = UnityEnvironment(file_name=env_name)

default_brain = env.brain_names[0]
brain = env.brains[default_brain]

env_info = env.reset(arenas_configurations_input=arena_config_in, train_mode=train_mode)[default_brain]

action = [[0,0]]
env_info = env.step(action)[default_brain]
print("VISUAL OBS: ",env_info.visual_observations)
input("HIT ME: ")
env.close()

I obtain:

VISUAL OBS:  [array([[[[0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         ...,
         [0.44705882, 0.37254902, 0.29019608],
         [0.43137255, 0.36078431, 0.2745098 ],
         [0.42745098, 0.35686275, 0.26666667]],

        [[0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         ...,
         [0.43137255, 0.35686275, 0.26666667],
         [0.44705882, 0.36862745, 0.2745098 ],
         [0.43529412, 0.36470588, 0.26666667]],

        [[0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         [0.19215686, 0.30196078, 0.4745098 ],
         ...,

I will close this issue too, please reopen if you still face this problem after a fresh install.

from animalai-olympics.

pnealgit avatar pnealgit commented on June 12, 2024

from animalai-olympics.

beyretb avatar beyretb commented on June 12, 2024

Hi Phil,

The speed at which you will be able to run the environment and train is very dependent on your hardware.
Also, you need to differentiate two things that can take more or less time:

  • Taking a single step in the environment
  • Training of your algorithm

If I understand your question correctly, your point "1." is regarding training (which library to use to train the agent), and point "2." is related to taking steps in the environment.

Regarding training, you are completely free to implement whichever technique you want using any library you prefer (OpenCV in your case). However, this should not be linked to the performance of the environment and we cannot really help on that side as this part of the challenge is what is required from the participants.

On the environment side, we have optimised the executable as much as possible to prevent the call to env.step() to be a bottleneck. To test for this, you can try to run a few thousand steps in the environment alone (without any training) and see how long it takes, put this code in your example folder and run it:

from animalai.envs import UnityEnvironment
from animalai.envs.arena_config import ArenaConfig
import numpy as np
import time

env = UnityEnvironment(
    n_arenas=1,
    file_name='../env/AnimalAI',
    worker_id=1,
    seed=0,
    docker_training=False,
    play=False
)
env.reset(arenas_configurations=ArenaConfig('configs/justFood.yaml'))

N = 10000
before = time.time()
for _ in range(N):
    env.step(np.random.randint(0, 3, size=2))
after = time.time()

print('Steps per second: {0}'.format(N / (after - before)))
env.close()

on Linux with an i7 and GTX730 I get to 320 steps per second.

Finally, if you wish to re-implement your own communicator and training interface you can do so, but keep in mind that at the time of submission we will expect an agent that implements agent.py (the syntax of which will most likely change by the launch date).
If you still want to follow this route we will not provide help in any other language than python. I can only encourage you to read and debug the code in animalai/envs and familiarise yourself with protobuf which is the protocol used to communicate.

Hope this helps,
Benjamin

from animalai-olympics.

pnealgit avatar pnealgit commented on June 12, 2024

from animalai-olympics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.