Sign in to follow this  
ChocoArcher

Fixed-Record size?

Recommended Posts

I'm writing a game and I will have monster data stored as a text file, this text file will be converted to a format provided by allegro (the library I'm using) because it offers some light encryption and compression. Right now I have six fields (realistically I'll have between 10 and 15 upon completion) and expect to have around 300 monsters. Let's assume I have ID (3 characters) Name (30 characters) HP (8 characters) MP (7 characters) Strength (5 characters) Defense (5 characters) That means that right now for 300 monsters it would cost me (3 + 30 + 8 + 7 + 5 + 5) * 300 = 17400 bytes = 17 kB (and probably a bit less after compression). Even double the space for each monster would only be about 35 kB. I am definitely wasting space by using a fixed record size, because obviously not each name will be 30 characters and my first 9 IDs will be 1 character (numbered sequentially) and so on. However, it will take me significianly longer to code (and I'm not 100% clear on how to do it) if I don't use a fixed length for each monster. Should I worry about the wasted space, or should I just get it done the way I know I can do it? Thanks!

Share this post


Link to post
Share on other sites
Given that very few people actually finish a game, I would advise to write it in the way that is easiest and clearest for you. There is usually little use in getting too stressed about such minor issues at the start of a project, unless the size is judged to be crucial to your project (i.e. it has to run on machines with very little in the way of memory).

Don't forget that you can always refactor it to use less memory at some later stage.

Share this post


Link to post
Share on other sites
Thanks, you're right :)

My biggest problem in programming classes were that I'd get too ambitious and never get half of what I wanted to done. I should really accept Stroustrup's "Premature optimization is the root of all evil".

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
moreover - even if you'd finished the game, are you really that concerned about 17KB? That is a tiny amount of data - even a small MS Word file is more than that...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this