Refactor

Refactored a lot of code, and added extra documentation for the sake of clarity. Also prepared for the addition of AI players by introducing:

* Two function types which represent player actions (AI or otherwise)
* Modified player definition
* Misc other code for function correctness