Twixt
A game published in the 1960s by the 3M corporation in their "bookshelf" line. The board consists of a 24x24 array of holes arranged in a square grid. The outermost line of holes surrounding the board is partitioned off, and opposite sides are assigned to opposing players by colors red and black (similarly to Hex).
Players take turns placing colored pegs into the holes, and when two pegs of the same color share a "Knight's Move" relationship to each other, they place a small plastic bar across the tops of the pegs. As in Hex, the goal is to complete a bridge from one side of the board to the opposite side using these bars. Since bars are not allowed to cross each other, they can be used defensively (block the way of the opponent) as well.
-
http://www.k2z.org play Twixt online (Client necessary)
-
http://www.littlegolem.net play Twixt, as well as Dots and Boxes and Go on this turn-based server
-
http://sourceforge.net/projects/twixt/ 2 players, play over network (linux (with SDL))
Speculations about a Computer Opponent for Twixt
- about 24x22=528 legal moves (on 24x24 board) in the beginning for each player
- there seems to be a special kind of search necessary:
- sometimes (especially towards the end of the game) there might be a winning move a for Player A (or a move that gives a big advantage) but it's Player B's turn: so it's clear that B must block A's way "somehow" (play in same area); especially all the about 400-500 other legal moves would lose immediately, so they need not be generated if you can prove that they make no difference!
- replace "a winning move a for Player A" by "an area (or a set of points), where at least some moves in the area would win (but definitly none out of this area)"
-
http://www.johannes-schwagereit.de/T1.html the program Twixt T1, with source
-
http://www.k2z.org/k2zAI.html haven't tried this one
Choosing the rules
- TwixtPP (=link removal not allowed) is _almost_ the same as Twixt with removing links for most of the game, except for some (endgame-)"fights" where the player is blocking his own way, removing links would help him then.
- I recommend TwixtPP (=no link removal) for computer-experiments for the beginning.
- a further simplification (starting from Twixt PP) would be to disallow (the computer) to place a peg and not simultaneously add all possible links (note that this is not really a big disadvantage). Changing the rules this way means that a move consists just of the xy-coordinates of the peg, and all possible links are added automatically. (=about 528-(num-pegs on the board) legal moves in the beginning)
- another issue to consider is, whether own links are allowed to cross other own links (of course never opponent links). Little Golem (TwixtPP) apparently does allow this, while in "normal" Twixt it is not allowed.
- additional remark: a tie (no player able to complete a connection) is possible with both rules (TwixtPP and "normal" Twixt; see discussion-section)
Representing a board situation
- simple: keep a List of Pegs and Links for each Player (k2z uses this)
- represent the board as a 24x24 array for the pegs and have another (about 24x24) array for the links (8 directions=8bit-bitfield); 2 possibilities:
- store each link "twice" in the array (once for the point where the link begins and once for the point where it ends)
- store each link only once in the array, but use the convention, that links have to go to the right (for example) =only 4 directions left (T1 uses this)
- what next? Already "connected" pegs, together with the links that connect them, form a group, which the opponent can't break and which will stay on the board like it is till the end of the game in almost all cases (the only exception: link removal in the "endgame"). So the program can recognize and represent such groups in some datastructure. (incrementally perhaps, if undoing moves during search is necessary -- I implemented this already based on the source of "T1", but didn't use it for anything).
- another useful idea might be - especially when representing the board as a 2d-array (but not only then) -, to normalize the board so that the player-to-move always plays horizontally. This is imho very useful for all kind of algorithms ("pattern searching", just generating moves, etc), and eliminates a lot of special cases in the code.
- instead of "normalizing" the board and rotating it after every move, two board-objects (c++) should be kept, one where the player-to-move has to play horizontally (this is used for the actual algorithms/calculations) and one where the player-to-move would have to play in vertical direction (this is kept in the background). After the player has made the same move in both boards, the pointers to the board-objects are just swapped. (i implemented it to this point)
- the next level would be to have also 2 boards mirrored along the vertical axis, for searching for connections to the left OR right border of the board, depending on which subgame you are considering (an example for subgames: moves at the left side of the board might be completely independent of moves at the right side of the board, although both areas might not yet be completley connected, but both sides have to get connected, finally (AND-situation)) (in the opening there are no subgames, so it doesn't matter which of the 2 (mirrored) boards you look at for choosing the move).
- (So this gives a sum of 4 boards to update (or recalculate) for every move or undone move)
- to mirror the board also along the horizontal axis (player-to-move still plays horizontally) might make sense for very few algorithms (opening database is an example, this is normalized for first peg in upper left corner). However the above 2 normalizations are more useful/important.
- UPDATE (last 2 points): my opinion is now to use only the 2 mirrored boards that are updated for every move (during search etc). 4 or 8 boards is too complicated and not really useful (lots of coordinate-transformations to find the same point in another board). For 2 boards you just have to swap x and y coordinates, so not a too big problem.
Possible Strategies
- opening book for the first moves
Rules/Patterns
- rules/patterns: there are a few moves, which are often good, so the computer can try these moves first (then some other moves in the same area):
- extensions/jumps: 2-1,1-2;3-3,4-0, etc
- blocks: 2-0,4-0, etc
Subgames (simple situations)
- another observation is, that independent subgames often emerge quite early in the game; sometimes as soon as a (longer) string in the middle of the board exists, and "only" the 2 ends have to be connected to the sides (AND-Situation).
- to consider 2 situations (at the 2 ends of the large group/string, for example) as subgames might make sense, in a given situation, only, if the player-to-move is able to win both subgames provably (or at least very likely, according to heuristics). Being not able to win one of the 2 subgames directly means a different strategy has to be chosen, which possibly only uses the large group (at which's 2 ends the 2 subgames exist) as an indirect threat.
- when analyzing subgames it is not only interesting whether the player-to-move can win the subgame, but also whether he can win it, even if he moves second in the subgame.
Twixt on small boards (no swap allowed)
- 8 legal moves as Move1 for Player1
- all moves result in a tie, because no complete connection is possible on this small board
4x4
5x5
- 6 possible moves (with considering symmetries) for Move1
- move in the middle wins for Player 1?? / 2?? / Tie?? ???
- ...todo
If "Vertical" plays 1, H plays 2 (for example), etc...
6x6
Twixt Puzzles
-
http://www.gamerz.net/pbmserv/Twixt/puzzles.html 40 puzzles
- I have entered these as 24x24 full board problems, so they can be used as testcases for a program, to test whether it is able to solve these problems (currently no program exists however). (--> there is no download address for this, but ask here if you need it)
List of known Programs (the first two mentioned above)
-
http://www.k2z.org/ k2z-bot (no source available?, playing online)
-
http://www.johannes-schwagereit.de/T1.html T1
-
http://www.8ung.at/hgui/T2_RELEASE3.zip T2 (based on T1, developed indepentently for some time; T1 plays better (was even improved since the branch); in fact T2 (almost) doesn't play, but has some other changes) (includes the cpp-Source for Windows, Linux, cygwin; includes EXE compiled with cygwin)
-
http://www.twixt.de/ very weak, in java
-
http://zapletal.objectis.net/homepage/projects/twixt didn't check this, written in XBasic