[SOLVED] Cubic Minefield help

Please format your code.
Instructions are here: How to Post Your Code With Radiant, Harmonious Formatting.