Basic simulation and evaluation

MadKnight
17K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Full turn simulation

To simulate a turn, you need to resolve all collisions for the current turn:

void Play(Pod[] pods)
{
    float timeLeft = 1;
    while (timeLeft > 0)
    {
        if (TryFindCollision(out var collision, timeLeft))
        {
            ResolveCollision(collision);
            MovePods(pods, collision.time);
            timeLeft -= collision.time;
        }
        else 
        {
            MovePods(pods, timeLeft);
            break;
        }
    }
    FinishTurn(pods);
}
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content