📜 ⬆️ ⬇️

Dice Wars on App Engine + Twisted

Since August, in my free time, I have been developing an entertaining risk-like toy in the world known as Dice Wars. The ingenious Japanese game designer Taro Ito came up with the wonderful rules of this game and created it on a single-player flash , and it gave rise to many variations on this topic, which are still poorly known in Russia.

In this article, I would like to analyze my first fail with a risk-like game, which I wrote about in March, to tell why I abandoned the idea of ​​using App Engine everywhere and everything, to show a bunch of App Engine + Twisted to which I came and which as it seems to me, quite useful for applications with a permanent connection. In addition, I would like to talk about my experience with Actionscript 3, something like the look of the back end of the developer at this alien technology for me, as well as search here for companions and like-minded people.

First pancake


This winter I got the idea to use App Engine as a server for an application that implements a polling pattern for instantly receiving events from the server. Those. This is an application that sends a request to the server once a second and receives actions from other users, chat messages, and so on. As an example, I decided to make a simple risk-strategy and use Google maps in it, their JavaScript API. And in this game I made two key mistakes, in my opinion such.
Firstly, with all the virtues of JavaScript at the moment, it cannot replace Flash / Silverlight, and many things are difficult to implement. Progressive browsers of course support a lot of good chips, but just like 10 years ago, you have to do ifs / switches for compatibility with other browsers. In addition, the combination of such canvas and Google maps is difficult. This makes it difficult to create various ryushechek, so necessary in games.
Secondly, the use of polling turned out to be bad ideas, and not because it creates a heavy load on the App Engine, it will cope with this, but due to the fact that polling is difficult to develop.
Since then, the Channel API has appeared, but it still does not provide the flexibility that you have in developing your server that supports a permanent connection. It's one thing when all the objects are loaded inside the program, you freely operate them and distribute the load among the servers according to your logic, and another thing is when you cannot be sure which server the request came in and you need to re-request all the objects again do not request unnecessary objects and cares about the cache in memcache. I hope in the future Google will introduce a more convenient and flexible work with an instance (inctance) of the application.

Actionscript 3 for VIM lovers


I made several approaches to learning Flash, tried to read books, opened a Flash IDE and every time I experienced some kind of inexplicable rejection to all these buttons, windows, helpers. The Flash IDE is not quite similar to environments such as Eclipse or Visual Studio and requires careful study. The solution was simple. There is a Flex SDK, an mxmlc compiler, and with them the development turns out to be traditional. For VIM there is a plugin , and Actionscript 3 is a nice modern object-oriented programming language. If you experience similar problems, then perhaps you should try this way.

App Engine + Twisted



The diagram to which I have now come is shown in the figure. Game mechanics moved to a separate Linux server running a daemon that accepts persistent connections from clients. To create a permanent connection on the client, Flash is used, and when there is a shortage of Linux server power, the game quite simply scales. This is not a universal solution for all occasions and it assumes that you can split game objects on different servers. In my case, the games take place in different "rooms" and these rooms can be located on different servers, everything inside the room fits on one server.
If you would make a super global game in which in one location you would play one hundred five hundred thousand million people who would dynamically interact with each other, then most likely the Channel API would be able to offer you a more flexible approach in this case.
App Engine in my scheme has become a central authentication server and statistics server. When a client connects to Twisted, for authentication, Twisted makes a request to the App Engine and checks if that client is who it claims to be. Statistics is just a great area to use App Engine.
')

Authentication Library



For various authentication, I wrote a library, the class diagram of which is shown in the figure. The End User applications are inherited from the User library, which in turn is linked through a composition with various authentication schemes.
All this happens on the App Engine server and for the Twisted server it doesn't matter where the client came from.

Looking for companions


Currently, I have problems with design and with promotion (marketing). If you understand any of this, you have free time, the desire to do something, but you do not know who to join, I would be happy to share the charms of the creative process with you, just send me a personal message or email. The desire to find professionals in their field, the ability to someday create a strong development team, were among the goals for which I wrote this article.

Links


Game site In Cubes
Facebook app
Application In Contact
Application in My World

Source: https://habr.com/ru/post/108527/


All Articles