Q:

Collision Timing Detecting in Tron Game

So I am trying to a make a Tron LightBike game in C#.NET but I'm running into an issue when two players hit each other at the same time (or a head on collision).
Here is how I initialize the players...
bikes = new ArrayList();
bikes.Add(new LightBike(new Point(500, 10), Color.Blue, "left", new DirectionKeys(Keys.Left, Keys.Down, Keys.Up, Keys.Right))); //blue player facing right
bikes.Add(new LightBike(new Point(10, 10), Color.Red, "right", new DirectionKeys(Keys.A, Keys.S, Keys.W, Keys.D))); //red player facing left
grid = new int[this.Size.Width, this.Size.Height]; //create the grid map
drawThread = new Thread(drawBikes);

It seems like the first player added always wins when there is a head on collision. When I change the order in which the bikes are added to the ArrayList (blue is added second) then red wins. I believe it has something to do with the way I am checking the collisions. I think specifically it has to do with my foreach loop in drawBikes...
Here is the drawBikes method:
while (true)
{

    ArrayList deleteBikes = new ArrayList();
    foreach (LightBike b in bikes)
    {
        if (isValidLocation(b.getNextLocation()))
        {
            canvas.DrawLine(new Pen(b.color, BIKE_SIZE), b.location, b.getNextLocation());
            b.location = b.getNextLocation();
            grid[b.location.X, b.location.Y] = bikes.IndexOf(b)+1;
        }
        else
        {
            deleteBikes.Add(b);
        }

Why does just the red player get removed and not the blue player as well (since they both should essentially hit each other at the same time)? Should I create more threads? I feel like that is unnecessary...
Here is my isValidLocation() code:
public Boolean isValidLocation(Point x)
{
        if (x.X < this.Size.Width && x.X > 0)
            if (x.Y < this.Size.Height && x.Y > 0)
                if (grid[x.X, x.Y] == 0)
                    return true;

    return false;
}

A:

I believe your problem is that you are calling getNextLocation() followed directly by a collision check in your for each loop.  If bike A is the first to be processed in the loop, its position is updated, found to be in collision with bike B, and presumably deleted (I don't know what you do with your deleteBikes list after the else statement).  When the loop moves onto bike B, there is no longer another bike to collide with.
Your code should:

Loop over the bikes and update their positions on the grid.
Loop over the bikes, check if each is in collision, and perform collision logic.
Draw each bike at its new position.  

If a bike was in collision in step 2, it is removed from the list of bikes (or flagged in some way), and is not drawn in step 3.
The key here is that updating the bikes' positions is completely finished before checking for collisions, and drawing is deferred until all collision logic is handled.

