Code Monkey home page Code Monkey logo

coders_strike_back's Introduction

Coders Strike Back - Racing Pod

alt text

in action
in action

losing due to collisions
losing due to sub optimal cornering

Ranked in the top 1% worldwide.

Due to the nature of the competition code is limited to a single file.

The approach

This code does not implement genetic algorithms as many have done and instead uses physics and trigonometry to calculate angles, compensations and headings.

The pod will initially head towards its next checkpoint. At a certain distance it will make a small adjustment to its course so as to maximise its angle to the next checkpoint. It is like swerving out before taking a corner so that speed can be maintained.

As the pod approaches the checkpoint, based on the angle to the following checkpoint it will choose a pre-defined cornering sequence. If, for example, it is a very tight turn, such as a hairpin turn, it will shut off the engine and turn to face the next checkpoint. After a delay it will begin thrusting again. This allows cornering to be tight, making the pod just skim the checkpoint.

The code calculates the heading required to compensate for its momentum. In earlier revisions, it would just head towards the centre of the next checkpoint. If there was a lot of sideward momentum on the pod, it sometimes led to the pod orbiting the checkpoint. To remedy this the algorithm calculates a compensated heading.

Areas for improvement

Short of implementing a genetic algorithm, with some tweaking of the parameters for corners, how much compensation is made to side to side momentum and how much the pod prepares for cornering, that it may be possible to rise up in the league a little more.

Or, implementing a way for my second pod to act as a 'blocker' and actively seek to collide with the enemy that is in first position.

Another way is to try and detect a collision before it happens, and try and avoid it. However, this would involve trying to predict the positions of the pods many ticks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.