Last update June 29, 2003

ICFP /
Design Overview



as we already have the optimal path, here's some possible solution for driving the car along it: I'll give pseudo-code in D as example:

driveAlongPath(Path optimalPath) {
    PathCell currentCell = optimalPath.start;
    Car car = new Car();
    car.startOn(currentCell.x, currentCell.y);
    while (currentCell != null) {
        nextCell := currentCell.next;
        car.moveTo(nextCell);
        if (car.isAt(nextCell)) {
            currentCell = nextCell;
        }
    }
}
moveTo(Cell cell) {
    Angle axis = cell.axisFrom(car.x, car.y);
    Angle diff = car.direction.anglediff(axis);
    char[] actions = car.calculateMinimumArcNecessaryToTurnAroundBy(diff);
    car.perform(actions);
}

This way we can follow the optimal path already in our hands and only have to handle left or right turns correctly. Of course a variation of this algorithm would include vectorization information about the path, so we can know how, and when we need to accelerate and brake to make our turns very small and quick. IIRC there are some easy formula to calculate belziers to round corners of vectors. I did something like that when I was trying to deal with .swf format, but I'm too tired to remember. A version of this simpler algorithm is already in CVS (untested and unproved).

Any thoughts?

-- DanielYokomiso?


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: June 29, 2003 9:38 (diff))