I'm trying to make a game but it's not really working :confused:
If I have a field in a 2x2 matrix, let's say:
Code:
XXXXXXXXXX
X X
X X
X X
X X
X X
X X
X X
X X
XXXXXXXXXX
I want to randomly add a serie of X-characters (they are walls in the game). So I can create new "maps" at random. SO for instance I could get something like:
Code:
XXXXXXXXXX
X X X
X X X
X X X
X X X X
X X X
X X X
X X X
X X X
XXXXXXXXXX
The difficult part is that there shouldn't be any 'double walls' for instance
Code:
XXX
XXX
XXX
the X in the middle would be doubled (there are other doubled positions too).
I can't seem to figure out an algorythm to check wheter or not a wall is 'doubled'. Any help?
03-28-2006, 02:27 AM
graviton
did i get it right, that a wall is "doubled", when all neighbours are walls too?
if so, then that's your algorithm. before setting a wall, check if all surrounding fields have walls too. if so, you don't need to set a wall.
otherwise show me some more examples of what a doubled wall is.
03-28-2006, 10:46 AM
julie_tatoue
No, there are other possibilities too, for instance:
Code:
1. XXXXXXXXXX
2. X X
3. XX X
4. X XX X
5. X X X
6. XXXXXXXXXX
The last X on line 4 that is part of the wall is a "doubled" one here too...
Let me refine the definition of doubled. A player can only move up/down and left/right in the world (not diagonally), so here that "doubled" wall is just unnessecary ...
03-29-2006, 02:16 AM
graviton
so there are the following possibilities:
XX
X
and
XX
X
and all rotations of that as well as full filled blocks like
XX
XX
it seems to me, that a wall is doubled, if it has a wall at the left/right and a wall at top/bottom.
assuming that you test this on the following block by starting at the field left top, the first wall to be identified as doubled would be 1/1.
1:XX
2:XX
after removing that wall you would have the following block:
1: X
2:XX
the wall at x=2/y=1 has only one neighbour, at bottom, so it's not doubled.
the next wall to be recognized as doubled would be 2/2. then the algorithm would lead to the following block
1: X
2:X
i think that's it. or isn't?