AI 4 U by gilcoder - 2


AI4U provides an easy way to connect python code with Unity games. This way, you can use the entire available Python machine learning culture to experiment machine learning algorithms and artificial intelligence with Unity.

Unknown VersionMIT LicenseUpdated 13 days agoCreated on August 26th, 2019
Go to source

Running example ballroller

What is AI4U?

AI4U is a neat and easy way to connect a Unity application to Python code. Therefore, it is possible with AI4U plugin connecting games and virtual reality applications to vast libraries set written in Python. Moreover, One provides integration with the latest algorithms implemented by OpenAI, e.g., PPO and PPO2. So, people interested in AI4U can use more recent advances given by OpenAI researchers.


  • Some examples.
  • Support for multiple environment configurations and training scenarios
  • Flexible SDK that can be integrated into your game or custom Unity scene
  • API agnostic, but one provides support to all algorithms implemented by stable-basiles.
  • Integrated A3C implementation.
  • Tools for facilated no-markovian decision making.
  • AI4U can be integrated to Imitation Learning through Behavioral Cloning or Generative Adversarial Imitation Learning present on stable-baslines.
  • Train robust agents using environment randomization.
  • Flexible agent control with On Demand Decision Making.
  • Train using multiple concurrent Unity environment instances.
  • Unity environment partial control from Python.
  • Wrap Unity learning environments as a gym.


Some projects were developed with AI4U. The list of major projects is shown in Table 1.

Table 2: Documentation.

Tutorial Link
MazeWorld Link
MemoryV1 Link
BoxChaseBall Link
TMazeRegretExperiment Link

How to use the AI4U?

AI4U has two components: * the server-side code written in C#. The second is the * client-side code written in Python.

For using AI4U, we recommend to have some version of Unity 2019 and start by looking at the examples available in the repository AI4UExamples. Start by example AI4UExamples/CubeAgent for the first look in AI4U. Also, see the documentation available in directory doc. See the complete documentation in Table 2.

Table 2: Documentation.

Tutorial Link
API Overview doc/
AI4U with OpenAI Gym doc/
A3C Implementation doc/
GMPROC (multiprocessing) GMPROC


First, it needs to install clientside component. Open the Ubuntu command-line console and enter in directory clientside/ai4u. Run the following command:

pip3 install -e .

Waiting for the installation ends, this may take a while. To install gym and a3c algorithm support, go to directory clientside/gym and run the following command:

pip3 install -e .

Waiting for the installation ends.

Now, run Unity and open project available in exemples/BallRoller. Then open the BallRoller scene (available on Assets/scenes) if it is not already loaded.

Menu File --> Open Scene

Menu File --> Open Scene

Then, press the play button and run the script located in examples/BallRoller/Client.

Pressing play button


Running example ballroller

Output logs: See output logs

If no error message was displayed, then AI4U was installed correctly.


Tested Systems

  • Operation System: Ubuntu 18.04, and 19.10.

    • Python >= 3.7.5.
    • Unity >= 2019.4 (64 bits for GNU/Linux).
  • Operation System: Ubuntu >= 20.04

    • Anaconda Python “3.7” version
    • Unity >= 2019.4 (64 bits for GNU/Linux).
  • Operation System: Windows 10

    • Anaconda Python “3.7” version.
    • Unity >= 2019.4 (64 bits for Windows)

Unfortunately, AI4U does not have support for mobile applications.


AI4U is currently maintained by Gilzamir Gomes (, Creto A. Vidal (, Joaquim B. Cavalcante-Neto ( and Yuri Nogueira (

Important Note: We do not do technical support, nor consulting and don’t answer personal questions per email.

#How To Contribute To any interested in making the AI4U better, there is still some documentation that needs to be done. If you want to contribute, please read guide first.


AI4U was created in the CRab (Computer Graphics, Virtual Reality and Animations) Labs at UFC (Universidade Federal do Ceará).

Show all projects by gilcoder