# Variable board size 3D Connect Four [closed]

Write a 3D version (the game logic being 3D, not the visual representation) of the popular Connect Four game ( http://en.wikipedia.org/wiki/Connect_Four ) where the user can play against the computer. The user may freely chose the dimensions of the game board (width, height, depth) up to a limit of 10 x 10 x 10.

The computer must play an intelligent (probably even optimal) game, apart from its first move which should be random. Ideally a solution will be optimal and never lose. Like tic-tac-toe, perfect play should always result in a draw.

The first player to place four pieces in a row (vertically, horizontally, diagonally, .. (23 combinations in 3D)) wins.

Winner is shortest code.

## closed as unclear what you're asking by Martin Ender, ProgramFOX, Optimizer, Level River St, Moris ZuccaFeb 5 '15 at 14:01

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• For what it's worth, 4x4x4 is probably the most interesting variant, and has already been manufactured under the name Score Four. It may also make it easier to develop an optimal AI. – primo Mar 20 '13 at 7:13
• There was already a question about standard connect 4, which deserves more attention and answers: codegolf.stackexchange.com/q/5496/7486 – user7486 Mar 20 '13 at 13:02
• so why would this other question "deserve more attention and answers"? my question has nothing to do with standard plain vanilla 2D Connect Four. – lightxx Mar 20 '13 at 13:04
• There are only on the order of 9! = 362880 possible tic-tac-toe games, which is a trivial number to search for a computer. On the other hand, for an n x n x n board, there are on the order of pow(n, 2 n) possible 3D Connect Four games. Granted, those are loose upper bounds, but it gives one idea of the size of the search space. Is optimally solving a 10 x 10 x 10 3D Connect Four game feasible on today's hardware? – ESultanik Mar 20 '13 at 13:21
• @lightxx, this question has everything to do with standard Connect 4. It is the exact same problem put in a larger, more generalized space. I think the 2D version is a better fit for golfing because it is not quite so complex. – user7486 Mar 20 '13 at 15:19