This file illustrates what checks should take place
when a bomb object is detonated. Please view in a
FIXED-WIDTH FONT. Hopefully it is correct...

Game Logic
----------

The game logic within the original Xor game, which I (hopefully)
correctly implemented in XorCurses, had the following important
rules governing precedence of moving objects:

If player moves right to collect a pickup which has
both a falling object and a left-running object resting
against it (the pickup), then which moves first, depends
on which direction the player moves away to get out of it.

If player moves down, the left-moving object moves before
the falling object. If the player moves left, the falling
object moves before the left-moving object. (And if there
were chains of objects, all of each type move before the
other type).

This logic was also reflected in the detonation of bombs
and the order in which consequences of the detonation
were checked (I believe). The immediate concern here was
the difference between (aside from h-bombs and v-bombs)
detonators that fell, and detonators which ran left - as
to which points around the explosion were checked for
further gravitating objects which were resting before
the bomb went off.

Game Logic II
-------------

XorGramana on the other hand has further behaviour characteristics
to bear in mind: objects can now also travel in opposing directions,
running right or rising upwards.

(My source code uses the term 'gravitate' for these objects which
 move as soon as their path is clear up to the point their path
 is blocked - each type gravitates always in the same direction, and
 can be pushed vertically if they move one of the horizontal
 directions, or pushed horizontally if they move in one of vertical
 directions).

(Gravitating objects exclude the Doll object which only moves
 when the player pushes it - the doll continues moving until it
 is blocked - but it is excluded from the definition and logic
 of gravitational behaviour - the Doll cannot pass through force
 fields, cannot detonate bombs, and cannot harm the player, nor
 can the doll move without being pushed).

Therefor with four different types of gravitating movement:

    down
    left
    up
    right

We have a more complex set of rules to check and a decision to
be made on how the precedence of these rules is to be set.

In XorGramana, it has been decided that the down/left precedences
will remain, and that objects moving down and left will also
preside over objects moving up and right - the down and left therefor
are the 'natural' directions (which does not mean up and right are
'supernatural').

Example: A horizontal force-field has a falling object perched
upon it, and beneath the force field, a rising object rests against
it. When something moves through the force-field then the falling object
will be processed before the rising object (because falling is classed
as a 'natural' direction and rising is not). The falling object will
then fall one block and come to a stop upon the rising object. Then
the rising object then cannot rise because it is blocked by the falling
object.

Bomb Types
----------

1a) h-bomb which falls down
2a) v-bomb which runs left
1b) h-bomb which rises up
2b) v-bomb which runs right.

(note: types 1a and 2a are those from
 orignal Xor game and therefor have
 precedence over the two new types, 1b & 2b,check notes below).

Detonator Types
---------------

1) detonator falls down
2) detonator runs left
3) detonator rises up
4) detonator runs right

(note: types 3 and 4 are new and have lower
 precedence than those from original Xor game,check notes below).

-========================-
 Bomb Detonation Checking
-========================-

#-key-----------------------------
#                                #
# ^    | or <- or ->             #
# | or V = detonator direction   #
#                                #
# X = bomb position              #
#                                #
# x = bomb explosion             #
#                                #
# 0,1,2,3,4,5,6,7,8,9            #
#  = coord to be checked in      #
#    order (lowest first)        #
#                                #
---------------------------------

NOTE: Because of the new gravitation directions, the checks
already in place (those utilized for XorCurses) are no longer
fully satisfactory - they don't check for the new types which
may be lurking beneath or to the left of the explosion.

EXISTING CHECKS (h-bomb,down, detonator down)
   |   
   V   
  2x0  
  xXx1 
   #   

EXISTING CHECKS (h-bomb,down, detonator left)
        
  210   
  xXx<- 
   #    

Note the wall icon (#) is used here. In the original game,
it may not be a wall the bomb is resting on, but that is
irrelevant, because at the time of detonation the bomb is
*always* resting on *something*.

However, it is perfectly clear (as mud) in XorGramana that
the possibility exists to detonate a falling bomb (or a
rising bomb) so therfor, what previously were 3 checks,
have now become 7 or 9, not only because it is uncertain if
the bomb is actually resting on anything, but because there
is almost potentially twice as many different movements to
check for.

ANDSOMETHINGELSE: About the detonator, when the detonator
explodes, we do not check for anything behind it at the time
we check all the other points around the explosion. The handling
of the detonator is taken care of beforehand and is reletively
straightforward.

-----8<-----------------------------------8<-----------
(((((((((((((((((((((((((((((((((((((((((((((((((((((((
EXISTING CHECKS (h-bomb,down, detonator down)
   |    coming back to these checks, notice the order:
   V    down is not completely precedented above left,
  2x0   so try to reflect this in checking order from
  xXx1  now on... From this discovered bug, point 0
   #    requires a check for each direction: down+left
        so infact there are four checks not three.
        (This bug fixed in XorCurses-0.0.7)
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
--8<-----------------------------------8<--------------

1) bomb type: 1a (h-bomb,down)  detonator type: 1 (down)

        0)downward
        1)leftward   (xy@0)
    |   2)upward
    V   3)upward
        4)downward
   4x0  5)rightward  (xy@4)
  8xXx7 6)upward
   632  7)leftward
        8)rightward

2) bomb type: 1a (h-bomb,down)  detonator type: 2 (left)
        0)downward
  420   1)upward
 6xXx<- 2)downward
  531   3)upward
        4)downward
        5)upward
        6)rightward

3) bomb type: 1a (h-bomb,down)  detonator type: 1 (up)
        0)downward
   430  1)upward
  8xXx7 2)leftward  (xy@1)
   5x1  3)downward
    ^   4)downward
    |   5)upward
        6)rightward (xy@5)
        7)leftward
        8)rightward


4) bomb type: 1a (h-bomb,down)  detonator type: 2 (right)
        0)downward
   420  1)upward
 ->xXx6 2)downward
   531  3)upward
        4)downward
        5)upward
        6)leftward


-----8<-----------------------------------8<-----------
bomb type: 1b (h-bomb,up)    detonator type: 1 (down)
          (yes this is possible)
          
    |     
    V     
   2x0    
  5xXx1   
   643    
          
bomb type: 1b (h-bomb,up)    detonator type: 2 (left)
          
          
   210    
  6xXx<-  
   543    
          
--8<-----------------------------------8<--------------

I have now decided - atleast just from looking at how to assess the detonations
of h-bombs - not to treat h-bombs which rise any differently from h-bombs which
fall. That is, not to assess the points around the explosions from these two
bombs any differently - the direction they gravitate makes very little
difference that to not ignore it seems extra finnicky and more work. Hopefully
this will turn out to be the correct assumption.

Now, onto the v-bombs and their detonators:


5) bomb type: 2a (v-bomb,left) detonator 1 (down)
   V    0)leftward
        1)rightward
  1x0   2)leftward
  3X2   3)rightward
  5x4   4)leftward
   6    5)rightward
        6)upward

6) bomb type: 2a (v-bomb,left) detonator 2 (left)
        0)leftward
        1)downward  (xy@0)
   7    2)rightward
  2x0   3)rightward
  3Xx <-4)leftward
  6x4   5)upward    (xy@4)
   8    6)rightward
        7)downward
        8)upward


7) bomb type: 2a (v-bomb,left) detonator 3 (up)
        0)leftward
   6    1)rightward
  1x0   2)leftward 
  3X2   3)rightward 
  5x4   4)leftward
   ^    5)rightward
   |    6)downward

8) bomb type: 2a (v-bomb,left) detonator 4 (right)
        0)leftward
        1)rightward
   7    2)downward  (xy@1)
  1x0   3)leftward
->xX3   4)leftward
  5x4   5)rightward
   8    6)upward    (xy@5)
        7)downward
        8)upward


Ok some resolution. In Xor, when a bomb explodes you might have a situation
where that explosion causes the potential for two objects to move: one will
move down, the other will move left. Both directions take the objects to
the same block. In this case, the down moving object will have precedence
over the left moving object.

Extrapolating this to four directions we could have the following precedence:
(regarding a similar incident)

1) downwards objects
2) leftwards objects
3) rightwards objects
4) upwards objects

going back (again)...^^^^

oh no, back here again. In Xor, with the above mentioned situation, the
precedence again, depends upon the explosion of the bomb? so no... i remember
this game, XorGramana, is NOT Xor! It is loosely based upon Xor, but is
otherwise a lot different. Here we have four directions object can gravitate
in, and not just two. So we can decide upon the precedences these moving
objects have over each other when two object wanting to occupy the same
space (but moving in different directions) will have in order to determine
which of the objects will occupy that space. THIS IS NOT XOR AND IT DOES
NOT HAVE TO WORK EXACTLY LIKE XOR DOES! REVELATION!

wait.wait.wait.wait. i like the fact that some puzzles the precedence changes
depending on either the bomb type, or the direction the player moves. already
in xorgramana, there is this for those puzzles not involving bombs, and it
creates a nice symmetry. do i really want to do away with that by simplifying
the precedence to make my life easier when coding the bomb detonations?

I don't think so. So, no there will not be a strict precedence with downwards
objects at the top of the tree and upwards objects at the bottom with leftwards
and rightwards respectively in the middle. this is not the case in those puzzles
not involving bombs (as stated in previous paragraph) so it should not be the
same for the puzzles involving bombs, the logic has to carry across.

Therefor, that precedence stated above, is the precedence for h-bombs, but not
for v-bombs. We must inspect the precedences in Xor again for v-bombs and
translate that to incorporate the extra two directions of movement.

The difficulty I've had trying to sort the logic of this out, is partly due
to the fact that some situations with bombs are impossible to test in Xor,
an h-bomb with a wall to it's right, and chicken to the right of that and
a fish above the wall - and then testing if a chicken detonating the bomb
is any different to a fish detonating it - for the fish and chicken wanting
to occupy the same block is impossible because the wall that explodes (where
fish and chicken want to then occupy) is in the way of the chicken used to
detonate the bomb!

Lastly then, the above mentioned precedence statement, down on top, up below,
left+right in middle is still wrong. For h-bomb, the vertical movements are
precedented above horizontal with down precedenting up, and left precedenting
right. For the v-bomb, it is the horizontal movements preceding the vertical
movements - but still with up preceding down, and left preceding right.

-================-
 Potential issues
-================-

Going back to the example in the 'Game Logic II' section of a force-field
sandwiched between a falling object above and a rising object below, turn
the falling object into a h-bomb (rising object does not explode). When
the player passes through the force-field, the bomb drops one block and
the rising object *attempts* to rise: this force is enough to explode the
bomb - which is now at the same level as the player. The player is situated
next to the bomb when it explodes and gets killed. This by the logic is
quite sane, but to the player perhaps is "a bit harsh". Yes? No?

