xhexagons
=========

A Hexagons Widget

Web: http://www.tux.org/~bagleyd/puzzles.html

Download: Primary site: ftp://ftp.tux.org/pub/tux/bagleyd/xpuzzles
          Secondary site: ftp://ibiblio.org/pub/Linux/games/strategy

Maintainer: David A. Bagley <bagleyd@tux.org>


  Try resizing the puzzle.  Notice the puzzle resizes to take advantage of
  the "room" available.

  Try editing the file Hexagons.ad to get a certain feature and then copying
  to $(HOME)/Hexagons (where Hexagons is the file name) and running
  xhexagons again.  There is also a Windows port (whexagons).

  If you were looking for a auto-solver, sorry.

  Refer to the man page for detailed command line options and instructions
  on how to operate.

  If you want further information on puzzles, I'll be glad :-) to send
  it to you.

MATHEMATICAL STUFF USED IN CONSTRUCTION

  Lets start out with a triangle of hexagons for simplicity's sake
  and then expand these ideas to a hexagon of hexagons

  Assuming it is a triangle of i hexagons in each row and the
  numbering starts from 1.
    Corner 1-> 1
           2-> i(i+1)/2 - i + 1
           3-> i(i+1)/2

    Center ->i%3 =>
           1: (2i'-1)*(2i')/2-i'+1 where i'= (i+2)/3
           default: None

    Max_Width -> i * 3^(1/2) units
    Max_Height -> (3/2)i+(1/2) units

    Start -> x= i * 3^(1/2)/2 units
             y=0
             fin=i
             step=i
    Next -> (n==fin) =>
             true: x+= -3^(1/2) * (2 * step - 1)/2 units; y+=3/2 units;
                   step++; fin+=step
             default: x+= 3^(1/2) units

    Same row? -> (m'==n') where s'=(1+sqrt_trunc(1+8*(s - 1)))/2 {k}
                              i.e. s = s'(s'-1)/2
    Same trbl? -> (m-1)-m'(m'-1)/2 == (n-1)-n'(n'-1)/2 {i}
    Same tlbr? -> (m'+1)m'/2-m == (n'+1)n'/2-n {j}

    Now assuming it is a hexagon of i hexagons in each row and
    the numbering starts from 1.

    Corner 1-> 1
           2-> i
           3-> Center - i + 1
           4-> Center + i - 1
           5-> 3i(i-1) - i + 2
           6-> 3i(i-1) + 1

    Center -> 3i(i-1)/2 + 1

    Max_Width -> (2i-1) * 3^(1/2) units
    Max_Height -> 3i-1 units

    Start -> x= i * 3^(1/2)/2 units
        y=0
        fin=i
        step=i
    Next -> (n<=center) =>
        true: (n==fin)
            true: x+= -3^(1/2) * (2 * step - 1)/2 units; y+=3/2 units;
                  step++; fin+=step
            default: x+= 3^(1/2) units
        default: (n==fin)
            true: step--; x+= -3^(1/2) * (2 * step - 1)/2 units;
                  y+=3/2 units; fin+=step
            default: x+= 3^(1/2) units

    Same row? -> (m'==n') {k} where (s<=center) =>
        true: s' = (1+sqrt_trunc(1+8*(s+i*(i-1)/2)))/2-i
                       i.e. s = s'*(2s'-1)-(i)(i-1)/2
        default: s' = 3*i-2-(1+sqrt_trunc(1+8*(3i(i-1)+1+i*(i-1)/2-s)))/2)
    Same trbl? -> (m''==n'') {i} where (s<=center) =>
        true: s'' = (s+i*(i-1)/2)-(s'+i)*(s'+i-1)/2
        default: s'' = 2*i-2-(3i(i-1)+i*(i-1)/2-s-(3*i-s'-2)*(3*i-s'-3)/2)
    Same tlbr? -> (m''==n'') {j} where (s<=center) =>
        true: s'' = -1-((s+i*(i-1)/2)-(s'+i+1)*(s'+i)/2)
        default: s'' = 2*i-1+(3i(i-1)+i*(i-1)/2-s-(3*i-s'-1)*(3*i-s'-2)/2)

FOUND A BUG?

  Send bugs reports and fixes to the author. For bugs, please include
  as much information as to their location as possible, since I may not
  be able to duplicate them.
