Python + MySQL = Online Multiplayer?

I saw this article on using Python with MySQL databases :

and I was wondering if it would be fast enough (for a DSL user) to query an online database from within Blender at about 30fps to create an online multiplayer game? I know that quering a database is a little slow but i’m thinking that at about 30fps (actually 20 would be sufficient) it might work - we are talking extreme amounts of querying - simple SELECT and UDPATES on a couple fields… what do you all think about it?

TBL_SERVER

ID IP NAME MAP USERSNOW USERSMAX

TBL_PLAYERS

ID SERVER LOC ROT POS WPN MDL …

All you have to do is download the server list, join a server by creating a new id in the tbl_players and then initialize your location and your player model and then update your individual stats and loop downloading all player stats and uploading your stats - to leave all you have to do is delete your player entry… sounds simple and in theory it is but would it actually work for a real application with about 7users per server?

yes, it would be too slow

[and besides, even if not using mysql you wouldn’t be getting 30 updates/sec]

well, alright, i wouldn’t challenge your python skills! it was just an idea - i know with php and mysql i could get 20 per second with a few fields so i was just curious - of coures that was on local machine so lag time would be more considerable… thanks! :wink:

wait for tempeh to come out, it’s a python network engine cabable of anything from 2 players and up, great scalability.

Actually, MySQL is in fact used for massively online games (at least PlaneShift). The way these kinds of games work is by having a single server program (that does nothing else but crunch data) query MySQL; the clients then talk to that server in a special optimized language. Also, server-client communications never happen at 30 times per second - that is simply too often to even be useful. Normally, massively online games send updates once or twice a second; depending on the situation, that rate may go up or down.

let’s try this again - i went offline to do it and hit the submit button and lost all of my data - so this’ll be more concise:

We need an append actuator - select from a dropdown which data type you want to append (sce, obj, mesh, light etc…), then through a property field (you put a property name in the field and whatever the data in the property is the actual field data) you specify what particular data (ie: OB:camera, ME:cube etc…), and finally another property field provides the .blend location.

The above feature allows newer users to quickly (through the aid of python scripts that are premade for just this kind of online play) to start a game mod of their own.

Something as simple as a python script dumping the data (get to that in a sec) into the property names and then using sensors like “On Property CHange” and a controller and the Append Actuator with the property fields the object could be loaded without any real coding of “when this property changes load this object file name from this file and it’s this kind of data” in script links or through python over and over again for the same kinds of information - just change the property values when done and loop…

So how would this all work? Basically the player gets the game and registers online (creates a user account) then he configures his player (can be changed at any time) and at the same time downloads the server list and selects a preferred server. Saves his configuration in the database and then loads the game. The game downloads his player information from his online account in the database into the preset property names. Then the script links (it could be a python script for faster control but for newbs script links work better and are more configureable) the player models and server map and objects are loaded and initialized to there starting spots and locations. On loading all of that the network engine starts up and connects to the other players and then it passes required user stats back and forth amongst each other. That way they the loc,rot,pos,wpn…etc. are loaded 10-15 times a second while the chat messages and other not so urgent information (player model, health, etc…) is loaded once a second from the database. This requires more python work but wouldn’t require as much database stress.

It sounds okay to me and it would work down to probably 50-60kb/s download speed so it would still be high speed but atleast it wouldn’t require blazing fast - any old dsl would work…

The structure of having it load and initialize allows for expandeability for other online games. By using a game as a template, changing the models in the appended files (which also allows for the possibility of adding and downloading new ones on the fly) and then changing ingame guis and what not a brand new game based on the same engines and scripts could be made! It relieves the user from focusing on the python and network engine to making better players and graphics and optimizing online play!

So, is it possible and worth it? Or is it so left field it’s in the parking lot!?

It would be a good option to save data of players in there, server information, player stats when having an account based online game. So it’s really usefull for saving information in stead the information of player positions. But I think it could be as usefull as well for object placement in levels. So when the game starts it gets in range object positions and durning play it gets another object positions. Like the positions of new villages, enemies, or objects like crates and such stuff.

I think I’ll take a look on this article, thanks :smiley:

its almost a transition from master and slaves to peer to peer and a global access db - all the online blender games could be hosted by one dedicated website and yet the vitals are sent peer to peer - I think it offers the idea of a more expandeable GE and multiplayer experience - it’s still not a perfect solution to everything but I would love to get some of these ideas into the GE!

anyone to help with some of the python - i can get the databases and server and the GE stuff - i’ll need the peer to peer network - maybe Nor.J’s multiplayer project will be out in a few months and i can start testing with that!? It would be a lot of work but it would open up the GE to some money making as multiplayer games - however simple can sell for download for 4.95 like crazy!

I alreayd tried this, I posted a chess game, inwhich if one was movedand soeone else opened the game they would see the peices still moved. A big problem was getting it to update under a second made me stop, I took a good 5-7 seconds for sending and retriving data, making ti only useful for turn based, but even that is a bit extreme. You’d have to compress a lot of data and keep it to a bear min.

lil note:
my try:
https://blenderartists.org/forum/viewtopic.php?t=39745&highlight=mysql

why is python so slow at it? php is blazing fast (usually less than .5 seconds) to retrieve an entire database of over 10,000 rows and 20+ fields - I would think python would be atleast similarly fast! What makes it so slow? You’re talking less than about 1kb/s in database proccessing!

guys. i hate to be a party pooper, but you are not addressing all the issues involved in online play.

The fact is blender is capable of peer to peer, and server/client online games.

The one thing we cannot do is download a new model and have blender add that model to its memory while a game is running.

I’ll give you an example of something you should be thinking about. You should only be updating with a packet of info every 0.5 seconds, and this will hopefully take around 150ms to reach the target. Now, with these packets you need to do some serious maths to interpolate the positions you are getting - so that remotely controlled objects to not jump around the screen. This also includes working with the time differencial and guessing where the player will be because packets dont arrive instantly.

Nor.J has almost finished all this annoying math and network protocol stuff so spend your time learning how to use what he has done when it arrives.

If you really want to speculate about revolutionary ideas you should understand the techniques already in place. search google for network game programming and learn about it. Then you can theorise all you like

-Luke

I don’t think any of us are really theorizing that much - we know that most of these techniques (maybe not the timing) have been done before - we (atleast i am) just want to figure out an efficient way of making an online game template (ie: with the networking - using peer to peer, map loading, player loading/positioning, menus, weapons, etc…) that can be easily modified to create other online games. I think that it has already been mentioned that I plan on using Nor.J’s multiplayer script for the peer to peer - but with alot of “not so important” object data I was proposing another method of getting that information - especially for registration and initializing - perhaps peer to peer is still best for in game data however for initializing mysql sounds like a more efficient method - maybe slower but more accurate - and it allows for a website to pull player stats from the db! Not quite so much theorizing - just questioning - nothing wrong with that - just have to keep in mind that other methods have and probably are better - but unless you actually try it then you’ll never know for sure! :wink: