Giter Site home page Giter Site logo

codingameframework's Introduction

CodingameFramework

This project contains some Java utilities/tips for Codingame.

When i started on Codingame, i tried to reach legend in a lot of multis. It seems like an opportunity to practice Java 8. My bots were mostly heuristic with no use of a timer. But then, after pushing back as much as possible, i had to do UTTT. It changed my vision of Codingame and now i'm redoing all my previous bots.

Here are some Java tips that i've learned so far :

  • Use a Merger that allows you to code in multiple files. I coded the CodinGame Sponsored Challenge in one file. I had to stop when it wasn't readable anymore (still got to redo it).

  • Use a personal Logger printing time elapsed and class name.

  • Go back to the source. Forget about Java 8 (Stream, Optional...). I even removed foreach loops in UTTT.

  • I use mostly primitives and arrays rather than objects. In this project to store a position, i used a byte rather than an object with x and y fields (see PointUtils).

  • I almost don’t use List, Set, Map... anymore. I have small utilities to use arrays instead of collections (basically the first element of the array is the number of elements in the "list"). It avoids boxing/unboxing, the creation of "useless" objects (Integer, Byte...), to clear a "list" you only set the first element to 0... Look at PlaceUtils to see a use case.

  • I use assertions rather than Unit Tests to make sure that there's no bugs/regressions.
    For example in Spring Challenge 2021 : i kept the state of the game at the beginning of my last turn, then i "guessed" the opponent actions, used my simulation to play my action and his, and compare (with assertions) the result and the game inputs.

  • Create caches (around positions, distances...)

  • One of the main problems using Java in CodingGame (besides its slowness) is garbage collector timeouts. One way to reduce them is to implement the trick in GarbageCollectorUtils (see also JVM memory issues). But mostly you must avoid creating garbage collectable objects. For an example, you can look at the Beam Search implementation.

I'm also starting to use bitboards (but no specific tips for Java).

There's an associated post in the Codingame forum.
Hope it will be helpful.

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.