







                            C H E C K E R S   3 D

                              free version 1.0








The developers don`t assume responsability of damages caused by:
use of any line of this source;
aplication of any technical descriptions;
execution of the programs.

I wrote the source and coments in portuguese. To be more easy translations
there is a small dictionary portuguese-enghish, see the end of this file.

Excuse my english.


COPYRIGHT AND ABOUT THE AUTORS
------------------------------

You are free to use, modify, redistribute this sources. It`s nice credit
the developers of the module you are using, but you are not forced to
do this. Send me any thing that you develop using (or not) my sources, if
you want. Send me 100 dolars then I translate the coments of the sources.
Bugs reports and questions are welcome too.

Autors:
Leandro Bernsmuller - programming, modeling, art, this text;
               e-mail: lebe@aton.inf.ufrgs.br
               my page: http://www.geocities.com/SiliconValley/Bay/1704
Sandro Daniel Camillo - static evaluetion function (CControle::mMAvalia()),
                        beta-tester.

Why I develop this program? I have benefited enormously from the free
information on the Internet, and I would like to keep that process going.


WHAT IS CHECKERS 3D?
--------------------

It is a checkers game with a nice 3D board. Result of joing my 3D engine,
rules of checkers game and the minimax algorithm.

Tested under Windows 95 and Windows NT 4.0, work nice.


RULES OF THE GAME
-----------------

 - pieces can capture ONLY forward, never backward;
 - kings move only one position each time;
 - kings can capture moving backward and forward;
 - the pieces MUST be captured.


TECHNICHES: ARTIFICIAL INTELIGENCE AND IMAGE RENDERING
-------------------------------------------------------

The artificial inteligence part of the game are based on the minimax
algorithm. Basicaly it simulate possible combinations of moves creating a
tree of possibilities and then select one move acording a score computed
by a "static evaluetion function" over each possible board in the leafs.

The rendering kernel draw polygons composed by 4 vertices in anticlockwise
order. You can define one between 8 colors to draw the polygons. The shading
is done using the flat model (knows as Lambert model). The basic view
algorithm is deph-sort, is done previouly the remotion of polygons that
observator can`t see.

To do the visualization is necessary 2 copies of the virtual board. One
with vertices decripted in universe reference system (the system
of reference that object is descripted in file). The other has a temporary
copy of this model. This temporary model is obteined by the geometrical
transformation of the original model (file model) to ajust the virtual
board to the observator position. This temporary board are used to compose
each frame: for each frame the original model is read, transformed and is`t
result putted in temporary model. Then deph-sort draw the image acording
this temporary model.

Deph-sort principle: it order each polygon by it`s Z distance then draw back
to front polygon per polygon. See details in books.


COMPILING
---------

I develop with DJGPP 2. The full source is present here and can
be compiled easy, follow the example:

   c:\check3D> make

Before all ambient variables must be right setted as in the example:

   set DJGPP=E:\DES\DJGPP\DJGPP.ENV
   PATH=E:\DES\DJGPP\BIN;%PATH%

Put this ambient variables in your autoexec.bat doing the alteractions
to your system.


VARIABLE AND FUNCTION NOTATION
------------------------------

I use my self variation for the hungarian variable naming to define short,
prefixes onto each variable, function and type name to denote its properties:

  PREFIX     DATA TYPE OR USE CASE
    a        array (compound type: ach aw)
    b        boolean
    ch       character
    d        double
    dw       unsigned long (double word)
    f        floating point
    ll       linked list (compound type: llptw)
    p        pointer (compound type: pf, pu)
    n        integer (32 or 16 bits)
    u        unsigned integer (32 or 16 bits)
    sz       NULL-terminated string
    w        word (16 bits)
    y        byte
    v        void
    C        class
    o        object
    tag      name of a structure
    enum     name of a enumeration
    c        variable used to count: for(int ncNum=0; ncNum < 5; ncNum ++)
    m_       member variable of a class
    m        member function of a class
    Atr      function basicaly set value
    Ret      function basicaly get (return) value


MODULES OVERVIEW
----------------

I write this program using my best object-orientation knowledge with C++.
The result is a very modular and powerfull system that can be used to
develop other aplications.

This program has, in simple approach, 3 big parts:

                               Interaction
       (coordenetion betweed the other 2 parts and user - is the main part)
                   /                               \
                  /                                 \
                 /                                   \
              Control                               View
     (implements a checker game)           (do the visualization)

Each part can be composed by many classes.

Basicaly to do some thing like a chess or checkers game I need
program the rules and actions of the game. This is the Control part and be
implemented by the class CControl. To Control apply its rules and actions
it has a logical board with the pieces. Because this logical board is very
simple - an 8x8 bytes array - it`s in CControl class.

Logical board diagram:
             (0,0)
               + - + - + - + -
               - + - + - + - +
               + - + - + - + -
               - + - + - + - +
               + - + - + - + -    + position where pieces can be placed
               - + - + - + - +    - position where pieces can`t be placed
               + - + - + - + -
                             (7,7)

To view the 3D board I need a 3D model of the board. This model is a
virtual board: big array with the vertices of the board model, an big
array with polygons and other big arrays. The classes that have this data
are CSolido and CUniverso. To view, render, the 3D image I use CRender
class. To load the model I use CArquivo3D.

To do changes in 3D model acording the Control part and the choises the
user do I use CDamas class.

Many functions are in other classes that are used by this 3 parts.
See the list of class hierarchy on next title.


CLASSES STRUCTURE
-----------------

   Class         Declaration          Description
 hierarchy          File
 ________________________________________________________________________
 CArquivo         arquivo.h    basic text file and binary file access functions
   CArq2D         arq2d.h      bitmap file access functions
   CArq3D         arq3d.h      3D file access functions
 CControle        controle.h   logic of the game (IA,...)
 CControleSolido  contrsol.h   CSolido manipulation (polygons ordenation)
   CControleUniverso  contruni.h  CUniverso manipulation: change colors, piece position,...
 CDamas           damas.h      main module: interaction between user and the rest
 CGrVd            grvd.h       low level video graphics functions
   CGr            gr.h         low level virtual screen graphics functions
 CRender          render.h     high level graphics functions (3D kernel)
 CImagem          imagem.h     bitmap and palette data structures
 CSolido          solido.h     3D model description: vertices, polygons, colors
   CUniverso      universo.h   groups vertices to form units (partitions) like objects
 CSr              sr.h         reference system (for geometrical transformations)
 CTransf          transf.h     geometrical transformations: rotation, translaction, escale
 CTeclado         teclado.h    keyboard handler

 Observations:
    CDamas is an aplication dependent class (if you want Quake or a simple virtual
                                               camera start here)
    CControle is a game dependent class (if you want a chess game start here)
    CControleUniverso is a model dependent class (if you want do change the 3D
                           board you must adapt this class to the new model)

See the coments in source (*.cc and *.h files) or ask me for details.


BASIC CLASSES RELATIONS
-----------------------

  This diagram is a very simplificated overview of the classes relations:
  "What classes are member classes? And for what classes?"

  Example: CUniverso has an member object that is from CArquivo3D.

                           ---------------
                          |               |
                          |   CArquivo3D  |
                          | (file access) |
                           ---------------
                             |            |
                             |            |
                             |CUniverso   |
                             |(file model)|
                             |            |
                            -------------- -----------
                           |              | CTransf   |
                           |              |-----------------------
                           |              | CSolido (frame model) |
             --------------|   CDamas     |-----------------------
            |              |              |
            | CControle    | (start here) |-----------
            |   (AI)       |              | CSR       |
             --------------|              |-----------------
                           |              |ControleUniverso |
                           /--------------\-----------------
                          /                \
                          |                 |
                          | CControleSolido |
                          | (model ordering)|
                           -----------------


FILES DESCRIPTION
-----------------

README.TXT       this text
DAMAS.EXE        executable game
CWSDPMI.EXE      DPMI server
MAKEFILE         makefile, make command interpret this file
INIC.PCX         first message (who start)
DEFMET.PCX       second message (difficuty)
INFOI.PCX        game instructions screen
DEFAULT.PAR      define vertices that compose pieces and board squares and colors
DEFAULT.S        define vertices and polygons of the virtual board
ARQ2D.CC         CArquivo2D implementation file
ARQ2D.H          CArquivo2D declaration file
ARQ3D.CC         CArquivo3D implementation file
ARQ3D.H          CArquivo3D declaration file
ARQUIVO.CC       CArquivo implementation file
ARQUIVO.H        CArquivo declaration file
CONTROLE.CC      CControle implementation file
CONTROLE.H       CControle declaration file
CONTRSOL.CC      CControleSolido implementation file
CONTRSOL.H       CControleSolido declaration file
CONTRUNI.CC      CControleUniverso implementation file
CONTRUNI.H       CControleUniverso declaration file
DAMAS.CC         CDamas implementation file
DAMAS.H          CDamas declaration file
DEFS.H           general macros
DEPURA.H         debug macros
GR.CC            CGr implementation file
GR.H             CGr declaration file
GRVD.CC          CGrVd implementation file
GRVD.H           CGrVd declaration file
IMAGEM.CC        CImagem implementation file
IMAGEM.H         CImagem declaration file
RENDER.CC        CRender implementation file
RENDER.H         CRender declaration file
SOLIDO.CC        CSolido implementation file
SOLIDO.H         CSolido declaration file
SR.CC            CSR implementation file
SR.H             CSR declaration file
TECLADO.CC       CTeclado implementation file
TECLADO.H        CTeclado declaration file
TRANSF.CC        CTransf implementation file
TRANSF.H         CTransf declaration file
UNIVERSO.CC      CUniverso implementation file
UNIVERSO.H       CUniverso declaration file


TANKS
-----

  x2ftp.oulu.fi uploaders (Denthor, ...) and site administration;
  DJGPP developes and collaborators;
  some people in UFRGS - Universidade Federeal do Rio Grande do Sul.


DICTIONARY
----------

atribuir     - set (in context of this program)
arquivo      - file
colunas      - rows
comer        - capture (in context of this program)*
damas        - checkers
depurar      - debug
direita      - right
escrever     - write
esquerda     - left
frente       - forward
jogo         - game
ler          - read
mostrar      - show
nivel        - level
profundidade - depth
quadros      - frames
rainha       - king (in context of this program)**
teclado      - keyboard
tras         - backward

*  - the literal translaction is: eat
** - the literal translaction is: queen
