iannsp/phpwar — pull request #9 by jeremygiberson (2014-07-29 12:39:52+00:00)
Title: Refactor of Arena - Decoupling details about the playing field from the rest of the program. 

This is currently a work in progress pull request--it's not quite ready to be merged yet. I'm starting this early pull request to entice feedback from the maintainer since it is elaborate.

Currently, there is a lot of coupling between the arena data structure and other parts of the program. Violating lots of good programming principles.

This refactor maintains traversal details within the scope of the Arena implementation. Any part of the app that is looking for information about the playing field should use the Arena methods to inquire about the field rather than try to examine the field itself.

Additionally, playing field dimensions have been abstracted to an arbitrary array of axis definition. This allows playing fields in 1D, 2D, 3D and ND dimensions. An earlier pull request attempted to lay some groundwork for altering the playing field dimensions but the Geometry implementation doesn't lend itself to actual changes.

Remaining TODO:
* I'm in the process of now replacing references to Cartesian/geometry references with a single Arena parameter. Including updating any affected tests.
* I need to add a renderer that can draw N-dimensional playing fields in a human grokable format. I'm thinking a collection of 2d cross sections of the entire n-dimensions.
* The current data structure for an n-dimensional playing field has been implemented in a rather naive approach. It could probably be optimized by someone with more experience with spacial data structures. (not a necessary todo for the pull request but worth considering)
* Extracting Play, and Stats out of Arena and putting them elsewhere more fitting. Arena should strictly be about the playing field (do one thing well principal).