Open ksofiyuk opened 8 years ago
We could use custom created client programs to connect to the server....
have a lot of experience with C++ and Python programming.
P.S: same here... JavaScript seems like a snail compared to C++ ..
There are no existing clients written in Python or C++ or anything like that matter. Either JavaScript or HTML... :( Unless you want to make one ...
Javascript is bottleneck
It is. Especially because it allows just one thread, which is also needed for the slither.io calculations. And I got more experience with other languages too..
A custom client program would be pretty nice :)) 👍
Nice but hard :)
Isn't there a way to build a small programm with a webview running slither.io and bury all logic in c/c++ and only use a small js interface?
Accident - sorry
@Fredyy90 It would be possible but we would still be communicating using JavaScript. Are you saying the back end would be ... And then the frontend would be js ?
I guess we only need Js in this setup to get the data from slither.io out, to process it in c/c++ and a way to return calculated the output stuff, like mouse coordinates, speedboost etc.
Here is a crazy idea (because I do not know C++).
A quick Googling gave me these links: https://discuss.atom.io/t/electron-and-c-dll/17615/2 https://nodejs.org/api/addons.html#addons_hello_world
Now here's how I see it working: Scenario 1 Make a desktop application (with ElectronJS) that is a WebView to slither.io and the user will have to use the app to play the game with the bot.
Scenario 2 An ElectronJS app on users computer will act as a WebSocket server that the browser extension can then talk to. This means that the user doesn't have to use a different application to play the game, but still requires installing an app for the complex calculations at back-end.
@FliiFe Is'nt that what you did for Apos's bot ?
@ErmiyaEskandary It's kinda. But the backend was just sending a list of scripts to load. Implementing script in a backend is, for sure, a good idea, but that would require a lot of work.
Agreed.
@mirorauhala good suggestions. I would add:
Scenario 3 Use asm.js to compile C++ (or other) down to fast javascript.
All of these options are interesting but complicated.
I found this StackOverflow discussion about using node-webkit (now "NW.js") to modify a website like Greasemonkey / Tampermonkey does.
With NW.js, the client-side and server-side are the same thing, so our AI could use node.js features. This also provides indirect access to C++.
Experimental SIMD technology might be useful. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD
The bonus of SIMD is that it's not terribly complicated to use -- it would still work in the browser.
tl;dr it lets you do more math at the same time.
Four math operations:
One math operation:
@ChadSki Great idea, but it looks like we will have to wait a bit...
@ChadSki Oh, and about asm, that wouldn't work since we access game variables and we modify them.
asm wouldn't work since we access game variables and we modify them.
Why wouldn't it work? asm.js code can fully interop with normal javascript.
Example interop between javascript and C++ (compiled to asm.js with emscripten).
This looks handy for the asm.js route: https://github.com/gasman/bonsai-c
bonsai-c is a tool for writing programs, not porting them. By building a C compiler from the ground up, rather than bolting a Javascript backend onto a mature C compiler, we can tailor it to the needs of Javascript programmers. You can use it to write a function for calculating fibonacci numbers, and you will get back an asm.js-compliant Javascript module with an obvious entry point, for calculating fibonacci numbers. You will not get a mountain of runtime code to implement file handling and malloc and a million other things you didn't ask for.
They have a great example of C-js interop here: https://github.com/gasman/bonsai-c/tree/master/examples/mandelbrot
To use bonsai, it looks like you run the .c -> .asm.js transpiler on your local dev machine, then add the generated code to your git commit. The transpiler runs on node.js and can be installed with npm.
I think if we want to create a really good bot need to use general purpose programming languages. I have some complex algorithmic solution for slither, but it seems impossible to implement it using Javascript with realtime performance.
Is there a simple way to connect the game interface with external libraries that are written in Python or C++?
P.S. I'm new in Javascript, but have a lot of experience with C++ and Python programming.