/*
 *
 * init.c -- static declarations
 *
 * This code is copyright 1995 by James A. Cherry, jac@doe.carleton.ca.
 * It is not to be redistributed or modified without his permission.
 *
 */

#include "funddefs.h"
#include "fowc.h"

char Board[16][16], TBoard[16][16]; /* storage for board and temporary board */

char Words[2170000]; /* dictionary storage space */
long WPtr[220200];   /* pointers to start of words */
long WLen[MAX_WLEN + 2][27]; /* pointers to start of words beginning with each
                                letter of each length*/
long DictSize;       /* dictionary size */

char PlrTiles[2][7];               /* player racks */
int PlrScores[2];                  /* player scores */
int TilesLeft[27], TTilesLeft[27]; /* tiles of each type left */
int Track[27], TTrack[27];         /* tracking for robot */

int MyPlrNum, TheirPlrNum;         /* index for robot and opponent (0 or 1) */

int B1X, B1Y, B2X, B2Y;            /* location of blank tiles on board */

compmove *CHead;                   /* pointer to queue of moves */
int IgnoreSmaller;                 /* 1 to ignore plays other than the best */
int VerticalPlay;                  /* kludge for critique */

struct another_word NewWords[8];   /* list of words formed */

struct let_distrib Letters[28] = { /* standard tile distribution */
   {9,  1},  {2,  3},  {2,  3},  {4,  2}, {12,  1},  {2,  4},
   {3,  2},  {2,  4},  {9,  1},  {1,  8},  {1,  5},  {4,  1},
   {2,  3},  {6,  1},  {8,  1},  {2,  3},  {1, 10},  {6,  1},
   {4,  1},  {6,  1},  {4,  1},  {2,  4},  {2,  4},  {1,  8},
   {2,  4},  {1, 10},  {2,  0},  {0,  0} };

int RackLeave[27][8] = {           /* rack leave scores, times two */
    { 0,    2,   -2,  -12,  -28,  -50,  -78, -112,}, /* A */
    { 0,   -7,  -20,  -39,  -64,  -95, -132, -175,}, /* B */
    { 0,   -1,   -9,  -24,  -46,  -75, -111, -154,}, /* C */
    { 0,    0,   -5,  -15,  -30,  -50,  -75, -105,}, /* D */
    { 0,    8,   11,    9,    2,  -10,  -27,  -49,}, /* E */
    { 0,   -4,  -12,  -24,  -40,  -60,  -84, -112,}, /* F */
    { 0,   -4,  -13,  -27,  -46,  -70,  -99, -133,}, /* G */
    { 0,    1,   -5,  -18,  -38,  -65,  -99, -140,}, /* H */
    { 0,   -1,  -10,  -27,  -52,  -85, -126, -175,}, /* I */
    { 0,   -6,  -12,  -18,  -24,  -30,  -36,  -42,}, /* J */
    { 0,   -5,  -10,  -15,  -20,  -25,  -30,  -35,}, /* K */
    { 0,   -2,   -8,  -18,  -32,  -50,  -72,  -98,}, /* L */
    { 0,   -2,   -8,  -18,  -32,  -50,  -72,  -98,}, /* M */
    { 0,    1,   -3,  -12,  -26,  -45,  -69,  -98,}, /* N */
    { 0,   -3,  -13,  -30,  -54,  -85, -123, -168,}, /* O */
    { 0,   -3,  -11,  -24,  -42,  -65,  -93, -126,}, /* P */
    { 0,  -23,  -46,  -69,  -92, -115, -138, -161,}, /* Q */
    { 0,    3,   -1,  -12,  -30,  -55,  -87, -126,}, /* R */
    { 0,   15,   22,   21,   12,   -5,  -30,  -63,}, /* S */
    { 0,    0,   -5,  -15,  -30,  -50,  -75, -105,}, /* T */
    { 0,   -6,  -18,  -36,  -60,  -90, -126, -168,}, /* U */
    { 0,  -11,  -29,  -54,  -86, -125, -171, -224,}, /* V */
    { 0,   -8,  -25,  -51,  -86, -130, -183, -245,}, /* W */
    { 0,    7,   14,   21,   28,   35,   42,   49,}, /* X */
    { 0,   -4,  -17,  -39,  -70, -110, -159, -217,}, /* Y */
    { 0,    4,    8,   12,   16,   20,   24,   28,}, /* Z */
    { 0,   49,   68,   57,   16,  -55, -156, -287,}, /* ? */
};

int VCMix[8][8] = {                /* vowel/consonant mix heuristics */
	{  0,  0, -1, -2, -3, -4, -5,  0},
	{ -1,  1,  1,  0, -1, -2,  0,  0},
	{ -2,  0,  2,  2,  1,  0,  0,  0},
	{ -3, -1,  1,  3,  0,  0,  0,  0},
	{ -4, -2,  0,  0,  0,  0,  0,  0},
	{ -5, -3,  0,  0,  0,  0,  0,  0},
	{ -6,  0,  0,  0,  0,  0,  0,  0},
	{  0,  0,  0,  0,  0,  0,  0,  0}
};

/* hook tables */
int HHook[16][16][27], THHook[16][16][27];
int VHook[16][16][27], TVHook[16][16][27];

int SockP;                  /* file number for socket */
char SocketError[80];       /* storage for error from socket, if needed */

int PrevState, CurrState;   /* previous and current state numbers */ 
int PrevTicks, CurrTicks;   /* previous and current number of clock ticks */

struct plrlet MyPlay[7];    /* letters placed on ACBot's play */
int MyWords;                /* number of words formed by ACBot */
int MyPlaced;               /* number of tiles placed by ACBot */
int MyDX;                   /* X direction for ACBot */
int MyDY;                   /* Y direction for ACBot */
struct plrlet TheirPlay[7]; /* same things for opponent */
int TheirWords;
int TheirPlaced;
int TheirDX;
int TheirDY;

/* strings for conversion of moves from internal form to `8b RETINAS' form */
char MoveString[25], MoveLS[5], MoveWS[20];

char BlackList[100][20];    /* blacklist names */
int BListLen;               /* length of blacklist */

char TokenChars[5] = "()! |";  /* token characters for `words' command */

int TokenPairs[5][5] = {       /* allowable pairs of tokens */
    { PAIR_OK , PAIR_SYN, PAIR_OK , PAIR_OK , PAIR_SYN },
    { PAIR_AND, PAIR_OK , PAIR_AND, PAIR_AND, PAIR_OK  },
    { PAIR_OK , PAIR_SYN, PAIR_OK , PAIR_OK , PAIR_SYN },
    { PAIR_AND, PAIR_OK , PAIR_AND, PAIR_AND, PAIR_OK  },
    { PAIR_OK , PAIR_SYN, PAIR_OK , PAIR_OK , PAIR_SYN }
};

/* names of numbers */
char NumNames[10][6] = { "zero", "one", "two", "three", "four", "five",
			 "six", "seven", "eight", "nine" };

int DoomName;        /* name of DOoM */
char PlrName[20];    /* ACBot's name */
char Password[20];   /* password for ACBot to connect */

FILE *LogFile;       /* file pointer to logfile */
int Logging;         /* whether or not to log */

