Click here to Skip to main content
Click here to Skip to main content

The boardgame Twix with a twist

, 19 Oct 2004
Rate this:
Please Sign up or sign in to vote.
This is a strategy board game that I used to enjoy playing with my neighbour when I was a teen in the 80's that I developed in Java, then ported to C#.

Introduction

This is my first contribution to CodeProject! Twix is a strategy board game that was played on a square plastic board containing a grid of holes for pegs with which you connect bridges.

There are two players in this game who would try to connect an uninterrupted bridge from one edge of the board to the opposite edge of the board. One of the players attempts to connect the left and right edges, while the other tries to do the same with the top and bottom edges. Inevitably there is conflict and therein lies the strategy of the game.

Players take turns placing pegs onto the grid. When two pegs are in a grid position of one-over and two-away (like a knight in chess moves) a bridge may be placed atop the pegs. Bridges may not cross other bridges! Each peg may have up to eight bridges connected with pegs surrounding it that are placed in the 'valid' grid holes.

Every time a player places a peg, the peg is analyzed to determine if any bridges should be placed (up to eight). It is not necessary to place a peg in any potential bridge location i.e.. it is not necessary to place bridges and connect pegs in every turn.

Bridges are placed on like-colored pegs. Bridges may not cross other bridges and will not be allowed.

Some enhancements I have made:

  • Timer to enforce that player must make a move or forfeit their turn.
  • A credit system based on time and new bridges that reward a quick player move.
  • A creature is awarded to a player who has accumulated enough points (The cursor will change to indicate that a creature may be launched). This creature is assigned a location on the board (an opponent's peg in a strategic location is a good one). The creature will work its way over to that location, and if a peg is there, will grab it and relocate it to an empty grid position.

Code discussion

The reasons I undertook this project:

  • It was a cool game that I can't find anymore.
  • It was an interesting problem to solve.
  • It was a good starting platform to introduce a useful playing field for my creature object.

The trickiest part of developing this game was the bridge connection/blockage detection. The next difficult problem was the win condition detection. The latter required recursion, the former required a lot of boundary checking and thoughtful looping.

The creature is a specialty of mine that I came up with almost ten years ago. It learns how to migrate towards a coordinate by randomly flailing its appendages until a 'good' move is determined. A good move is one where its elbow and its feet are closer to the destination than its current elbow and feet configuration. Then the creature iterates through the two configurations repeatedly (extending its arms, grabbing with its feet, and extending and contracting its elbow) until its destination is reached, or its distance from the destination increases. I'm very proud of this little guy and finally found an interesting use for it in a game.

The game is run by a timer in the main windows form. Every time the timer event occurs, a set of list objects is called upon to do work. There is an explosion list, an arm list, a peg list (which contain bridge lists) and the board object. The graphics is page flipped to provide a smooth look.

Crack open Globals.cs to change the board size, the speed of the creatures, their spawn rate in demo mode, etc..

Desired future enhancements

  • Sound!! Nice ambient background and a heartbeat that increases as the players get closer to winning would be cool. Explosion sounds, creature walking sounds, grabbing sounds, etc..
  • Computer AI for one player mode.
  • Two players over the network would be awesome, but a significant and possibly difficult restructuring of the code is required.
  • More interesting events and sub-goals for players to strive for (enclosing something causes something to occur, etc.)
  • Port to DirectX, DirectSound, DirectPlay.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Alex A. Miller
Web Developer
United States United States
Masters Computer Science Rochester Institute of Technology
B.S. Computer Science at Oswego State University of New York

Comments and Discussions

 
QuestionThis game is called Twixt not Twix. PinmemberTwixtfanatic26-Oct-14 10:01 
Generaltwix PinsussAnonymous23-Oct-05 11:17 
GeneralRe: twix PinmemberAlex A. Miller24-Oct-05 4:17 
GeneralRe: twix Pinmemberdiana8192-Oct-12 8:30 
GeneralRe: twix PinmemberTwixtfanatic26-Oct-14 9:36 
General[Message Deleted] Pinmembernfwu25-May-05 2:36 
GeneralRe: Code In Java PinmemberAlex A. Miller25-May-05 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411028.1 | Last Updated 19 Oct 2004
Article Copyright 2004 by Alex A. Miller
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid