Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity as a simulator

Discussion in 'Scripting' started by Null_Terminator, Oct 14, 2020.

  1. Null_Terminator

    Null_Terminator

    Joined:
    Sep 19, 2013
    Posts:
    5
    Hey guys,

    I'm trying to create smart agents to do some tasks. In order to evaluate each agent, I want to start a specific scene, parametrize it according to the specific agent, run a simulation, and get a score based on the agent's performance in the scene.

    1. How can I achieve this behavior in Unity? I have a main scene which generates the parameters to create an agent, and a scene to test an agent. From the main scene - create a test scene for each agent, wait for the test to finish, get the score of each agent (computed in the testing scene), repeat. Note that there are a lot of different agents, and testing a few scenes in parallel is preferable.

    2. How can this be achieved outside of Unity? Suppose my agents are generated in a different software, and I want to use Unity as a service (start the Unity process, run the simulation, get a score, terminate the process. Repeat).


    Thanks in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    No idea what "simulation" means in this context, but you probably want to work through a few different tutorial videos for games that use features of Unity that your simulation anticipates needing: physics or whatever, for example.

    You can spawn a Unity game with arguments, you can put stuff in files and have Unity go read it, you can start a server in Unity and communicate with it via TCP/IP, pretty much whatever interprocess communication you like.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  4. Null_Terminator

    Null_Terminator

    Joined:
    Sep 19, 2013
    Posts:
    5
  5. Null_Terminator

    Null_Terminator

    Joined:
    Sep 19, 2013
    Posts:
    5
    Thanks for the reply!

    I suppose that suffices. I was wondering if Unity has something built-in which might save some time, especially if I'm going towards a distributed approach.

    Also, is there a way to run a Unity process at maximal time scale?
    For example, let's say I have an agent moving forward at 1 meter/second and I want to see how far it will go in 10 seconds. There's really no reason to actually wait 10 seconds, it is enough to just compute what happens in these 10 seconds - I don't need to render the simulation graphically.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I would encourage you to ask here https://forum.unity.com/forums/unity-game-simulation.472/