Basket Ball Neural Network In Unity by mkwiatkowska003 - 1

Network

Unity 2018.3.3f1Unknown LicenseUpdated 81 days agoCreated on May 29th, 2019
Go to source

Introduction

The main goal of the project was to create a neural network algorithm in C# that could be used for throwing balls to basket with the highest precision. The project is adapted to Unity3D , but the neural network algorithm has been written regardless of requirements of the Unity platform - the engine was used only for simple simulation, testing and verification.

Getting Started

To start the application, open the project from Unity environment and provide the location of the folder downloaded from this site (go to File->Open Project, and then specify a Unity project’s folder). After successful opening, in the Unity environment go to the Assets->Scene and choose the “SampleScene.Unity”. After these steps, the following scene should appear on your screen.

Build and Test

You can click on the “Run” button to start testing, or build it and test as the standalone desktop application.

Guide

User Interface

There is the graphical user interface provided to control the neural network settings. By using its functionality, the user is able to manage values of the following parameters:

  • Hidden layers’ count and size,
  • Time scale - used for managing time during learning,
  • Deviation factor - which means the initial distance between throwed balls,

There are three buttons called by names according to methods they are provided for:

  • Spawn Throwers - creates a simple cube with a random position and starts throwing 27 balls per Time in random directions with the distance between each other according to Deviation Factor,
  • Populate new neural network - starts throwing balls to basket using naural network,
  • Apply new time scale - sets the new Time Scale if the value of Slider is changed.

Camera Control

There are two camera modes with two possible transforms: changing rotation and position. Both rotation and position applies to camera and coudn’t be changed at the same time. By default the camera is in mode Changing Position and the user is able to press the arrows to move the camera in the scene. To set the mode Changing Rotation , the user needs to click the “M” key and start moving the Mouse.

Neural Network in C#

The algorithm is prepared for using not only in Unity engine but also for different platforms. All the main parts of the network are clearly described in separated classes. The neural network learns according to initial position of the cube and the target point which is the basket’s location. It ‘looks for’ the best precision for throwing with the most optimized ball’s trajectory. In every 27-balls group there is one ball with the red color and it means the ball throwed with the neural network algorithm. All the other balls are thrown in the close distance from it.

Show all projects by mkwiatkowska003