best approach to blocked tiles due to not seeing them.

C++, C#, Java, PHP, ect...
Post Reply
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

best approach to blocked tiles due to not seeing them.

Post by ShawnSwander »

So this isn't a coding question per se but as far as coding goes it's just asking what's best.

I have my game with a 7x7 grid so fairly easy for modern servers to handle 49 1's and 0s in an array

If youre in the game and a wall is north of you the tiles north of that wall will not be visible. I've written this code once and abandoned it. I still have the old script I made on impact engine somewhere

I was thinking instead when my server initializes it could just save 49 arrays in memory for every possible blocked square. My thought is it might save processing time if it doesn't have to calculate blocked squares.

I got the idea from reading about how hackers use rainbow tables to do brute force attacks.

So instead of running through 100 lines every time there is a square that blocks a bad guy's view it just pulls of that table from memory and blocks the squares.

Also FML if I have to write 49 arrays of 1s and 0s by hand but I want the game to run well. I realize I could do calculations like flips and rotates to do it in fewer tables but the idea is that I save processing resources for a very small memory commitment.

Is this a bad way to implement this feature?
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: best approach to blocked tiles due to not seeing them.

Post by hallsofvallhalla »

Overall an array of 49 is so small there won't be much of a hit, or are you sending 49 arrays of 49?
ShawnSwander
Posts: 53
Joined: Thu May 17, 2012 12:31 am

Re: best approach to blocked tiles due to not seeing them.

Post by ShawnSwander »

49 arrays of 49 but they are all binary either you see the tile or you don't. So I bet that's a few KB of memory that can be saved once and used for hundreds of mobs in the game.

It just feels a little ham-fisted to code it that way.
Post Reply

Return to “Coding”