• Advertisement

Strategy game: Limiting wall thickness the player can build

Recommended Posts

Hi!
I'm making a tile-based strategy game. I need some way to prevent the player from building too thick walls. I might want to limit it to single or double thickness. I DON'T want the player to be able to just fill in any amount of tiles to make a super thick wall. Think Dune 2 or warcraft 1 or similar = each tile can house a "wall-building" which is 1x1 tiles big. 

Just making a simple rule like: "do not allow placing a wall if two/five adjacent tiles already is walls" doesnt work (for single/double thickness limitation).

Any idea?

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)
33 minutes ago, suliman said:

Just making a simple rule like: "do not allow placing a wall if two/five adjacent tiles already is walls" doesnt work (for single/double thickness limitation).

In each direction, count the number of wall tiles. If the maximum is more or equal to the max thickness, do not allow.

def test(x, y, max_thickness):
  for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
    ok = False
    for n in range(1, max_thickness + 1):
      xpos, ypos = x + dx * n, y + dy * n
      if xpos < 0 or ypos < 0 or xpos >= MAX_X or ypos >= MAX_Y:
        ok = True
        break
      if tile[xpos, ypos] != WALL:
        ok = True
        break
        
    if not ok:
      return False
    
  return True

 

Edited by Alberth

Share this post


Link to post
Share on other sites

Is that python? :)

But if I have a gap in the wall (five walls, one tile with no wall, five walls) that will prevent the player from refilling that gap in the wall since to the left and right it is now "five walls thick". Even though the wall is just one tile thick...

Or when I build a line of wall tiles, the direction im building from will always have lots of wall tiles in the row:
Building from left to right: wall wall wall (try to build another wall but already 3 wall tiles to the left).

Edited by suliman

Share this post


Link to post
Share on other sites

It's Python indeed, so much nicer for explaining ideas and for experimenting implementations.

 

6 hours ago, suliman said:

But if I have a gap in the wall (five walls, one tile with no wall, five walls) that will prevent the player from refilling that gap in the wall since to the left and right it is now "five walls thick". Even though the wall is just one tile thick...

Apparently I don't understand what you see as "thickness of wall" then, could you state a precise definition of thickness please?

I don't see how you want to allow to fill in holes, and also have your requirement "I DON'T want the player to be able to just fill in any amount of tiles to make a super thick wall.".  If you allow filling gaps, how would I not be allowed to make a big area of walls with gaps between them (thus avoiding the thickness restriction), and then as a second step, fill all gaps to get a massive wall? (Since above you say I should be allowed to do that, it seems.)

 

6 hours ago, suliman said:

Or when I build a line of wall tiles, the direction im building from will always have lots of wall tiles in the row:
Building from left to right: wall wall wall (try to build another wall but already 3 wall tiles to the left).

Good point, but afaik Dune2 walls have no direction, they just attach to any wall nearby (in all directions).

 

As another point of discussion, what is the problem with building a fat wall exactly? You can just go around it, right? Just make sure a path exists to whatever the player is protecting?

 

Share this post


Link to post
Share on other sites

Dune2 had no restrictions. You could build a 10x10 wall.

It looks ugly with too thich walls and destroys some of the balance for defences that I have planned. They have a system for this in the game "they are billions" but i dont know how they implemented it.

Double-walls would be like (This is thickness 2, each X is a tile of walls):

XXXXXXX
XXXXXXX

So you should be allowed to fill gaps if they looked like this:
XXXOXXX
XXXXXXX

or:
XXXOXXX

But not build like this (which would be triple-thickness). The bold X:s are examples of gaps (if they were gaps) were walls would be disallowed to place (and the others would not be allowed to be placed like this either)
XXXXXXX
XXXXXXX
XXXXXXX

Edited by suliman

Share this post


Link to post
Share on other sites

I'd see your first wall as 2 tiles high and 7 tiles thick :P

Pointing out good examples and bad examples is quite easy most of the time. The trouble is always finding a rule that allows you to decide "good" vs "bad".

My first attempt failed, how about  "Every wall must have a non-wall neighbour at most thickness/2 tiles away" ?

Share this post


Link to post
Share on other sites

If the thickness limit is 2 tiles, there's a cheap special case approximation: wall tiles must have a non-wall tile among their 8 orthogonal and diagonal immediate neighbours.

Examples of good walls:

355555553
367776553
 66 67
 55 576543
 33 355543


     2321
     5
12224442222221
     6
    333
    2 22

A wall with thickness 3 or more contains a square of 3 by 3 wall tiles, which contains a wall tile with 8 wall neighbours in its center.

Of course it's possible to elude the rule. For example two concentric thickness 2 walls separated by 1 non-wall tile are allowed and probably slightly better and slightly more expensive than a thickness 4 wall. Even worse, arbitrarily thick walls could have holes to make them legal:

..................
...777777777777...
...7x77x77x77x7...
...777777777777...
...777777777777...
...7x77x77x77x7...
...777777777777...
..................

 

Share this post


Link to post
Share on other sites

Instead of allowing the player to build arbitrarily thick walls of any sort, why not give them a different means of increasing the strength of walls?

 

For example, allow each wall tile to connect to at most two other walls. That will allow only ribbons of wall, or air-gapped layered walls. Then, to discourage the player from making successive layers of wall, give them an economic reason to upgrade existing walls instead; let them triple the max HP of a wall by reinforcing it, at a resource cost of only an additional 1x or 1.5x of the base wall cost.

Have the player focus on infrastructure over layers. Give walls an upkeep cost, so that a worker or whatever must come by and repair the wall periodically, even if this is semi-automated, even if the wall is not damaged, to keep it from losing max HP over time. This forces the player to reduce their total amount of walls used, or else pay ever-increasing amounts of workers and wall upkeep costs. Waive this cost if the wall has a manned "tower" or "parapet" attached within 3-5 wall sections in either direction, to give them a reason to build real defensive structures on the wall, and not just use it to dam up areas.

Finally, give the player a reason to protect their walls. Have each 1x1 wall section, when destroyed, collapse into "ruined walls", which take up a 5x5 area and cannot be built on nor can other walls in that area be repaired until the "ruin" is cleaned up. To prevent the player using this defensively or as griefing, have it happen only if the wall is a member of a ribbon at least 5 walls sections long (two additional walls in each of two connected directions).

Edited by Wyrframe
minor tweaks

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


  • Advertisement