1. 27 Dec, 2016 2 commits
    • Terence Martin's avatar
      Refactor final ball drop flag setting · 0d43c88a
      Terence Martin authored
      Instead of code needing to remeber to set the flag to some value, we
      now just make it a parameter to the drop function.
      0d43c88a
    • Terence Martin's avatar
      Fix drop ball bug introduced yesterday · 5e7cb088
      Terence Martin authored
      Yesterday I introduced some new code where we could detect a vanished
      ball but not trigger the notification that a ball drop was complete if
      the ball was being vanished due to it being a blocked ball.
      
      This was a bit flawed but unfortunatey I didn't notice it until it was
      too late. Basically it would not trigger for a ball that vanished
      because it got to the goal, because I used the wrong variable to track
      if the event should trigger or not (_droppedBall instead of
      _lastDroppedBall) and since _droppedBall gets cleared as soon as the
      vanish is called, such a ball is treated like a blocked ball.
      
      This has been fixed by using the correct variable.
      5e7cb088
  2. 26 Dec, 2016 4 commits
    • Terence Martin's avatar
      Add a new event for removing blocked ball · f3d4974f
      Terence Martin authored
      This adds in a new event that tells us when a blocked ball is being
      removed (happens once when the ball is told to vanish).
      
      This can be used to add blocked balls to the final score when that
      happens.
      f3d4974f
    • Terence Martin's avatar
      Tweak the ball drop event · e71e3ed4
      Terence Martin authored
      It no longer gets the boolean indication; this can be determiend by
      the caller based on the map position of the ball when it stopped.
      e71e3ed4
    • Terence Martin's avatar
      Fix bugs in blocked ball removal · b7594275
      Terence Martin authored
      This code went through several iterations, and so some things were not
      in the correct order (e.g. null test AFTER other tests).
      
      There was also an issue where a vanished ball would trigger the  ball
      drop complete method and then throw an error because there is no
      dropped ball, which I have currently patched away but this needs to be
      handled better.
      b7594275
    • Terence Martin's avatar
      Include method to find and vanish blocked balls. · d9bc2a01
      Terence Martin authored
      This will be used during end game, just prior to vanishing all of the
      gray bricks and dropping the final balls.
      
      We want to be able to find all balls that have no chance of moving
      because they are either stopped on an arrow, or stopped on top of a
      ball waiting on an arrow, and then remove them away like the gray
      bricks do.
      d9bc2a01
  3. 25 Dec, 2016 3 commits
    • Terence Martin's avatar
      Fix possible premature state change · 05a53006
      Terence Martin authored
      The code for starting the next ball dropping in the final ball drop
      was incorrectly only checking to see if a ball is hidden without also
      checking to see if it's still actively hiding; fixed.
      05a53006
    • Terence Martin's avatar
      Fix final ball drop bug · c3da8655
      Terence Martin authored
      It turns out that the reason for this failure was entirely because I
      incorrectly stopped the search for balls to remove for being vanished
      one column short of the edge.
      
      This means that any final ball dropped in the last column of the maze
      will vanish but not be reaped. Thus the flag for the ball being done
      will never get set and everything stalls out.
      
      Whoops.
      c3da8655
    • Terence Martin's avatar
      Allow for the notion of no gray bricks · d4a3f817
      Terence Martin authored
      This is probably only of use when debugging, but as originally written
      the code would get stuck and not be able to enter the final ball drop
      if there are no gray bricks in the level because in that case there
      are none to reap.
      
      This is fixed by having the method that would normally remove such a
      brick return false if there are none left to remove; when this happens
      the code can immediately jump to the next phase.
      d4a3f817
  4. 24 Dec, 2016 4 commits
    • Terence Martin's avatar
      Put final ball drop under the control of states · 4b351244
      Terence Martin authored
      This puts the final ball drop into the control of the state machine;
      when we are in the final ball drop state, we select a ball and drop
      it, and then return to this state once the ball is done.
      
      There is currently a bug in this in which sometimes during the final
      ball drop a ball (that is blocked?) starts dropping, but the flag that
      says that it is done moving is not set.
      4b351244
    • Terence Martin's avatar
      Swap to final ball drop state when bricks gone · 1f9e5ca8
      Terence Martin authored
      Now the maze will invoke a method on the listener to tell it that all
      of the gray bricks have vanished out of the maze and have been reaped.
      
      The Game state uses this to transition into the final ball drop state,
      so that it can start the final ball drop of the round.
      1f9e5ca8
    • Terence Martin's avatar
      Switch to removing gray bricks when no moves left · 364531a8
      Terence Martin authored
      Now instead of swapping to the final ball drop state, we swap to the
      state in which we remove all gray bricks. We handle this state by
      using the state timer to slowly remove all of the gray bricks (telling
      them to vanish).
      
      Currently the code that reaps vanishing bricks is just spewing a
      console log every time it knows all of the gray bricks are gone.
      364531a8
    • Terence Martin's avatar
      Remove Maze handling of removing gray bricks · beb4c0db
      Terence Martin authored
      The code in the Maze entity that tries to determine for itself if it
      should remove all gray bricks has been removed. Now no gray brick
      removal happens at all.
      beb4c0db
  5. 23 Dec, 2016 1 commit
    • Terence Martin's avatar
      Replace ball swapping with direct dropping · 1fffad2a
      Terence Martin authored
      Originally, the MazeContent class would store an array that contained
      the balls left to be played for both the human and computer player
      along with a variable that indicated which of the two were currently
      visible in the maze. We would then save the balls from the maze into
      one array and restore from the other.
      
      This actually causes a problem in that this gets the balls in the
      array out of sync with reality if you don't swap right away.
      
      For example, if the computer pushes a ball, then we check to see if
      the human can play a ball and cannot (all blocked), then we check to
      see if the computer can play to see if they can take another turn,
      since we did not save the ball state and the check happens from the
      array, it thinks it can play the ball it just played.
      
      If that ball is the only ball that can be played, this gets us into
      a situation where there is actually no move to be made.
      
      Now we instead just restore from an array to the maze, and every time
      a ball drops we check to see if it was in one of the arrays and remove
      it from there, thus always keeping everything in sync.
      1fffad2a
  6. 22 Dec, 2016 2 commits
    • Terence Martin's avatar
      Fix a bug; do not reap balls that are hidden · 52d8f9d0
      Terence Martin authored
      Yesterday's woes are caused by the fact that the update loop is
      constantly trying to reap hidden balls by marking them as dead.
      
      This is an issue because a dead ball will not render or update, which
      means that any computer balls that are hidden are almost immediately
      killed, causing them to no longer update even though they're still in
      the maze.
      
      Since we render all balls that are alive, this means that once the
      scene is set up with a set of live balls, it always looks like this
      even when the balls are swapped into the maze, because they won't
      overwrite themselves. Grrr.
      52d8f9d0
    • Terence Martin's avatar
      Include some debug keys · b1a8a977
      Terence Martin authored
      For the purposes of debugging the bug from yesterday, introduce a key
      that allows us to switch directly to a set of balls.
      b1a8a977
  7. 21 Dec, 2016 1 commit
    • Terence Martin's avatar
      Update Maze end of game tracking · ecd041c3
      Terence Martin authored
      Now that we have a separate set of balls for the compute and for the
      player, we need better checking to determine if all balls have been
      played or not (since not all are visible).
      
      There is a method we can use for this, which makes the existing code
      much simpler.
      ecd041c3
  8. 19 Dec, 2016 3 commits
    • Terence Martin's avatar
      Add more state handling · 021c44e1
      Terence Martin authored
      This adds extra events to the Maze entity that tell us if a ball has
      just started being dropped and when it has just finished stopping.
      
      Currently this is handled by disabling player input by switching to an
      appropriate state. Control returns when the ball stops dropping.
      021c44e1
    • Terence Martin's avatar
      Implement MazeEventListener · 0c2b9154
      Terence Martin authored
      This adds to the Maze entity the ability to add a listener object that
      will be told when various events happen. Currently this is just that
      the maze generation is now complete.
      0c2b9154
    • Terence Martin's avatar
      Stop Maze entity from generating a Maze on init · 77d174b3
      Terence Martin authored
      This should actually be done as part of the state machine, since we
      need to do it at controlled times. This also sets up for the idea of
      generating the world in steps instead of all at once, in case we get
      that far along in the development.
      77d174b3
  9. 18 Dec, 2016 1 commit
    • Terence Martin's avatar
      Enhance AI · e57b472b
      Terence Martin authored
      This is a feature of the AI that I wanted to implement originally but
      which I did not get around to in the press for getting the basic
      concept up and running.
      
      Essentially, when the AI is calculating the move that it wants to
      make, it  should pretend that the gray bricks are not actually there
      (even if they are) under the theory that when the round ends, such
      balls will drop  and would theoretically score more.
      
      To this end, the collision API for detecting if an entity blocks a
      ball now gets the isSimulation parameter so that this can happen.
      e57b472b
  10. 17 Dec, 2016 3 commits
    • Terence Martin's avatar
      Get Maze ready for AI · ec9dcc28
      Terence Martin authored
      This creates some accessor methods for entering and exiting the
      simulation for all entities that require it, and exposes the method
      that calculates the next ball position so that outside code can see
      it.
      ec9dcc28
    • Terence Martin's avatar
      Implement simulation save/restore for Arrow · 06e11cbe
      Terence Martin authored
      For the arrow the only state we save is the direction we're pointing.
      This also updates the flip method to take a boolean that indicates if
      this flip is part of a simulation, so that it knows if it should
      change the visual orientation to match or not.
      
      Currently the simulation code does not invoke the update() method, so
      it is basically operating under the hope that an automatic arrow will
      be pointing the right direction when the ball gets there (same as a
      human).
      06e11cbe
    • Terence Martin's avatar
      Set up for AI; include simulation flag · 20c051e8
      Terence Martin authored
      In order to use our existing code for regular and AI purposes, we now
      are able to pass a parameter to the MazeCell methods that are
      responsible for touching and redirecting the ball, so that the method
      can tell for what purpose this is happening (regular or AI).
      
      The existing code invokes this with a parameter that indicates that
      this operation is a regular one so that everything happens as per
      usual.
      20c051e8
  11. 16 Dec, 2016 1 commit
    • Terence Martin's avatar
      Put in ball pushing · 3ad57cee
      Terence Martin authored
      This adds a simple API to the Maze entity that allows the player to
      push the ball if it's facing downward, facing a ball, and a ball is
      not already dropping.
      3ad57cee
  12. 15 Dec, 2016 10 commits
    • Terence Martin's avatar
      Shift debug flag to the debugger object · 1bcd5b79
      Terence Martin authored
      This moves the flag that says if the debugger is turned on or not into
      the debug object itself. This lengthens the code a bit but finishes the
      isolation.
      1bcd5b79
    • Terence Martin's avatar
      Refactor most debugging code into a new class · 272b499a
      Terence Martin authored
      This does for debugging what the previous commits did for the
      generation of the maze. This pulls all of the debug options out and
      puts them into their own class.
      
      This still needs a bit of work, si\nce the flag and a couple of other
      things are still held in the Maze.
      272b499a
    • Terence Martin's avatar
      Rearrange debug code a bit · 40494759
      Terence Martin authored
      This cleans up the debug code by moving one last function upwards to
      where it lives.
      40494759
    • Terence Martin's avatar
      Refactor Maze generation · f0224daa
      Terence Martin authored
      This shifts the code that generates the maze into its own class, which
      shortens up and clarifies the Maze code itself and also makes it
      easier to tweak generation in the future, since it will be self
      contained.
      f0224daa
    • Terence Martin's avatar
      Clarify ball dropping · 549186a3
      Terence Martin authored
      There were several places where code was being used to check if a cell
      in the maze was blocked or not. This has been factored out into the
      MazeContent class so that we can easily do it in one step.
      549186a3
    • Terence Martin's avatar
      Implement simple accessors for ActorPool access · 3d835944
      Terence Martin authored
      This simplifies the code marginally for the purposes of pulling an
      entity out of the associated ActorPool instance, but exposes a simple
      method for external code to be able to get at our entities so that the
      debug code can go away.
      3d835944
    • Terence Martin's avatar
      Remove the last of the instanceof uses · 5568b6a9
      Terence Martin authored
      This implements a new helper in the MazeContent entity that allows you
      to fetch the name of the entity at a given location with a built in
      null check.
      5568b6a9
    • Terence Martin's avatar
      Remove almost all of the instanceof uses · 795e459e
      Terence Martin authored
      We now favor using the internal name of the entity, which for our
      purposes here is the name provided to the MazeCell constructor.
      
      ts-game-engine uses this for debugging so it's exposed, but it
      probably should be. This has been added to the new interface to
      remind us that it should be added along with everything else.
      795e459e
    • Terence Martin's avatar
      Add kill() method to MazeCell and new interface · b64b9a85
      Terence Martin authored
      In order to make code even clearer that wants to kill an entity based
      on its pool, add a kill() method directly to MazeCell that invokes the
      killEntity() method for us as a convenience.
      b64b9a85
    • Terence Martin's avatar
      Use new pool tracking for easier disposal · d0d9d641
      Terence Martin authored
      In order to make the code a little clearer in a few places, instead of
      having wordy code to select the appropriate pool for killing an
      entity, we can just use its pool directly.
      d0d9d641
  13. 14 Dec, 2016 4 commits
    • Terence Martin's avatar
      Create new MazeContent class · a277ce17
      Terence Martin authored
      This class wraps the maze contents and the operations for getting and
      setting cells and markers in it, removing that from the Maze itself.
      
      This cleans up the code and also allows us to  do something like pass
      the content easily as a get() property so that e.g. the scene that owns
      us can modify, which means we can also get a bunch of the debug code
      out of there as well.
      a277ce17
    • Terence Martin's avatar
      Alter drop speed for end of game · 28cef7d2
      Terence Martin authored
      The ball speed while dropping should be faster at the end of the game
      than it is while things are being played normally since there are
      conceivably many ball in this situation and we don't want it to take
      forever.
      28cef7d2
    • Terence Martin's avatar
      Refactor ball dropping code · fdc8455c
      Terence Martin authored
      Shift the code that sets up for a ball move to be in its own method so
      that it is not duplicated in multiple places, since we need to be able
      to do it manually and also automatically.
      fdc8455c
    • Terence Martin's avatar
      Drop balls automatically at game end · 6e64eb8c
      Terence Martin authored
      This new logic detects when all of the gray bricks have finished
      vanishing, and then one by one is selects balls from the maze and
      drops them one last time.
      
      The same drop code is used as for the regular drop, except that in
      this phase the ball is always vanished when it stops moving, even if
      it doesn't hit the goal line.
      
      We move balls from the bottom up so that every ball gets a fair chance
      to move through the maze without being blocked.
      6e64eb8c
  14. 13 Dec, 2016 1 commit
    • Terence Martin's avatar
      Clean up debug code a bit · 45e35481
      Terence Martin authored
      This is just some simple cleanup. Since bricks that are vanished out
      of the maze are reaped now, the code for unhiding them is no longer
      needed since it can't do anything anyway.
      
      This also removes the control from the scene and the documentation.
      
      There are a couple of smaller changes as well in a similar vein.
      45e35481