Giter Club home page Giter Club logo

codenjoy-java-client's Introduction

This project represents a basic java websocket client for the codenjoy platform. It allows you to easily and quickly join the game, developing your unique algorithm, having a configured infrastructure.

What do you need to get started?

To get started, you should define the desired game and enter a value in com.codenjoy.dojo.Runner.GAME.
The second important thing is the connection token to the server. After successful authorization on the site, you must copy the url and enter a value in com.codenjoy.dojo.Runner.URL.
This is enough to connect and participate in the competition.

How to run it?

To start a project from the console window, you must first perform build with Maven mvn clean package -Pjar-with-dependencies. The entry point for starting a project is com.codenjoy.dojo.Runner.main(args).
You can pass the game type and token connection to the server as command-line arguments. Game parameters passed by arguments at startup have a higher priority than those defined in the code.

The archive is run with the command java -jar target/client-exec.jar [<game>] [<url>]

How does it work?

The elements on the map are defined in com.codenjoy.dojo.games.<gamename>.Element. They determine the meaning of a particular symbol. The two important components of the game are the com.codenjoy.dojo.games.<gamename>.Board game board and the com.codenjoy.dojo.games.<gamename>.YourSolver solver.

Every second the server sends a string representation of the current state of the board, which is parsed in an object of class Board. Then the server expects a string representation of your bot's action that is computed by executing YourSolver.get(board).

Using the set of available methods of the Board class, you improve the algorithm of the bot's behavior. You should develop this class, extending it with new methods that will be your tool in the fight. For example, a bot can get information about an element in a specific coordinate by calling AbstractBoard.getAt(x, y) or count the number of elements of a certain type near the coordinate by calling AbstractBoard.countNear(x, y, element), etc.

Business logic testing

Writing tests will allow you to create conclusive evidence of the correctness of the existing code. This is your faithful friend, who is always ready to answer the question: "Is everything working as I expect? The new code did not break my existing logic?".
The com.codenjoy.dojo.client.<gamename>.BoardTest class contains a set of tests that check board tools. Implementation of new methods should be accompanied by writing new tests and checking the results of processing existing ones.
Use com.codenjoy.dojo.games.<gamename>.YourSolverTest.should_when() to check the bot's behavior for a specific game scenario.

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.