1

I am developing an MMO shoot-em up similar to the game Realm of the Mad God in Python 2.7.

Player data for the game will include equipment worn, the player's name, etc. for each player of the game, so that when they log off their character, their player data will be saved and preserved in a permanent manner, and when they log on again, their player data will be loaded onto the game. To be safe, I am estimating that the number of unique player data entries will be 1,000,000 entries.

Is it perhaps more efficient to store all player data in one massive txt file, or perhaps 26 files, or perhaps 26*26 files? What is the best way to arrange these entries?

Example entry:

"player1023"|13|1023|482|9|1|4|5|9|3
Sigma Freud
  • 57
  • 1
  • 3

1 Answers1

3

If you don't want to use a database (most natural here), I would suggest to use fixed width records in the file (let say all lines are composed by 80 characters. That way you can achieve a very quick binary search to find lines and you can overwrite a single line without the need to rewrite the whole file.

Emanuele Paolini
  • 9,912
  • 3
  • 38
  • 64
  • 3
    Good suggestion, assuming you can definitely fit everything into a fixed width. But...just use a database. Using sqlite with SQLAlchemy or SQLObject is low-overhead but makes it easy to switch to something more hard-core if it becomes necessary. – Danica Jan 21 '13 at 00:03
  • I will definitely check this out, it looks like the best choice. – Sigma Freud Jan 21 '13 at 00:05
  • however... insertions are anyway a problem. You should also implement an index on a different file so that you append new rows on the huge data file and keep a (relatively) short file with an ordered list of indices in a separate file. Once you have done this you will appreciate more the use of a database :-) – Emanuele Paolini Jan 21 '13 at 00:16