Sports Simulation Database

Monkey Forums/Monkey Programming/Sports Simulation Database

Afrobear(Posted 2015) [#1]
I want to make a sports sim game and I've been wondering how I should make the database for it.

Let's say the game's gonna have 20.000+ players, 500+ teams, etc, etc.

What's the "best" way to do this?

I thought of making arrays for each of their stats, like:

PlayerName[]
PlayerAge[]
etc..

PlayerName[0] would save the name of player of ID 0, PlayerAge[0] would save his age. PlayerName[116] would save ID 116 player's name, and so on...

I don't think objects would be a reasonable way so I kinda discarded it.

Or saving stuff to a txt would be better? Would be more complex and accessing it would be slower but wouldn't waste so much memory.

Waiting for your opinions... Thanks! :)


muddy_shoes(Posted 2015) [#2]
There is no general best way. What suits your game for in-memory and storage structure will depend on the platforms you target and your query pattern. The most flexible approach is probably to use something like SQLite and create in-memory caches for the most frequent accesses. That could well be over-engineered if you have simple access requirements though.


nullterm(Posted 2015) [#3]
Depends how much each player takes.

If a player is 100 bytes, then you could keep everything in memory (100 x 20,000 = 2 megs).

If a player is 10,000 bytes (200 meg total), then you'll need to keep everything on disk and only read in relevant players in a memory cache like muddy_shoes said.

Objects might be fine. I'd go that route. Really there's two paths (http://stackoverflow.com/questions/17924705/structure-of-arrays-vs-array-of-structures-in-cuda):

Arrays of Structures:
players:Player[]

Structure of Arrays:
playerName:String[]
playerAge:Int[]

I'd prefer AoS. And (if a large db) just load/cache only players being "used" by the simulation.

SoA makes more sense if you are doing super hardcore highly optimized operations across all players (like averaging all the ages of all players).


Paul - Taiphoz(Posted 2015) [#4]
You could store all of this in some xml files, and then just dynamically load the data when you need it during your games loading sequences, if you split the data into smaller files, like 1 teams.xml that holds all team names, managers, colours etc, then files per team which holds all that teams player names and coach names etc, then a file listing every player and his stats.

Then you Team 1 vs Team 2, you just load those teams xml files to get their players etc..