1

I am planning a project where I will develop bots for Agar.io by using the NEAT algorithm, which is implemented in Java (this is called ANJI). I will use the open-source Agar.io server called Ogar, which is implemented in Javascript. The Javascript implementation should communicate with the Java library to evolve the bots while the game is running, but I have no previous experience of how to make Java and Javascript communicate. I have considered using Rhino, but it does not seem like it is possible to use in a browser. So, are there any way to let a Javascript implementation like Ogar use a Java library?

1
  • A quick googling of "nodejs java" turns up this node module. Did you even try to do research? Commented Apr 13, 2016 at 16:35

2 Answers 2

1

using the Rhino / Nashorm is not relevant in this case and as for performance focus its should be much hard to run nodeJS based application via Java JS engine.

the Agar.io server is a NodeJS server that expose a WebSocket API and the client solution need to communicate this way.

Using spring websocket client for example

have you seen Agar.io-bot ? its seems like the way they implement the BOT is javascript browser extension and communicate via the browser.

Sign up to request clarification or add additional context in comments.

Comments

0

In common, Javascript and Java library communicate using Rest and Json, Java provide Rest API and Javascript send Json request to this API.

This is list of java library: for developing Java Rest API and working with JSON. I recommend using RESTEasy.

1 Comment

That was actually also my initial thought, but then I just kept searching for a solution that could integrate Java and Javascript more tightly. The problem with the Rest/Json-solution is that it might be slower (especially because I need to work with large populations where each agent needs to send a request to the server quite often). But if there is no other way to do it, then I will implement it with the Play-framework.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.