Setting up TestingAcademy

With the TestingAcademy script created, it is time to add it to the game object via the following steps:

  1. Drag the new TestingAcademy script file from the Scripts folder and drop it on to the TestingAcademy object in the Hierarchy window. This will add the component to the object. We want to create a few other components before we complete the academy.
  2. Click in the Hierarchy window, and in the menu, select Game Object | 3D Object | Cube. Rename the new object goal.
  1. Select the object and change the Tag to goal. Then, swap its material by clicking on the Target icon and selecting the v46, or another flashy material of your choice, as shown in the following screenshot:

Swapping the goal object's materials
  1. With the goal object selected from the menu, select Component | Physics | Rigidbody. This will add a physics system component called a Rigidbody. By adding the Rigidbody to the object, we allow it to be controlled by the physics system.
  1. Drag and drop the goal object into the HoDLG | Prefabs folder in the Project window. This will turn the goal object into a Prefab. Prefabs are self-contained objects that contain their own hierarchies. A prefab can contain an entire scene, or just one object, as we have here.  
  2. Select and delete the goal object from the Hierarchy window. In the future, we will programmatically instantiate the goal from the Academy by using its Prefab.
  3. Click inside the HoDLG | Brains folder, and click to open the Create menu. From the menu, select ML-Agents | LearningBrain. Name the new brain TestingLearningBrain, and then create a new player brain called TestingPlayerBrain. Don't worry about configuring the brains just yet.
  4. Select the TestingAcademy object in the Hierarchy window, and then update the values of the Testing Academy component, as shown in the following screenshot:

Setting up TestingAcademy
  1. Notice that we are setting up the following properties in the TestingAcademy script:
    • Brains: TestingLearningBrain
    • Max Steps: 3000
    • Goal: Goal set by dragging the prefab from the folder
    • Num Goals: 3 (number of goals dropped from the box)
    • Goal Size: (50, 50, 50) (determines maximum bounds of the goal box)
    • Goal Center:  (85, 110, -37) (the center point of the goal box)

You may be tempted to run the project at this point; you can if you have just downloaded the code, but hold off until we define the TestingAgent 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