Uh oh! Your current browser is not supported by CodinGame.
You may encounter navigation difficulties. Update your browser with the latest versions of Firefox or Chrome for optimal use.

Loading [Contrib]/a11y/accessibility-menu.js
Back
Close

Basic simulation and evaluation

MadKnight
6,018 views

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);
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants