1. 25 Dec, 2016 5 commits
    • Terence Martin's avatar
      Hide players before final ball drop · cd982101
      Terence Martin authored
      Now when we enter the phase for the final ball drop, we make sure that
      the human and computer Player entities are hidden.
      cd982101
    • 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
      Clean up pushed ball marking · 366ba91e
      Terence Martin authored
      Now that we know the dropping of balls works for removing balls from
      the two player arrays, remove the debug logging.
      
      This was particulary annoying in that it would warn about pushing a
      ball not in one of those arrays when the final ball drops were going
      on.
      366ba91e
    • 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
  2. 24 Dec, 2016 5 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
      Clarify the usage of currently defined states · c0cd298d
      Terence Martin authored
      Now that we have a better idea of the exact flow that we're going for,
      update the documentation comments for how all the states are used.
      c0cd298d
    • 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
  3. 23 Dec, 2016 3 commits
    • Terence Martin's avatar
      Check that a play is possible before switching · 41bc2c35
      Terence Martin authored
      We can now check to ensure that if it is to be a player's turn, that
      there is a valid move for that player first. If not, we instead skip
      to the next player's turn.
      
      In the case that neither player has a valid move, we transition to the
      state that handles the final ball drop, although currently that's not
      how this state is handled.
      41bc2c35
    • Terence Martin's avatar
      Enhance state machine · 86cba188
      Terence Martin authored
      In order to handle some upcoming timing changes, make the state
      machine aware of how long it has been in the current state so that we
      can check it, knowing when to transition to another state or perform
      an event at a set interval.
      86cba188
    • 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
  4. 22 Dec, 2016 8 commits
    • Terence Martin's avatar
      Update game thumbnail · bdde1e10
      Terence Martin authored
      bdde1e10
    • Terence Martin's avatar
      Remove some old debug logs · a2de46c6
      Terence Martin authored
      This cleans up the console now that we know that everything works the
      way we want it to.
      a2de46c6
    • Terence Martin's avatar
      Add a "Just in case" check · 22e0f85d
      Terence Martin authored
      Just to ensure that nothing goes away, before we hide a ball while
      swapping we first remove it from the maze. This makes sure that the
      update loop can't hose it out from under us.
      
      I'm pretty sure this can't actually happen but I'm not 100% sure in
      what sequence the code runs if it is responding to input, so bette
      safe than sorry.
      22e0f85d
    • Terence Martin's avatar
      Re-enable the ability of the computer to take turn · 07e0ff3f
      Terence Martin authored
      Now that we have fixed the underlying issue, we can proceed with
      allowing the computer to take a turn again when it becomes its turn,
      since the balls are actually there now.
      
      The rest of the code should work as we want it to from this point, but
      I'll check anyway.
      07e0ff3f
    • 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 Question mark debugging key · 249f7e6e
      Terence Martin authored
      This adds in the question mark key during debugging mode to dump some
      information to the console of the maze entity currently at this maze
      position.
      249f7e6e
    • Terence Martin's avatar
      Turn off AI pushing of suggested ball · 05ae4a83
      Terence Martin authored
      The question mark key is now a player key, so it only works while it
      is the player's turn. Instead of playing the ball for the human
      player, it merely jumps the player to the suggested ball and turns to
      face the ball in order to set up playing.
      05ae4a83
    • 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
  5. 21 Dec, 2016 6 commits
    • Terence Martin's avatar
      Include ball swapping at player switch time · d65471c1
      Terence Martin authored
      Now when the game state switches from one player to the other, the
      appropriate ball swap happens.
      
      This is curruently buggy for some reason; although the code is
      extremely straight forward, it somehow fails after the first time,
      which breaks everything and I can't figure out why just yet.
      
      This task will have to carry over into tomorrow.
      d65471c1
    • 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
    • Terence Martin's avatar
      Fix bug in MazeContents · f37c720c
      Terence Martin authored
      In favor of pasing a parameter to the swap function that swaps balls
      between the computer and the player that says if it should save the
      ball state or not, instead allow setting the visible ball state to
      clobber the existing ball row.
      
      This will be futher enhanced in the immediate future, but this causes
      a problem in that we want the player balls to be visible first, but
      because that is the default, the swap function swaps them and displays
      the wrong one.
      f37c720c
    • Terence Martin's avatar
      Fix ball visiblity during generation and swaps · 59c03a4a
      Terence Martin authored
      Now when balls are generated, they are generated hidden. Saving the
      balls to the appropriate array in the MazeContent class hides them and
      restoring them shows them again.
      
      This means that when we swap balls, we automatically hide and show
      everything as needed.
      59c03a4a
    • Terence Martin's avatar
      MazeGenerator now generates dual sets of balls · 05ae7e09
      Terence Martin authored
      When the maze is generated, we now fill out the generated balls into the
      appropriate arrays and then restore the default ones to the top row,
      which gets everything ready to go.
      05ae7e09
    • Terence Martin's avatar
      Enhance MazeContent class · c4a86a1a
      Terence Martin authored
      We now have two separate arrays that store the playable balls for each
      player, and have the ability to swap what set is currently visible in
      the top row of the maze.
      
      We can also query to see if a given player has a move or not, allowing
      us to skip the turn of a player if needed.
      c4a86a1a
  6. 20 Dec, 2016 6 commits
    • Terence Martin's avatar
      Remove superflous state · 983a442f
      Terence Martin authored
      As implemented we don't need a state for the AI to select its move;
      this happens as a part of the state in which it is taking its turn.
      983a442f
    • Terence Martin's avatar
      Use state logic to make a computer take a turn · c5d0a5ad
      Terence Martin authored
      This introduces the logic required to have the computer player take a
      turn. When this happens it will select a move, then walk to that
      location and push the appropriate ball.
      
      This lacks the change to the state where we know that the end of the
      round is at hand, so when this happens the two players just keep
      swapping back and forth doing nothing.
      c5d0a5ad
    • Terence Martin's avatar
      Proper visibility for Player entities · 2f3b5ae5
      Terence Martin authored
      We now track the switching of states so that when it is the player
      turn they are visible and when it is the computer turn they are
      visble, and the alternate entity visiblity is swapped when this
      happens.
      2f3b5ae5
    • Terence Martin's avatar
      Player entity can be visually turned off · 42e3654b
      Terence Martin authored
      This adds to the Player entity a visible property that allows us to
      turn off it's rendering. This will be used by the game scene to only
      display the human or computer player, but not both.
      42e3654b
    • Terence Martin's avatar
      Game scene makes a computer player object too · 50f47de4
      Terence Martin authored
      In order to prepare for the computer to take a turn, we need a Player
      entity that represents it as well.
      
      The Game scene now creates the entity and sets it up; it is currently
      visible at the same time as the player entity. This will be addressed
      shortly.
      50f47de4
    • Terence Martin's avatar
      Respond to ball drop finishing properly (moreso) · 09d29e3e
      Terence Martin authored
      Instead of just always being the turn of the player, we now take turns
      by swapping to an appropriate state depending on what the prior state
      was.
      
      This is only a base implementation; it doesn't know where to go after
      the final ball drop, it doesn't swap balls for the computer or player,
      and so on.
      09d29e3e
  7. 19 Dec, 2016 7 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
      Handle maze events in Game scene · a9a1a745
      Terence Martin authored
      This hooks up the Game scene to the events that the Maze object can
      trigger, so that we can react to the maze generation complete by
      making it the players turn, which adds controls back and once again
      puts us back to where we were before.
      a9a1a745
    • Terence Martin's avatar
      Constrain player input to provided state · 9f98a325
      Terence Martin authored
      This shifts the code responsible for allowing the player to take a
      turn (or do something that can happen only on their turn) into its own
      method, which will handle it as before but do nothing if the state
      does not indicate that this is the player's turn.
      
      This proves that the player will not be able to interact with anything
      when it is not their turn.
      9f98a325
    • 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
      Add state machine to Game scene · f9f42d11
      Terence Martin authored
      This adds in the actual property that includes the state machine in
      the game state. We set up a state and priorState property right on the
      Scene class instance itself so that we can get at the value easier.
      
      This checks at the time that the scene is activated to see if it is
      currently no state (startup) and if so, changes the state to the level
      generation state, which will then kick off the level generation.
      
      This is basically a roundabout way to do what we were already doing.
      f9f42d11
    • 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
    • Terence Martin's avatar
      Include new StateMachine class · 9d91e183
      Terence Martin authored
      This is a first pass and is subject to changes, so we'll see what
      happens.
      
      This is set up so that the machine maintains both a current and a
      previous state (i.e. it has a state stack size of 1), allowing us to
      not only track our current state but also make rudimentary decisions
      about where to go next.
      
      There is a change listener interface that allows the machine to
      directly notify interested parties when the state changes so that they
      can take the appropriate action.
      
      This code currently has a proviso (in comments only) that warns again
      changing the state of the machine while inside the change handler, but
      I think as long as there is only ever a single listener this is safe.
      In the case of a multiple listener, notifications to objects that get
      notifed after the current cycle might be undefined.
      9d91e183