Capstone Project Update #1: Creating a Road System
Jump to a section in this update
During the last week or so, I’ve been working on a modular road system and a level creator to allow the users (and me) to easily create a map with connected roads. I’ve made decent progress, and at this point have a level editor which allows the placement of an arbitrary number of roads which are automatically connected to one another as more roads are placed.
Road System Breakdown
- Path: Holds a list of nodes of a bezier curve. Each potential path between each lane is represented by a Path object. For example, a two-lane straight road has two Paths, whereas a four-way intersection has 12 (straight, left, and right from each of the four entrances). Each Path holds a list of Path(s) it’s connected to.
- RoadConnection: Represents a connection between two roads and an arbitrary number of paths from each. This abstracts the connection process between Paths, such that when two Roads are connected, the outgoing paths of one RoadConnection are automatically connected to the incoming paths of the road it is connected to.
- RoadPiece: Represents a single placeable road tile in the map. This is primarily used by derived classes, such as TwoWayRoad, ThreeWayIntersection, and FourWayIntersection. Each RoadPiece stores its list of Paths and RoadConnections.
The Tricky Part!
The part that gave me the most trouble in implementing what I have so far was automatically changing road types when placing roads down. It needs some cleaning up, but the method I’ve set up is as follows:
- New straight two-way road piece is placed
- For each of the pieces around the newly placed piece, a function is called that transforms that piece to correspond with the new piece.
- If need be, each surrounding piece also transforms the new piece so that it stays connected with any pieces it’s currently connected to.
For example, if a road is placed between three adjacent roads, it will first be turned to meet one adjacent road. It will then be turned into an elbow road to connect the road 90 degrees around. Finally, it will be converted to a three-way intersection to connect to all three roads.
I’ve also implemented a basic path following component. For now, all it does is follow the path around, picking a random direction to turn when it hits a junction. In the future, this will tell the agent how close to the path it is and reward it accordingly.
The functionality as of now
Road placement demo
Showing off the path follower
Up Next
Below you can see where in the schedule for the project we are. So far I’ve made solid progress on implementing the road system and level editor.
February | March | April | May | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Task | Week 1 | Week 2 | Week 3 | Week 4 | Week 1 | Week 2 | Week 3 | Week 4 | Week 1 | Week 2 | Week 3 | Week 4 | Week 1 |
Simulation Setup | |||||||||||||
ML-Agents Setup | |||||||||||||
ML-Agents Training & Testing | |||||||||||||
Integrate ML-Agents into Simulation | |||||||||||||
Polish | |||||||||||||
User Testing | |||||||||||||
Done! |
Coming up, I’ll have to implement traffic signals (stop signs, stop lights, etc.), and begin implementing a car with percepts to train the agents. I also need to enable serialization to save levels made in the level editor. Those will hopefully be wrapped up in the next couple weeks.