Star Trek 3D Chess   0


Row Col Layer

Canvas will appear here when you the game, but I'd recommend you read the Rules and Options before playing.

Spock Thinking
# W/B Type From To Capture


Row Col Layer


Row Col Layer


Row Col Layer

The UI isn't exactly stable, and sometimes it's necessary to change the viewing position to have it redraw the pieces. Not entirely certain why this is, but if you know, please tell me. The questionable code will probably be in Chess3dView.js Also, this seems to work relatively well on Firefox (and perhaps on Chrome), but not using some other user-agents. Again, if you know why, please advise.

Rules and Options

Computer will play this side.
This selection determines the relative complexity of the computer play (the algorithm).
This number controls the recursion level for the selected computer algorithm.

Computer Configuration

The computer can play either side. This is useful if you want to see the computer play against itself using different algorithms or different levels of algorithm recursion. None of these are very good, but it's a start - I'm trying to come up with a better one.

The computer will randomly select a legal move. The recursion level doesn't make any difference for random moves.
The computer will examine all possible moves and examine all possible response moves to determine which move is best. Recursion will cause the script to examine all possible response moves to all possible moves for all possible responses for all possible moves... and will use all available CPU. Best to keep the recursion level near 1 unless you've got a very powerful machine.
The computer will first determine the best moves based on the Value algorithm, and then will refine it to favor moves that press the attack on the opposing king.
Computer will play this side.
This selection determines the relative complexity of the computer play (the algorithm).
This number controls the recursion level for the selected computer algorithm.

Computer Delay (pause between moves)

The computer can pause between each move to give you time to watch the play. This is only useful when letting the computer play against the computer.

Game Play (starting, pausing, and stopping)

This game starts when you click the button here or at the top of the page. And then you can jump back to the top of the page to play. Changes you make to the configuration items here (above) will affect the play after the current move.

Pressing the pause/play button on the top-right will pause and resume playing the game. To restart the game - reload the page. The game will automatically stop on checkmate or when only the king remains on one side.

Adding an additional dimension to the standard 2D game makes piece movement much more complicated but most of the movements of pieces will seem very familiar. The addition of 'Attack' boards is where the fun comes in.

Pieces on boards must be able to move to other boards, but not indiscriminately (as seemed to be the case in the Star Trek TOS episodes). In one of those episodes, Spock puts Kirk in check, and Kirk responds by moving a piece to put Spock into checkmate. This sort of move does not make much sense, and the closest you'd be able to do here is to move an attack board that was used by your opponent to put your king into check, that may contain enough pieces to checkmate your opponent - removing the threat to your king in the process.

The description of this game at the very end of the Star Trek manual (available in the '70s - and I have a copy) did not give the rules for this game, so I put together what seemed logical. And although the attack boards could move, never in the show was this demonstrated, though they were in different positions in scenes where the game could be seen.

The series showed different numbers of attack boards in different shows (and in different positions), with five being the most ever shown in a game. But since four attack boards and three regular boards makes for 64 squares (the size of the original game), I've chosen to put in six attack boards. The individual pieces have more power than their 2D counterparts, so more real-estate seemed like a necessity. And there's no equitable initial positioning of an odd number of attack boards.

Piece Movement (pieces and boards)

The pieces move like ordinary chessmen, except that in some circumstances they are allowed to move between the different boards. The 3D movement of the pieces is much like their 2D movement, with the exception of the pawns.


The rook moves in a straight line - any number of squares. The straight line may be forward, back, left, right, up, or down, and it can also move in a straight line forward+up, forward+down, left+up, left+down, and so on. The only requirement is that there be no pieces blocking this rook, and that it moves through active squares. It may not jump over any missing squares. There are potentially 14 different directions of movement from its sitting position. And to move between the boards, the rook must make use of the attack boards.


The bishop moves in a diagonal - any number of squares. This line may be a simple diagonal forward+left, forward+right, back+left, back+right, or it may also be diagonally up or down (forward+left+up, forward+left+down, &c.). This makes a total of 12 different directions of movement from its sitting position.


The queen moves like a combination of the bishop and the rook. It may move 26 different directions from its sitting position, but only if there are no blocking pieces and there's a continuous line of active squares. Like the rook and bishop, it may not jump over other pieces.


The king moves like the queen, but only one square at a time. There is no castling implemented, partly because the short-side castle resting position for the king is already a place where it can move directly, and partly because it's an additional complexity that doesn't seem necessary for the game in this form.


The knight may jump over other pieces, and in this implementation it can also jump over missing (inactive) squares. There are 24 different destination positions for the knight from its sitting position, though many of those destinations may not be active.


The pawn must move from its starting position 6 squares ahead to be promoted, and promotion is only to a queen. On its first move, the pawn may move two squares forward. It attacks diagonally to the left or right, but its attack is not restricted to adjacent squares on the same board. The pawn attacks the adjacent columns in the direction it needs to move to be promoted (down for the white, up for the black). This means that if a white pawn is on row 4 and column C of level 4, it is attacking squares on row 5 and columns B and D of all levels from 4 on down, even though it might not normally be able to move there. A white pawn on the fourth row of the top 4x4 level may capture a piece on the bottom 4x4 level, even though it would not be able to move there directly if not capturing.

Pawns at the end of their board (any board) may also move one square to the side. But in order to reach their destination for promotion, they must either move between the levels by capturing a piece on another board or by using the attack (the 2x2) boards to move forward between the levels. Pawns may move onto or off of an attack board by moving forward with a move that gets them closer to their destination.

Attack Board

The attack (2x2) board may be moved to any corner of the larger (4x4) boards, provided certain conditions exist: This move may not be used to advance or retard the row of any pawn, so if a pawn is on the attack board, it may only move up, down, or sideways so that the pawn is not moved from the current row. To be moved, the attack board must currently hold at least one piece, but may not hold a piece of the opponent. The attack board may not move if it holds a king. This is because a player could simply move his king onto an attack board and then perpetually retreat from all attacks.

Cores (controlling how much CPU is used)

This code is written to use all available horsepower you your machine. If your CPU has 8 cores, it will take and use all of them. This is necessary, because the more complicated computer algorithms for game-play require a lot of calculations, and the earlier version of this game was single-threaded. It's not fun clicking on a button or trying to make a move, only to have to wait a minute or two for the UI to become responsive again. Therefore, much of the processing is offloaded onto separate workers on background threads.

It's possible to restrict the number of cores the JavaScript will use here: cores The initial value will be the one less than the number available, but you may set to any number down to one (the structure of the code requires at least one background thread). When a worker thread is finished with a calculation, it will send its results to the main thread, and the main thread may send any additional work to that worker, keeping the cores hard at work.

Movement and Views (preset and adjusting the viewing position)

The arrow keys are used to change the viewing position (up, down, left, right). These will move the observers position by one degree at a time. Holding down the shift key while pressing an arrow key will move the viewing position by 10 degrees. And pressing the "SCRLK", "PAUSE", "INS", "HOME", "PGUP", "DEL", "END", or "PGDN" buttons with and without the shift key will change the view to preset positions.

The mouse may be used to select pieces for movement. The standard left-click will load the Row, Col, Layer into the "From" field, and the right-click will load the Row, Col, Layer into the "To" field. The accuracy is difficult, especially with some viewing positions (changing the viewing position may be necessary). Always check that the correct move was loaded into the form before committing the move - there's no ^Z.

When your move is loaded into the form, press the "Move White" or "Move Black" to finish your turn.