Progress: Version 1.2 Complete!

Haha! Theoretically (as in the tests all pass), I have V1.2 of SmartAgent complete. Whether it actually works or not, I have yet to find out. A job for Monday. The changes in this version from version 1.1 is that it has semi-guided placement of pieces for exploratory mode.

Today I have completed the code for the functions semiGuidedAction and scanSubStateContours. Doing this also introduced 3 further functions:
randomPosition, which chooses a random position on the field for a given piece (used when scanSubStateContours can’t find a decent position over 3 iterations).
getRelativeCentre under the Tetromino class, which is a hard-coded function that returns the centre of the piece from the bottom left part of it taking into account the rotation. So a vertical I-piece will return 0.5, while a horizontal one returns 2.5.
And getPieceContours under the Tetromino class, which is also a hard-coded (I was getting lazy) function that returns a variable sized array representing the best contour for a piece.

These come together in the following fashion:

  • When the agent explores, semiGuidedAction is called.
  • This, in turn calls scanSubStateContours (with getPieceContours) for every possible rotation of the piece.
  • scanSubStateContours finds the best (read: lowest) position for the piece. If none can be found, it recurses a max of depth 2 while modifying the pieceContour slightly.
  • The position of the goal piece is calculated by getRelativeCentre().
  • The best rotation is chosen and set as the goal position.
  • Finally, the goal is chased using chaseGoal().

All tests are passing, all that needs to be done is run. As for further progress, I’ll need to consult the checklist.