Setting up the TestingAgent

Now, the system that we are building here is fairly generic, and it's intended to be used in multiple environments. Keep that in mind as we set things up, especially if some concepts seem a bit abstract. Open up the editor, and let's add the TestingAgent script to an object:

  1. Select Vehicle1, Vehicle3, Vehicle4, and Vehicle5 in the scene, and disable them. We currently only want to give our agent the ability to drive, and not to switch vehicles; therefore, we only need the default Vehicle2.
  2. Select the TestingAgent script from the HoDLG | Scripts folder and drag it on to the Vehicle2 object. This will add the TestingAgent component to our Vehicle2, and will make it an agent (well, almost).
  3. Open Vehicle2 | Cameras in the Hierarchy window and choose the view that you want the agent to use. We will select Camera2 for this exercise, but the options for each of the five cameras are shown in the following screenshot:
Selecting the visual observation camera to use as an input to the agent
  1. The best options are either Camera1 or Camera5, as shown in the preceding screenshot. Note that the cameras are ordered in reverse, with 1 starting at the far right, not the left. Of course, that leaves plenty of opportunity to play with other visual input in the future.
  1. Select Vehicle2 and drag the selected TestingPlayerBrain and Camera1 into the required slots, as shown in the following screenshot:

Setting up the TestingAgent component
  1. You will also need to define additional properties, which are summarized as follows:
    • Brain: TestingPlayerBrain.
    • Camera 1: Click on Add Camera to add a new camera, and then select Camera1 from the Vehicle2 cameras.
    • Decision Frequency: 10 (this determines how often the agent makes decisions; 10 is a good starting point for this game. It will vary, and you will likely have to tune it to your needs)
    • Axis Action: 2:
      • Element 0: Vertical (denotes the axis we will be overriding to allow the agent to control the game. We will get more into axis descriptions shortly)
      • Element 1: Horizontal (same as the preceding)
  2. Save the project and the scene, and, again, ignore any compiler errors.

That completes the set up of the TestingAgent; as you can see, there isn't a whole lot of configuration or code required to get this running. In the future, you will likely see more advanced ways of testing/debugging or building agents this way. For now, however, we need to complete our example by injecting into the Unity input system, which we will do in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset