Quote:
Originally Posted by koonda
Hi Jos,
I think I did not understand your way of implementing it. If possible could you please send me some code examples to implement that.
Looking forward to your reply.
Thanks a lot
Best regards,
Koonda
Nope, no code; code is for computers and similar silly machines. What I was
saying is that if your 'logical' board measures 7x6 you should use a 'physical'
board of 9x8:
-
+---+---+---+---+---+---+---+---+---+
-
| X | X | X | X | X | X | X | X | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | | | | | | | | X |
-
+---+---+---+---+---+---+---+---+---+
-
| X | X | X | X | X | X | X | X | X |
-
+---+---+---+---+---+---+---+---+---+
the 'X' values represent a non-empty square not taken by any of the two players.
That way you don't need to do any explicit boundary checks in any of your
methods. The logical playing board ranges from [1 ... 7] and [1 ... 6] and any
cell outside that range is invalid (although it physically exists).
w.r.t. my second remark: if none of the players has won and a current move
causes one of the players to win then the position of that last current move
is part of the winning configuration. If it weren't, a previous configuration would
have been a winning situation for one of the players therefore contradicting the
previous assumption that none of the players did win already.
So checking in any possible directions starting from that last move is sufficient
to find a possible winning configuration.
kind regards,
Jos