Jump to content
Sign in to follow this  
domob

Easy development of Xaya games with libxayagame

Recommended Posts

Since Xaya is not just a blockchain project but a platform for blockchain games, we are not only working on the core blockchain infrastructure but also additional layers that make it easy to develop fully decentralised games.  The first step in this direction is the game-specific ZeroMQ interface we designed, whose main parts are already implemented and tested in the Xaya Core daemon.  Using this interface directly, however, still requires messing around with potentially unreliable ZMQ notifications and handling of blockchain-specifics like reorgs.

Thus, we are also building libxayagame:  A library that interfaces to the core daemon through the ZMQ interface and handles all the blockchain-specific processing.  This makes it super easy to develop fully decentralised games on the Xaya platform, without any prior blockchain experience or knowledge.  All you have to do to implement a game is to provide functions that implement your game rules; namely by computing a new game state from the old state and a set of moves.  The library then handles all the rest for you.

This is still very much a work in progress with lots of missing pieces before it can be used in production, but it can already be used in development and early testing.  So if you are interested in developing a game on Xaya, I strongly encourage you to take a look at libxayagame and the integrated example game "Movers".  It can probably save you a lot of messing around with ZeroMQ, blockchain reorgs and other stuff.

  • Like 3

Share this post


Link to post
Share on other sites

Nice ? did you plan to release something for JavaScript too or should I try to build something with the same behavior myself?

Share this post


Link to post
Share on other sites

You mean, to develop the actual game daemon in JavaScript (not the frontend)?  No, I do not have plans for that.  However, I am working on a wrapper that makes it easy to use libxayagame from any language that has interoperability with C.  I do not know if that applies to JavaScript, to be honest.

But in general, I think you should try to avoid redoing what libxayagame does yourself.  We can certainly discuss what methods there are to use the library from JS.

(I personally like JavaScript as a language due to its functional concepts, but have only used it for web development and would not really think about using it to write a backend daemon.)

Share this post


Link to post
Share on other sites

Before some weeks I read the xaya specs for the interface (https://github.com/xaya/Specs/blob/master/interface.md) and I think I can get the attached/detached blocks from ZMQ and handle RPC calls myself. So I can build a working daemon myself with NodeJS.

So I just have to save the old X states to recreate the current state I get from ZMQ if a block is detached

And sending RPC calls are part of my game engine to make transactions.

Maybe I try to build it on my own

Share this post


Link to post
Share on other sites

Yes, you can do that, of course.  That's basically what libxayagame does itself - but there are quite a few tricky cases to think about (like missed ZMQ notifications), so you need to be careful in developing this part.

If there is any kind of framework for calling C functions from NodeJS or the other way round, you may be able to use libxayagame to simplify things.  But if not and you want to talk to the daemon directly, it is certainly doable as well.

Share this post


Link to post
Share on other sites

Hey,

I know this is an older conversation, but I found something while researching for the blockheader pool thing. NodeJs can make your C code working in like native JS code 👍

Quote

The process looks as follows.

You create a file with some C/C++ code (it may call some 3rd party library), place binding.gyp configuration file in the root of your project, telling what exactly needs to be compiled natively (more on that later), add gypfile: true flag to package.json, run yarn install (or, npm install). It will compile your C++ code into a /build/Release/<name>.node file, that later on can be referenced from inside JavaScript code and used as if it was a regular JavaScript module. You don’t even need the node-gyp module installed globally (or, locally) for that, because npm (or, yarn) can use the built-in node-gyp library to compile your code.

This <name>.node thingy is called an “addon” in Node.js terminology.

Node.js Addons are dynamically-linked shared objects, written in C/C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js module. They are used primarily to provide an interface between JavaScript running in Node.js and C/C++ libraries.

Regards

Edited by casp0or

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

Your use of this site is governed by our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.