best approach to blocked tiles due to not seeing them.

C++, C#, Java, PHP, ect...

best approach to blocked tiles due to not seeing them.

Postby ShawnSwander » Fri Apr 28, 2017 10:35 am

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?
ShawnSwander
 
Posts: 53
Joined: Wed May 16, 2012 7:31 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby hallsofvallhalla » Fri Apr 28, 2017 11:59 am

Overall an array of 49 is so small there won't be much of a hit, or are you sending 49 arrays of 49?
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11599
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 127 times
Blog: View Blog (3)

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

Postby ShawnSwander » Fri Apr 28, 2017 3:40 pm

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.
ShawnSwander
 
Posts: 53
Joined: Wed May 16, 2012 7:31 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

x