1. 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
  2. 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
  3. 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
  4. 18 Dec, 2016 6 commits
    • Terence Martin's avatar
      Streamline player movement · 9b473e5a
      Terence Martin authored
      In preparation for the future moving of the computer player on the
      maze, make a simple method that will turn and move a player entity in
      an appropriate direction.
      9b473e5a
    • Terence Martin's avatar
      Simplify Ball and Brick · eadf37a0
      Terence Martin authored
      The ball and brick were still using comparisons against the currently
      running animation in order to determine if they were hidden or not,
      when they could much easier just use the flag.
      eadf37a0
    • 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
    • Terence Martin's avatar
      Fix AI bug · 1749dc5a
      Terence Martin authored
      During simulation of a drop, a vanished gray brick would count as a
      bonus brick and add points to the ball, even though in practice this
      is not a situation in which points are scored.
      
      As a result of this the AI would prioritize moves through vanished
      gray bricks over regular drops for no discernible reason.
      1749dc5a
    • Terence Martin's avatar
      Enhance Player entity movement API · 6e654caa
      Terence Martin authored
      This is how this should have been implemented originally, but I just
      threw a quick couple of functions together for expediency to try and
      get the change finished before the end of that devember day.
      
      This merges the methods for moving left and right to simple
      translation and updates the documentation comment on this and the
      jumpTo method to not suck.
      6e654caa
    • Terence Martin's avatar
      Add computer animations to Player entity · 97e5cc01
      Terence Martin authored
      This is a simple operation but allows us to support the computer
      player as well. This adds in the animations that are needed in order
      to display as the computer and a parameter in the contructor to
      specify which type of player to be.
      
      The code to select the appropriate animation was already set up to
      work as desired so no changes were needed.
      97e5cc01
  5. 17 Dec, 2016 10 commits
    • Terence Martin's avatar
      Implement simple AI tests · 29cbb3c8
      Terence Martin authored
      This just has the AI run to select a ball, then jump the player there
      and push it so we can see what happens.
      
      This updates the player to have a new test method for jumping to a
      specific location in the maze instead of just going left and right.
      29cbb3c8
    • Terence Martin's avatar
      Implement simple AI · 769484a9
      Terence Martin authored
      This just finds all pushable balls and then simulates them moving
      through the maze to see which one is best. This uses a simple metric
      of just which ball would score the most points at this exact second.
      769484a9
    • 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 Brick · d398dc3f
      Terence Martin authored
      For a bonus brick, we handle touches different. If we are not
      simulating, we do what we always did (only nicer; forgot to refactor
      some code).
      
      If we ARE simulating, we update the score in the ball that touched us
      to indicate that we actually were collected by this ball and then set
      a flag saying it happened so we won't do it again.
      d398dc3f
    • 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
      Implement simulation save/restore for Ball · 8078c39a
      Terence Martin authored
      For the ball the only state we need to track is the position we were
      at before we were pushed (so we can go back there) and the score that
      is associated with this ball.
      
      Calling code is currently expected not to hide us visually if we're in
      a simulation.
      8078c39a
    • Terence Martin's avatar
      Implement core simulation save/restore · 7d1b3091
      Terence Martin authored
      This includes the new API methods for saving and restoring the state
      of a MazeEntity instance (non-visual only) so that we can perform a
      number of simulations in the AI selector without disturbing the actual
      game state.
      7d1b3091
    • 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
    • Terence Martin's avatar
      Fix incidental typos · a0ca9aab
      Terence Martin authored
      I noticed some rather egregious typos while researching what will be
      done  today, so I fixed them.
      
      Sorry, I just can't *not* fix that when I see it.
      a0ca9aab
    • Terence Martin's avatar
      Block addition of temporary todo lists · 563a8eca
      Terence Martin authored
      563a8eca
  6. 16 Dec, 2016 5 commits
    • Terence Martin's avatar
      Change game thumbnail · 4db6cb11
      Terence Martin authored
      4db6cb11
    • 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
    • Terence Martin's avatar
      Include walking · f274dd58
      Terence Martin authored
      The Scene can now make the player walk left and right in the scene. If
      the player is not facing in the correct direction, it rotates to face
      the given direciton, otherwise it walks in that direction.
      
      The movement is constrained to the limits of the columns of the maze
      grid between the walls.
      f274dd58
    • Terence Martin's avatar
      Position player properly · e4d87f90
      Terence Martin authored
      Using the new API, we position the player above the first column in
      the maze.
      e4d87f90
    • Terence Martin's avatar
      Give Player entity a reference point · 9dddef01
      Terence Martin authored
      This adds a reference point property to the player entity, which it
      will use to update its position on screen.
      
      This is done in combination with its map posiition and this reference
      position so that we can easily shift the player around and still know
      what position it's in.
      9dddef01