Re: [GENERAL] Improve MMO Game Performance

2012-10-19 Thread Torsten Zuehlsdorff

Hello Arvind,

i worked on MMO (and especially their performance) some time ago. I 
really like(d) them. :)



we are all aware of the popular trend of MMO games. where players face



To understand my query, please consider the following scenario
/we store game progress in a postgres table./
A tournament starts with four players and following activity

 1. Each player starts with 100hitpoints
 2. player 1 makes a strike (we refer to a chart to convert blows to
hitpoints with random-range %)
 3. player 2 has 92HP, and returns a light blow, so player1 has 98hp


That is a very simple description or a very simple system.


The above two round will now be in Game Progress Table, as

|ROWPlayer1HP  Player2HP  Strikefrom  StrikeTo  ReturnStrikeHP  Round  
TimeStamp  StrikeMethod
1   100100  0 0 0   0
298 92 P1P22   1
|


At this point you should reconsider if you need this much data. It is 
faster to store less data.


For example you do not need the colum "ReturnStrikeHP". You can 
calculate the damage from the difference between the rows.


If there is a cyclic change of the attacker (P1->P2->P1->P2->P1->P2 ...) 
you just need to store the starting player and could drop the "strik 
from" and "strike to" column.
If you need it and there are just 2 players in one fight, reduce the 
column to "attacker" and store if it is player one or two. The one which 
is not in the column is the defender.


Also why do you store each round? Most time there are just reports, 
charts or animations about the fight. You can generate them in a more 
compact form and just store 1 row with this information. In this way you 
will reduce the number of needed INSERT-operations a lot. And you will 
speed-up the SELECT because less data must be read.


I hope this will help you. Greetings from Germany,
Torsten


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to convert HEX to ASCII?

2011-12-02 Thread Torsten Zuehlsdorff

Damien Churchill schrieb:


after several attempts I have finally succeeded in developing a urlencode()
function to encode text correctly like defined in RFC 1738.

Now i have a big problem: how to decode the text?

Example:
# SELECT urlencode('Hellö World!');
  urlencode
---
 Hell%C3%B6%20World%21

Does anybody know a way to convert '%21' back to '!' and '%C3%B6' to 'ö'?


I've extracted the unquote method [0] from urllib in the python stdlib
that decodes urlencoded strings. Hopefully be some use!


Not directly, but it gives me some helpful hints. For example i'm now 
able to decode some basic characters, for example:


# SELECT chr(x'21'::int);
 chr
-
 !
(1 row)

But i clearly have a missunderstanding of other chars, like umlauts or 
utf-8 chars. This, for example, should return a 'ö':


# SELECT chr(x'C3B6'::int);
 chr
-
 쎶
(1 row)

Also i'm not sure how to figure out, when to decode '%C3' and when to 
decode '%C3%B6'.


Thanks for your help,
Torsten
--
http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8 
verschiedenen Datenbanksystemen abstrahiert,
Queries von Applikationen trennt und automatisch die Query-Ergebnisse 
auswerten kann.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] How to convert HEX to ASCII?

2011-12-02 Thread Torsten Zuehlsdorff

Hello,

after several attempts I have finally succeeded in developing a 
urlencode() function to encode text correctly like defined in RFC 1738.


Now i have a big problem: how to decode the text?

Example:
# SELECT urlencode('Hellö World!');
   urlencode
---
 Hell%C3%B6%20World%21

Does anybody know a way to convert '%21' back to '!' and '%C3%B6' to 'ö'?

Thanks for your help and greetings from Germany,
Torsten
--
http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8 
verschiedenen Datenbanksystemen abstrahiert,
Queries von Applikationen trennt und automatisch die Query-Ergebnisse 
auswerten kann.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general