Mate-in-two

was the very first chess playing program running on a general-purpose computer, developed in 1951 by Dietrich Prinz to solve a restricted set of [|mate-in-two problems]. It ran on a Ferranti Mark 1, the world's first commercially available general-purpose electronic computer, which was based on the [|Manchester Mark 1], developed at University of Manchester. || toc =Description= The program was described by Prinz in 1952. It already introduced a piece-list in conjunction with a embedded mailbox board representation, albeit 10*10, since a knight move was composed of two single step moves. Move generation was done keeping a ply-indexed array of piece-list-index, direction- and step-counter. Legal move detection was implemented somewhat inefficient - the king not to move was treated as a super-piece, and with the same technique as used in move generation, the board was scanned from the king's square looping over all directions and steps, to look whether an appropriate opponent piece to move may capture. The iterative search process took up to four plies 0, 1, 2, 3. A mate in 2 was found, if after a ply-0-move, all ply-1-moves could be replied by at least one mate-in-one move, that is leave no legal moves at ply-3. There was no distinction between checkmake and stalemate, and castling, double pawn push, en passant and promotions were not implemented.
 * Home * Engines * Mate-in-two**
 * [[image:DietrichPrinz.jpg width="337" height="282" link="http://www.computerhistory.org/chess/full_record.php?iid=stl-431e1a07d45c1&mainImage=1"]] ||~  || **Mate-in-two** (Prinz' program, Robot Chess),
 * Dietrich Prinz with Mate-in-two ||~  ||^   || ||~   ||^   ||

Control Flow
This [|control flow diagram] was given by Prinz, to demonstrate the nested iterative algorithm of the mate search. Each of the four blocks represents one ply : code ▼ ┌─────◄───────────┐      1│  │2                │    ┌────────┐              │    │  W  1  │              ▲ └────────┘             │      3│  │4   No solution  │ ▼ └─────►           │       │  ┌─────◄───────────~─────┐      1│  │2                │     │    ┌────────┐              │     │    │  B  1  │              ▲     ▲ └────────┘             │     │      3│  │4   Solution     │     │ ▼ └─────►           │     │       │  ┌─────◄───────────~─────~─────┐      1│  │2                │     │     │    ┌────────┐              │     │     │    │  W  2  │              ▲     ▲     ▲ └────────┘             │     │     │      3│  │4   Avoidable    │     │     │ ▼ └─────►───────────┘     │     │      1│                          │     │         ┌────────┐                    │     │    │  B  2  │                    ▲     ▲ └────────┘                   │     │      3│  │4   Mate               │     │ │ └─────►─────────────────┘     │       └────────►───────────────────────┘ code

Copy-Make
The code of each block is shared, ply-indexing appropriate data structures of the magnetic drum within a copy-make approach. At entry 1 both the piece-list (A-tube) and square-list (B-tube) are copied to the magnetic drum, indexed by ply-index. After initializing piece-list-, direction- and step-counters and generating the first move (if any), those updated counters are saved as state for generating the next move to the drum as well. Then, at entry 2, after determining the current ply index when returning from deeper iterations, the board representation as well the state for generating the next move are restored. Consecutively, after generating the next move, the updated generation state is stored for that level again. Exit 3 increments the ply-index and toggles side to move, and makes the move to update the board accordantly for the next ply level.

=Performance= One memory line of the Mark 1 [|Williams-Kilburn tube] main memory had 20 bits, one tube 64 lines. 20 bit instructions had an address and an operator part, indexing an array of consecutive lines was done by modifying the address part of the instruction. Most Mark 1 instructions with line operand and implicit accumulator, such as 'add', 'sub', 'xor', 'and', 'or', and 'store' took about 1 ms. As reported by Prinz, the following mate-in-two position took about 15 minutes to solve with his program:

>

=See also=
 * El Ajedrecista by Leonardo Torres y Quevedo
 * History of Computer Chess
 * Mater
 * Nemes' Chess Machine by Tihamér Nemes

=Publications=
 * Dietrich Prinz (**1952**). //Robot Chess//. Research, Vol. 6, reprinted 1988 in Computer Chess Compendium
 * Dietrich Prinz (**1953**). //The Use of General Computers for Solving Logical Problems//, in [|Bertram Vivian Bowden] (editor), [|Faster Than Thought], a symposium on digital computing machines
 * Alex Bell (**1972**). //[|Games Playing with Computers]//. [|Allen & Unwin], ISBN-13: 978-0080212227

=External Links=
 * [|First video game - 1947–1958: Chess, from Wikipedia]
 * [|Chess programs: Prinz] from Alex Bell (**1972**). //[|Games Playing with Computers]//. [|Allen & Unwin], ISBN-13: 978-0080212227
 * [|Ferranti Mark 1 Sales Literature] (d) PROBLEMS OF LOGICAL STRUCTURE, August 1952, from [|Computer 50 - The University of Manchester Celebrates the Birth of the Modern Computer]
 * [|The “Modern” History of Artificial Intelligence and Programs] from [|Neuroscience Of Intelligence]
 * [|Mate in Two Problem | Chess Puzzles!]

=References= =What links here?= include page="Mate-in-two" component="backlinks" limit="20"
 * Up one level**