Make the game
 
You will need to specialize 3 classes in C++.
- ACPPlayerStateto expose SetScore to blueprint, this will be used to create a custom reward function
- ACPPawnto make the pawn hostile to everybody, this makes- AISense_Sightsense all the pawn that are in range
- ACPGameModeto provide a custom- HasMatchEndedthat is used to reset the environment
From there everything can be done in blueprint. You will need to create the blueprints below.
- Level: - CartPole
- GameMode_CartPoleinherited from- CPGameMode
- Pawn_Cart(inherited from- Pawn)
- Pawn_Pole(inherited from- CPPawn)
- PlayerState_Cart (inherited from - CPPlayerState)
- PlayerController_Cart (inherited from - PlayerController)
Note
Both PlayerState_Cart and PlayerController_Cart are left empty.
Your input handling could be moved to PlayerController_Cart if you wanted.
GameMode_CartPole
Pawn_Cart
- Add a - FloatingPawnMovementcomponent to enable the cart’s movement
- The cart is composed of a single cube followed by a cylinder rotated 90 degrees i.e - (0, -90, 0)
- The cube is translated - (200, 0, 0)so it can be seen from the default camera
Pawn_Pole
- The pole is a single cylinder 
- Enable physics on the cylinder. 
- You can modify Linear Damping and Angular Damping properties to make the pole easier to balance. 
You should now be able to play the game