Mega Tic-Tac-Toe

A Java Applet by Paul Nahay

Plays Tic-Tac-Toe, Connect Four, Gomoku,
and over 1000 customizable original variants

You must have Java enabled in your browser to run this applet.

Object of the Game
To create a row of marks orthogonally (horizontally or vertically) or diagonally, before the computer does (as in classic Tic-Tac-Toe, Connect Four, or Gomoku, all of which may be played via this applet).

How to Move
Click on a square to mark it (you are "X", the computer is "O").

If Stack Vertically is selected, you may only mark squares that are either on the bottom row, or that are directly above a square already marked.

If Stack Diagonally is selected, you may only mark squares that are either on the bottom row, or that are immediately diagonally above (to the left or right of) a square already marked.

If "Knightly" Neighbors is selected, the first player may move anywhere, but all subsequent moves must be a chess knight's move away from a marked square.

If Orthogonal Neighbors is selected, the first player may move anywhere, but all subsequent moves must be an orthogonal (left/right, up/down) neighbor of a marked square.

If 4-Way Gravity is selected, imagine that you "drop" your marks from one of the four sides of the board, and that the mark "falls" from that side towards the other side (e.g., if you drop from the top side, your mark "falls" downward towards the bottom; if you drop from the left side, your mark "falls" rightward towards the right; if you drop from the bottom side, your mark "falls" upward towards the top; if you drop from the right side, your mark "falls" leftward towards the left). Your mark comes to rest when it "hits" either the side of the board, or an already-marked square. A legal move is then an empty square that fulfills this requirement of the mark having been "dropped" from one of the four sides of the board in this manner.

Who Moves First
At the start of a game, you have the first move, unless you allow the computer to play first by pressing the Computer Moves First button. (Towards the beginning of a game, you may want to set the Search Depth lower, so that the computer responds more quickly, and then set it higher a bit later in the game.)

Setting the Search Depth
In the Search Depth control, select lower values to make the computer play faster, but less intelligently; select higher values to make the computer play smarter, but slower. You may change this value at any time during the game.

If the computer takes too long to "think", you may press the Force Move button to force the computer to move immediately, although this forced move will probably not be the computer's best move. (If you are impatient, it is better to set a lower search depth and wait for the computer to complete its "thinking", than to set a higher search depth and press Force Move, because in the latter case, the computer will be forced to make foolish moves.)

Computer Moves Randomly will cause the computer to make all its moves without attempting to win or block you (good for encouraging your toddler to play!) Force Computer to Move Randomly On Its First Move will force the computer to play randomly on its first move, after which it will play according to the Search Depth setting. This is simply to encourage more diverse opening games.

Taking Moves Back
During your turn, you can "undo" your moves by pressing the Back button, and "redo" un-done moves by pressing the Forward button. At any point in this process, you can start moving normally again.

Starting a New Game
Start a new game at any time by pressing the New Game button. The new game will use the values set in these other controls:

When you change any of these controls, all their values are used to start a new game. You may also select from among a number of preset games via the Preset Game control.

Comments on the Various Games

Links to This Page

Please let me know if you link to this page, so I can link back to yours. Also, feel free to let me know if you have any suggestions for this applet, or for my other Java puzzle applet, Septangle. If either doesn't work for you, please tell me your operating system, your browser (including browser version), and specifically what doesn't work for you.

This applet is also available as a stand-alone Java application. Download to your hard drive from, then double-click on file MegaTTT.jar. Two possible problems you may have are: 1) If you're using Netscape Navigator, Netscape SmartUpdate may refuse to download the file, claiming it is "corrupt"; 2) It won't work at all unless you have a Java Virtual Machine installed on your computer (downloadable as the JRE/Java Runtime Environment from, and you have the ".jar" file extension registered with your system such that .jar files invoke the Java interpreter (java.exe on Windows).

--Paul Nahay,

MegaTTT Copyright 2002 by Paul Nahay,