GithubHelp home page GithubHelp logo

codingame-hs's Introduction

codingame-hs

A simple package to play with the Codingame site.

Usage

For now, this package includes two modules:

  • SourcePackager to create monolithic sources from multiples files.
  • WebServices to gain access to the Codingame web services API from your code.

A typical usage is to combine these two modules to submit a complex bot spanning many modules to the Codingame IDE (or directly to the arena) to test it against other players into a test session:

main = do
        source <- createMonolithicSource "src/Player.hs"
        credentials <- readCredentials "credentials.json"

        -- To play a specific past challenge (using its ID, not its name).
        playInIDE credentials (PastChallengeTitle "coders-strike-back") source [IdeCode, DefaultAi] Nothing

        -- To play any ongoing challenge (if any).
        playInIDE credentials OngoingChallenge source [IdeCode, DefaultAi, DefaultAi, DefaultAi] Nothing

        -- To submit a code into the arena.
        submitToArena credentials OngoingChallenge source

        return ()

If you are looking for a more detailled usage, have a look to this skeleton project which demonstrate how this package could be used in practice during a contest. Among other things, it introduces a small trick to easily replay locally a game, conveniently allowing the use of GHCI to debug the code.

Known limitations

SourcePackager

  • Although the module parses the sources provided to it to create a monolithic output, it won't be able to solve any name clash between functions, nor handle incompatible qualified and/or hidden import directives (so don’t use qualified or any fancy import directives in your local modules).

WebServices

  • Changes in the Codingame web API often break this module, even when they shouldn’t matter.

  • The credentials system should only work for pure Codingame accounts as opposed to linked accounts using Google+ for instance.

Install

The package now uses Stack, so nothing to add.

Since this package is not on Hackage, the simplest way to actually use it for one of your Codingame bots (that’s how I proceed for mines) is to create a dedicated Stack project for you contest bot, download the codingame-hs project alongside, then add the following depenpency into your stack.yaml file:

packages:
- .
- ../codingame-hs

A stack build will (re)build your project as well as the package.

Build environment

At this time (november 2020), Codingame is still using GHC 8.4.3 (as stated in the site’s FAQ) which corresponds to a Stackage LTS 12.14. However, since Haskell tooling is a bit brittle, I prefer to stay up-to-date and use a more recent LTS 16.21 (GHC 8.8.4).

codingame-hs's People

Contributors

chatanga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.