Nodejs Game loop and external script files

Well, first of all, I'm new to nodejs, and its appearance amazes me!

I really would like to create a game with bot players in nodes. The idea is for bots to play some kind of game (for example, checkers).

First question:

  • Is nodejs appropriate for this purpose? Please note that the main idea is not to create a game, but to gain experience with asynchronous programming, and especially nodejs (well, because node is cool and awesome!).

Then I ran into another problem. When writing a web server in nodejs is simple (there are millions of examples on the net), there is almost no example of how to write an infinite loop without locking an event loop, so the second question:

  • How to write an endless game loop without blocking the main even cycle? In C / C ++, I would do something like while (gIsRunning) {doStuff (); gIsRunning = gameEnded (); sleep (ms) / delay (ms); }

Of course, in my case, the game is endless (because the players are bots) and should be executed until I manually kill the node process.

Since the game is focused on the bot, I would like to be able to write bots in JS and include them in the main game engine. So third

  • Is it possible to write bots as stand-alone JS script and then load them into the main game engine running node in some limited environment (sandbox)? The future idea is to provide some basic API for developing bots, and I do not want to run third-party bots with full functionality (fs, sockets, etc.). Also, I do not want to manually check the code of each third-party bot.

, "Google AI Challenge". Google - SDK , "". , nodejs, , SDK .

, , SO ( node , , ).

!

+3

All Articles