  (piece
    (name Link1)
    (image White "..\..\..\IMAGES\Twixt\med24\link1Gold.BMP" Black "..\..\..\IMAGES\Twixt\med24\link1Black.BMP")
    (help "Click on any link of yours to remove it and enter manual mode.")
    
    (moves
      (move-type RemoveLink)
      (
        (getinfo)
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode true)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode true)      ; clicking on a link enters manual mode.
        )
        back
        (removelinkend Up L1t L13tR L3R L11ff L1b L11fe L11ef)
        (removelinkend Dn L1b L13bL L3L L11ff L1t L11ef L11fe)
        capture
        off-board
        (storeinfo)
        add
        (getinfo)
      )
    )
  )
  
  (piece
    (name Link2)
    (image White "..\..\..\IMAGES\Twixt\med24\link2Gold.BMP" Black "..\..\..\IMAGES\Twixt\med24\link2Black.BMP")
    (help "Click on any link of yours to remove it and enter manual mode.")
      
    (moves
      (move-type RemoveLink)
      (
        (getinfo)
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode true)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode true)      ; clicking on a link enters manual mode.
        )
        back
        (removelinkend Up L2t L24tL L4L L22ff L2b L22fe L22ef)
        (removelinkend Dn L2b L24bR L4R L22ff L2t L22ef L22fe)
        capture
        off-board
        (storeinfo)
        add
        (getinfo)
      )
    )
  )
  
  (piece
    (name Link3)
    (image White "..\..\..\IMAGES\Twixt\med24\link3Gold.BMP" Black "..\..\..\IMAGES\Twixt\med24\link3Black.BMP")
    (help "Click on any link of yours to remove it and enter manual mode.")
      
    (moves
      (move-type RemoveLink)
      (
        (getinfo)
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode true)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode true)      ; clicking on a link enters manual mode.
        )
        back
        (removelinkend Rt L3R L13tR L1t L33ff L3L L33fe L33ef)
        (removelinkend Lf L3L L13bL L1b L33ff L3R L33ef L33fe)
        capture
        off-board
        (storeinfo)
        add
        (getinfo)
      )
    )
  )
  
  (piece
    (name Link4)
    (image White "..\..\..\IMAGES\Twixt\med24\link4Gold.BMP" Black "..\..\..\IMAGES\Twixt\med24\link4Black.BMP")
    (help "Click on any link of yours to remove it and enter manual mode.")
 
         
                
    (moves
      (move-type RemoveLink)
      (
        (getinfo)
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode true)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode true)      ; clicking on a link enters manual mode.
        )
        back
        (removelinkend Lf L4L L24tL L2t L44ff L4R L44ef L44fe)
        (removelinkend Rt L4R L24bR L2b L44ff L4L L44fe L44ef)
        capture
        off-board
        (storeinfo)
        add
        (getinfo)
      )
    )
  )
  

; These pieces display the ends of the game-links, the part that connects to a peg.
; There may be one or two link ends displayed on the same piece.
; The are no moves or drops directly associated with link ends; instead, they are
; added or removed as a side-effect of adding or removing the central part of the game-link.

  (piece
    (name L1t)
    (image White "..\..\..\IMAGES\Twixt\med24\link1Goldt.bmp" Black "..\..\..\IMAGES\Twixt\med24\link1Blackt.bmp")
  )
  
  (piece
    (name L1b)
    (image White "..\..\..\IMAGES\Twixt\med24\link1Goldb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link1Blackb.bmp")
  )
  
  (piece
    (name L2t)
    (image White "..\..\..\IMAGES\Twixt\med24\link2Goldt.bmp" Black "..\..\..\IMAGES\Twixt\med24\link2Blackt.bmp")
  )
  
  (piece
    (name L2b)
    (image White "..\..\..\IMAGES\Twixt\med24\link2Goldb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link2Blackb.bmp")
  )
  
  (piece
    (name L3L)
    (image White "..\..\..\IMAGES\Twixt\med24\link3GoldL.bmp" Black "..\..\..\IMAGES\Twixt\med24\link3BlackL.bmp")
  )
  
  (piece
    (name L3R)
    (image White "..\..\..\IMAGES\Twixt\med24\link3GoldR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link3BlackR.bmp")
  )
  
  (piece
    (name L4L)
    (image White "..\..\..\IMAGES\Twixt\med24\link4GoldL.bmp" Black "..\..\..\IMAGES\Twixt\med24\link4BlackL.bmp")
  )
  
  (piece
    (name L4R)
    (image White "..\..\..\IMAGES\Twixt\med24\link4GoldR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link4BlackR.bmp")
  )
  
  (piece
    (name L13tR)
    (image White "..\..\..\IMAGES\Twixt\med24\link13GoldtR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link13BlacktR.bmp")
  )
  
  (piece
    (name L13bL)
    (image White "..\..\..\IMAGES\Twixt\med24\link13GoldbL.bmp" Black "..\..\..\IMAGES\Twixt\med24\link13BlackbL.bmp")
  )
  
  (piece
    (name L24tL)
    (image White "..\..\..\IMAGES\Twixt\med24\link24GoldtL.bmp" Black "..\..\..\IMAGES\Twixt\med24\link24BlacktL.bmp")
  )
  
  (piece
    (name L24bR)
    (image White "..\..\..\IMAGES\Twixt\med24\link24GoldbR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link24BlackbR.bmp")
  )
  
  (piece          ; f means friend, e means enemy. The first letter refers to the end which
    (name L11ff)  ; is a top end, the 2nd letter refers to the end which is a bottom end.
    (image White "..\..\..\IMAGES\Twixt\med24\link11Goldtb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link11Blacktb.bmp")
  )
  
  (piece
    (name L11fe)
    (image White "..\..\..\IMAGES\Twixt\med24\link11GoldtBlackb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link11BlacktGoldb.bmp")
  )
  
  (piece
    (name L11ef)
    (image White "..\..\..\IMAGES\Twixt\med24\link11BlacktGoldb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link11GoldtBlackb.bmp")
  )
  
  (piece          
    (name L22ff)  
    (image White "..\..\..\IMAGES\Twixt\med24\link22Goldtb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link22Blacktb.bmp")
  )
  
  (piece
    (name L22fe)
    (image White "..\..\..\IMAGES\Twixt\med24\link22GoldtBlackb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link22BlacktGoldb.bmp")
  )
  
  (piece
    (name L22ef)
    (image White "..\..\..\IMAGES\Twixt\med24\link22BlacktGoldb.bmp" Black "..\..\..\IMAGES\Twixt\med24\link22GoldtBlackb.bmp")
  )
  
  (piece          ; f means friend, e means enemy. The first letter refers to the end which
    (name L33ff)  ; is a right end, the 2nd letter refers to the end which is a left end.
    (image White "..\..\..\IMAGES\Twixt\med24\link33GoldLR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link33BlackLR.bmp")
  )
  
  (piece
    (name L33fe)
    (image White "..\..\..\IMAGES\Twixt\med24\link33BlackLGoldR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link33GoldLBlackR.bmp")
  )
  
  (piece
    (name L33ef)
    (image White "..\..\..\IMAGES\Twixt\med24\link33GoldLBlackR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link33BlackLGoldR.bmp")
  )
  
  (piece          
    (name L44ff)  
    (image White "..\..\..\IMAGES\Twixt\med24\link44GoldLR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link44BlackLR.bmp")
  )
  
  (piece
    (name L44fe)
    (image White "..\..\..\IMAGES\Twixt\med24\link44BlackLGoldR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link44GoldLBlackR.bmp")
  )
  
  (piece
    (name L44ef)
    (image White "..\..\..\IMAGES\Twixt\med24\link44GoldLBlackR.bmp" Black "..\..\..\IMAGES\Twixt\med24\link44BlackLGoldR.bmp")
  )

; This piece is used for debugging. It should never appear.

  (piece
    (name ErrorLinkEnd)
    (image White "..\..\..\IMAGES\Twixt\med24\errorlinkend.bmp" Black "..\..\..\IMAGES\Twixt\med24\errorlinkend.bmp")
  )


    
  
  (piece
    (name Peg)
    (image White "..\..\..\IMAGES\Twixt\med24\pegGold.BMP" "..\..\..\IMAGES\Twixt\med24\pegGoldround.BMP"
           Black "..\..\..\IMAGES\Twixt\med24\pegBlack.BMP" "..\..\..\IMAGES\Twixt\med24\pegBlackround.BMP")
    (help "Click on a peg to autolink to it and enter Manual mode.")
    
    (drops
    
      (move-type AutolinkPeg)  ; click on an existing peg to drop another peg of
      (                        ; the same color there, and as a side-effect,
        (getinfo)              ; add all legal links to that peg and enter manual mode.
        (verify friend?)
        (verify (piece? Peg))
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode true)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode true)      ; clicking on a link enters manual mode.
        )
        back
        (tryall) ; keep the peg where it is and perform autolinking to it.
      )
    
      (move-type PlacePeg)
      (
        (getinfo)
        (verify (or (in-zone? holes) (in-zone? borders)))
        (verify empty?)
        mark
        A2                      
        (if (in-zone? borders)                 ; current player = Black
          (verify (not-flag? WhiteManualMode))
          (set-flag BlackManualMode false)
         else                                  ; current player = White
          (verify (not-flag? BlackManualMode))
          (set-flag WhiteManualMode false)     ; placing a peg ends any manual move.
        )
        back
        (if (flag? FirstMove)
          mark
          cascade
          swapspot                    ; When White makes the first move, the swap "piece" is automatically
          flip
          (change-type swappiece)     ; placed to the right of the board. It changes owner so that
          to
          back                        ; Black can move it.
          (set-flag FirstMove false)
          (set-flag SwapMove true)
          (storeinfo)
          add
          (getinfo)
         else
          (if (not-empty? swapspot)
            (capture swapspot)
            (set-flag SwapMove false)
          )
          (tryall) ;  place the peg in this hole and perform autolinking for this peg
        )
      )
    )
    
    
  )
  
  
  
  (piece              ; White automatically puts the swap image to the right of the board on the first move.
    (name swappiece)
    (image White "..\..\..\IMAGES\Twixt\med24\swap.bmp" "..\..\..\IMAGES\Twixt\med24\swapround.bmp"
           Black "..\..\..\IMAGES\Twixt\med24\swap.bmp" "..\..\..\IMAGES\Twixt\med24\swapround.bmp")
    (help "Click here to swap the White peg to Black, reflected on the diagonal.")
    
    
    (moves
      (move-type SwapPeg)
      (
        (getinfo)
        
        (go last-to)
        (if (empty? reflect)
          capture
          reflect
        )
        (change-type Peg)
        (set-flag SwapMove false)
        (set-flag FirstMove false)
        (storeinfo)
        add
        (getinfo)
      )
    )
  )
  
  
  (piece
    (name infopiece)
    (dummy)
    (image White "..\..\..\IMAGES\Twixt\med24\infopiece.bmp")
    (attribute iWhiteManualMode false)
    (attribute iBlackManualMode false)
    (attribute iFirstMove true)
    (attribute iSwapMove false)
  )
