
  Copyright 1994 - 2017  David A. Bagley, bagleyd AT verizon.net

  All Rights Reserved

  Permission to use, copy, modify, and distribute this software and
  its documentation for any purpose and without fee is hereby granted,
  provided that the above copyright notice appear in all copies and
  that both that copyright notice and this permission notice appear in
  supporting documentation, and that the name of the author not be
  used in advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.

  This program is distributed in the hope that it will be "useful",
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#ifndef _version_h
#define _version_h

8.1.8

#endif  /* _version_h */

whexagons
=========

A Hexagons Widget

Web: http://www.sillycycle.com/puzzles.html

Download: Primary site: http://www.sillycycle.com/puzzles
          Secondary site: http://ibiblio.org/pub/Linux/games/strategy

Maintainer: David A. Bagley <bagleyd AT verizon.net>

  To build you need at minimum both of these, X11 and Xt (unless you are
  looking to build win32).
    sudo apt-get install libx11-dev
    sudo apt-get install libxt-dev
  You may need to install one of these to build Motif version:
    sudo apt-get install libmotif-dev (strongly recommended)
    sudo apt-get install lesstif2-dev (defunct)
  You need to install XPM if you want color icons:
    sudo apt-get install libxpm-dev (strongly recommended)
  To install XMU if you want editres:
    sudo apt-get install libxmu-dev (probably not useful)
  To install sound libraries (defunct):
    sudo apt-get install librplay3-dev
    sudo apt-get install libesd0-dev
    sudo apt-get install libaudiofile-dev
    sudo apt-get install nas-dev
    sudo apt-get install pulse-dev
      In place of these it is just configured by default with
      --enable-def-play=play.sh
  Then should be a simple
    configure; make

  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.

other stuff to do
  double buffering.
  auto-solve capability.

  [Jul 21, 2018]  V8.1.8:
    Fixing sound installation.
  [Apr 03, 2018]  V8.1.7:
    Updated to use spinner (using latest Motif  ;) ).
  [Oct 15, 2017]  V8.1.4:
    Removed gcc 7 warnings.
  [Oct 01, 2017]  V8.1.3:
    Updates for 64 bit compilation in Windows.
  [Aug 01, 2017]  V8.1.1:
    Valgrind helped find some definite memory leaks.
  [Jul 17, 2017]  V8.1.0:
    Updated sound configuration for X version.  Uses a simple included
      script play.sh, that is now used by default.
  [Sep 13, 2016]  V8.0.5:
    Old website http://www.tux.org/~bagleyd died, shifted code base to
      new website http://www.sillycycle.com
  [Feb 24, 2015]  V8.0.0:
    Sound and install fixes.
  [May 13, 2014]  V7.7.4: 
    Synchronized save and restore with Java version.
  [Jan 20, 2014]  V7.7.3:
    Reorganized pixmap directory.
  [Jan 10, 2013]  V7.7.1:
    Cleaned up some duplication in Motif menu.
    Added scroll to feature help dialog.
    New bold fontlist in resource file, so things are easier to read.
  [Aug 31, 2012]  V7.7.0:
    Puzzle control up now makes bigger and down makes smaller.
  [Oct 22, 2010]  V7.6.4:
    Changed key mappings g->r for read file, r->e for redo.
  [Jan 21, 2010]  V7.6:
    Version handling changed to a single version.h (and man page).
    Sound fixed for esound.
  [Nov 10, 2009]  V7.5.1:
    Windows version: added accelerator for references.
  [Jun 05, 2009]  V7.5:
    Cleaned up menu look.
    Fixed again for NAS sound.
  [Dec 14, 2008]  V7.4.3:
    Fixed for NAS sound.
  [Jul 21, 2008]  V7.4.1:
    Strange character at end of help title removed.
  [Jul 11, 2008]  V7.4:
    Leading function names in lowercase.
  [Feb 29, 2008]  V7.3.4:
    Changed pointer from crosshair to hand2.
  [Dec 24, 2007]  V7.3.3:
    Constants changed.
    Windows error fix when changing size.
    Added 3D look to frame.
  [Nov 06, 2007]  V7.3.2:
    Updated action codes and synchronized Java and C code.
    Various small changes.
  [Feb 23, 2007]  V7.3:
    Html no longer corrupted.
    reverseVideo update.
  [Jan 08, 2007]  V7.2.7:
    New bump.au sound, db lowered, and bumpdat.au removed, thanks to
      http://audacity.sourceforge.net to help clean the sound up.
  [Dec 12, 2006]  V7.2.6:
    Now use http://netpbm.sourceforge.net to generate images from xpm.
  [Oct 11, 2006]  V7.2.4:
    Fixed menu to assure the ok part of queries is handled correctly.
  [Jul 21, 2006]  V7.2.2:
    Fixed assorted memory leaks and uninitialized memory access reads.
    r is now for redo.  z is now the character for randomize.
    (corners): shifting them down by 2's work.
      x=1 and y=n top and bottom pieces are always trapped.
      There are some positions that are weird...  x=1 y=3 and x=2 y=2 in
      particular and  and these cases have to have special handling.
      x=1 y=3     x=2 y=2   special starting positions
         X          X X
        X 1        4 3 1
       5 4 2        5 2
        6 3
         7
    (no corners): shifted by 1, actually always solvable from
      EVERY position, except x=n y=1 this case is easily handled.
  [Apr 01, 2006]  V7.2:
    Made usage string compatible with versions of Motif and screen.
    More defensive code in case getlogin fails.
  [Oct 05, 2005]  V7.1.5:
    scoreFile and userName fixes
    -version added
    -score added
    Common option help for X and X-Motif
    Made corners key "o" to be consistent with alhextris
  [May 31, 2005]  V7.1.4:
    Separated out compatible components.
  [Feb 8, 2005]  V7.1.3:
    Mouse wheel for Windows now works.
  [Nov 21, 2004]  V7.1.2:
    Small changes synchronizing with Java code.
    Thanks to Debian maintainer Florian Ernst <florian AT uni-hd.de> for
      esound fix.
  [Sep 29, 2004]  V7.1.1:
    Sound, "<" and ">" speed control, and animation.
  [Aug 23, 2004]  V7.1:
    Thanks to Debian maintainer Florian Ernst <florian AT uni-hd.de> for
      fixing a compilation problem with X and without Motif.
    Added font option.
  [Dec 15, 2003]  V7.0.1:
    The Hide functionality of the Escape key now iconifies or drops in
      task bar.
    Added help in Windows.
    Accelerator Keys (F keys and regular keys) in Windows now work.
  [Nov 15, 2003]  V7.0:
    Fixed message initialization, it got truncated due to switch
      initialization.
    Integrated winpuz6.5 (Windows 3.1/95) into X source tree.
  [Oct 26, 2003]  V5.7.4:
    Mouse wheel scrolling added.
  [Aug 28, 2003]  V5.7.2:
    png for Gnome and KDE menus and xpm for CDE menus.
    install-games configure option and added other installation options.
    Added xpm for icon.
    Help kicked over.
  [Jul 07, 2003]  V5.7:
    Thanks to my daughter for banging on the keys:
      Resetting key sliders and toggles should reset display message.
      Fix for select and release done at the same time as
        clear, undo, randomize, or solve.
    Test for cheating from get.
    Popup for auto-solve.
    Clear now checks if you really want to randomize the puzzle using
      left mouse button, 'r' will not query
    'Esc' will hide the puzzle (actually osfCancel did the trick)
    Help & About expanded and pop-ups added
    Took out bitmaps since it takes too much room
  [Mar 21, 2003]  V5.6.2:
    Installation fixes for Motif and X versions.
  [Nov 06, 2002]  V5.6.1:
    VMS Motif fix and minor changes
  [Sep 06, 2002]  V5.6:
    configure if around 2nd AC_CHECK_FUNC
    removed Sun CC (char *) warnings
    removed hard coding of program name
    Cygwin changes ./, -lSM -lICE
    record store fix
    x and xm files combined using HAVE_MOTIF
    port back from Java (on the Java side I got some help from
        Sarat Chandran <saratcmahadevan AT yahoo.com>)
      use -1 for NEVER instead of 32767
      handle nobody = (null)
      .data->.dat for consistency
      frame color change on enter/leave
      background/foreground set by default
      allow more arrow keys (osf)
      menu
      3d tiles
      puzzle border changes
      clear
      PositionToTile update
      sizeX&sizeY
      reset maximum
  [Sep 01, 2001]  V5.5.4: g++ 3.0 warnings removed.
  [Mar 27, 2001]  V5.5.3: Infinite loop fix for ARM thanks to Matej Vela
    <mvela AT public.srce.hr>.
  [Aug 11, 1999]  V5.5.2: Fixed runtime library problems when using configure.
  [Jul 31, 1999]  V5.5.1: Imakefile fix for xhexagons and removed HP usleep
    warning.
  [Jun 20, 1999]  V5.5: Added -rv, -mono, -base
  [Jan 01, 1997]  V5.4: Username, concurrency check, configure, man page
    updates.
  [Apr 08, 1996]  V5.3: Minor changes.
  [Jan 31, 1996]  V5.2: If corners mode, a tile is now moved by a more
    intuitive drag and drop approach.  Tiles will invert,
    when selected.  Now using dynamic allocation, so there
    is no maximum size.
  [Dec 15, 1995]  V5.1: Minor updates, RNG for 32/64 bit, border color
    to make faces look more realistic.
  [Oct 01, 1995]  V5.0: Xt/Motif, your choice.
  [May 16, 1995]  V4.10: Warnings removed from Sun's cc and lint and now
    include a random number generator.
  [Mar 13, 1995]  V4.5: Removed lint warnings and added a VMS make.com .
  [Nov 11, 1994]  V4.4: Conservative guess for random number generator.
  [Nov 02, 1994]  V4.3: Now allows undos, saves, and recalls.
  [Aug 23, 1994]  V4.2: Switched left and middle buttons on the mouse to
    have up and down consistent with vi's "j", "k" keys.
  [Jun 28, 1994]  V4.1: Can accommodate a auto-solver.
  [Jun 07, 1994]  V4.0: Xt version.
    I got some good ideas from oclock.
  [Apr 01, 1993]  V3.0: Motif version.
    I got some good ideas from Douglas A. Young's
    book: "The X Window System Programming and Applications
    with Xt OSF/Motif Edition", particularly his dial widget.
    I got some good ideas on presentation from Q. Zhao's tetris.
  [Jan 07, 1992]  V2.0: XView version.
  [Sep 06, 1991]  V1.0: SunView version.

Version 7: 03/11/15 X/Windows
Version 6: 1996     Windows3.1
Version 4: 94/06/07 Xt
Version 3: 93/04/01 Motif
Version 2: 92/01/07 XView
Version 1: 91/09/05 SunView
