Path Finding with A*

by Anton Kulikov

The goal of this project was to create an application that would allow the user to work with A* path finding on multiple characters in an environment that would encourage experimentation. On starting the program, the user is presented with a grid of 200 spaces. The user places objects on the grid using a blue cursor. There are three types of objects – obstacles, characters and waypoints. Obstacles mark impassable spaces and characters are moving entities which avoid these obstacles and try to reach waypoints on the board. Each character has its own list of waypoints which he follows, and waypoints can be assigned to a character once it has been selected with the number keys.

Arrow keys – Move cursor

‘O’ key – Place obstacle

‘C’ key – Place and select character

‘W’ key – Add new waypoint at the end of the selected character’s movement order

‘E’ key – Erase obstacle

Numerical keys – Select characters

Spacebar – Start and stop simulation

Once the simulation is started, characters will determine shortest-paths to their destinations and set out along these paths. If a character encounters another character along its movement path, it will do one of two things:

- If the character encountered was created after the current character, the current character will stand still and wait for it to move.

- If the character was created before the current character, the current character will attempt to find a new path around it.

This system of motion results in a very orderly series of character interactions. The characters’ greatest values are laziness and politeness – they don’t particularly care how fast they get to their destinations, as long as they move the least possible distance and don’t force their superiors to move out of their way.

As distance goes – characters can move diagonally, but prefer to move in cardinal directions when they can – as the distance across a horizontal is shorter than the distance across a diagonal.