Hogwarts Wand Docs: ../server/check.c

Wand Sourcecode: ../server/check.c

//
// check.c - run the comparison 
//
// Copyright (C) 2006  Nathan (Acorn) Pooley
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
// 
// 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.  See the
// GNU General Public License (gpl.txt) for more details. 
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
// 
// You can contact the author, Nathan (Acorn) Pooley, by writing
// to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA
// or through the form at http://www.rawbw.com/~acorn/wand/feedback.html
//

//
// OBSOLETE - see fmtb_parse.c
//

//#@DOC@ OBSOLETE utility to compare a motion spell (from parse) with known spells

//###########################################################################
//############################### INCLUDES ##################################
//###########################################################################

#include <stdio.h>
#include <stdlib.h>

#include "ac_assert.h"

#include "tokens.h"

//###########################################################################
//############################### DEFINES ###################################
//###########################################################################

//
// SHOW_COVERAGE - just show which table entries are used & how often
//
#define SHOW_COVERAGE   0
#define CK_DEBUG        0

#define MAX_PATTERN     128
#define MAX_MOTION      128

//###########################################################################
//############################### TYPEDEFS ##################################
//###########################################################################

typedef struct CkPatternRec {
    char *name;
    unsigned char *tokens;
    int len;
    int group;
    float quality;
} CkPattern, CkMotion;

//###########################################################################
//############################### GLOBALS ###################################
//###########################################################################

int g_mtx[MAX_MOTION][MAX_PATTERN];
int g_tables[6][CK_TOKSHAPE_CNT][CK_TOKSHAPE_CNT];
int g_gap[2][CK_TOKSHAPE_CNT];
FILE *g_log = 0;

unsigned char g_wpicacorn_fa_1[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x24};
unsigned char g_wpicacorn_fa_2[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x42};
unsigned char g_wpicacorn_fa_3[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00 /*,0x43,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicacorn_fb_1[] = { 0x36,0x07,0x04,0x21,0x00,0x03,0x02 /*,0x41,0x13,0x11,0x13,0x11,0x13,0x31,0x00 */};
unsigned char g_wpicacorn_fb_2[] = { 0x35,0x06,0x07,0x04,0x05,0x46,0x30,0x03,0x02,0x01,0x24 /*,0x21,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x40 */};
unsigned char g_wpicacorn_fb_3[] = { 0x35,0x06,0x07,0x04,0x05,0x06 /*,0x47,0x11,0x13,0x11,0x33,0x42*/};
unsigned char g_wpicacorn_fc_1[] = { 0x31,0x00,0x03,0x02,0x01,0x40,0x50,0x11,0x33,0x02 /* ,0x41,0x13,0x31,0x00,0x03,0x02,0x41,0x13,0x31,0x00,0x27,0x04,0x45,0x13,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fc_2[] = { 0x31,0x00,0x03,0x02,0x01,0x24,0x45 /* ,0x13,0x11,0x13,0x31,0x00,0x27,0x04,0x21,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00 */};
unsigned char g_wpicacorn_fd_1[] = { 0x36,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x41 /*,0x50,0x32,0x01,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fd_2[] = { 0x36,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x46 /*,0x50,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fd_3[] = { 0x36,0x07,0x04,0x05,0x06,0x07,0x44,0x12 /*,0x50,0x31,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x42,0x00*/};
unsigned char g_wpicacorn_ff_deeann00000[] = { 0x34,0x05,0x06,0x07,0x04,0x05,0x46,0x13,0x50,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x37,0x44,0x50,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x00};
unsigned char g_wpicacorn_ff_deeann00001[] = { 0x34,0x05,0x06,0x07,0x04,0x45,0x13,0x50,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x37,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00};
unsigned char g_wpicacorn_ff_deeann00002[] = { 0x13,0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x50,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x37,0x44,0x00};
unsigned char g_wpicacorn_fg_1[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x04};
unsigned char g_wpicacorn_fg_2[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x47 /*,0x50,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fg_3[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x47 /*,0x50,0x13,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fh_1[] = { 0x35,0x06,0x07,0x44,0x33,0x02,0x25,0x06,0x47 /*,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fh_2[] = { 0x35,0x06,0x07,0x04,0x05,0x22 /* ,0x41,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fh_3[] = { 0x35,0x06,0x47,0x11,0x33,0x02 /* ,0x41,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fh_curtis00000[] = { 0x37,0x44,0x32,0x41,0x13 /* ,0x50,0x13,0x35,0x06,0x23,0x02,0x41,0x13,0x11,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x13,0x35,0x46,0x00*/};
unsigned char g_wpicacorn_fh_curtis00001[] = { 0x11,0x37,0x44,0x32,0x41,0x13 /* ,0x50,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x25,0x06,0x23,0x02,0x25,0x06,0x23,0x02,0x25,0x06,0x23,0x02,0x25,0x06,0x23,0x02*/};
unsigned char g_wpicacorn_fh_curtis00002[] = { 0x11,0x37,0x44,0x32,0x41,0x13 /* ,0x50,0x13,0x35,0x06,0x23,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x35,0x06,0x23,0x02,0x25,0x06,0x23,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicacorn_fh_deeann00000[] = { 0x34,0x05,0x06,0x47,0x11,0x32,0x41,0x13 /* ,0x50,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x37,0x44,0x00*/};
unsigned char g_wpicacorn_fh_deeann00001[] = { 0x13,0x11,0x37,0x04,0x45 /* ,0x50,0x13,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fh_deeann00002[] = { 0x36,0x47,0x11,0x32 /* ,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x37,0x04,0x21,0x00*/};
unsigned char g_wpicacorn_fh_sean00000[] = { 0x11,0x13,0x31,0x40 /* ,0x50,0x37,0x04,0x45,0x13,0x11,0x37,0x04*/};
unsigned char g_wpicacorn_fh_sean00001[] = { 0x11,0x36,0x07,0x44,0x32,0x01,0x00,0x43 /* ,0x50,0x37,0x04,0x21,0x00,0x27,0x04,0x45,0x33,0x02*/};
unsigned char g_wpicacorn_fh_sean00002[] = { 0x11,0x12,0x10,0x32,0x01,0x00};
unsigned char g_wpicacorn_fh_sean00003[] = { 0x11,0x36,0x07,0x44,0x32};
unsigned char g_wpicacorn_fh_sean00004[] = { 0x11,0x50,0x36,0x07,0x44,0x32,0x01,0x40 /*,0x50,0x13,0x11,0x37,0x04*/};
unsigned char g_wpicacorn_fh_sean00005[] = { 0x11,0x50,0x37,0x44,0x32,0x01,0x40 /* ,0x50,0x37,0x04,0x45,0x37,0x04*/};
unsigned char g_wpicacorn_fh_sean00006[] = { 0x11,0x50,0x37,0x44,0x32,0x01,0x40 /* ,0x50,0x37,0x04,0x45,0x37,0x04*/};
unsigned char g_wpicacorn_fj_1[] = { 0x33,0x02,0x01,0x00,0x03,0x26,0x07,0x04,0x45,0x37,0x04,0x45 /* ,0x50,0x33,0x02,0x41,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fj_2[] = { 0x33,0x02,0x01,0x00,0x43,0x36,0x07,0x04,0x05,0x06,0x07,0x20,0x43 /* ,0x50,0x13,0x11,0x13,0x31,0x40,0x37,0x04,0x21,0x40,0x13,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fj_3[] = { 0x33,0x02,0x01,0x00,0x43,0x36,0x07,0x04,0x05,0x46 /* ,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x40,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fj_4[] = { 0x30,0x03,0x02,0x01,0x40,0x36,0x07,0x04,0x05,0x06,0x07,0x44 /* ,0x50,0x13,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fk_1[] = { 0x35,0x06,0x47,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41 /* ,0x50,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fk_2[] = { 0x35,0x06,0x07,0x04,0x21,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x26,0x47,0x31,0x00 /* ,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fk_3[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00 /* ,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x40,0x13,0x31,0x00,0x43,0x11,0x13,0x31,0x40,0x13,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fl_1[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x24,0x45 /* ,0x50,0x11,0x13,0x11,0x33,0x02,0x01,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02*/};
unsigned char g_wpicacorn_fl_2[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x24};
unsigned char g_wpicacorn_fl_3[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x24 /* ,0x45,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x40,0x00*/};
unsigned char g_wpicacorn_fl_deeann00000[] = { 0x12,0x35,0x06,0x07,0x44,0x36,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02};
unsigned char g_wpicacorn_fl_deeann00001[] = { 0x34,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02};
unsigned char g_wpicacorn_fl_deeann00002[] = { 0x34,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40 /* ,0x50,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x40*/};
unsigned char g_wpicacorn_fl_sean00000[] = { 0x11,0x13,0x35,0x06,0x07,0x44,0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x24};
unsigned char g_wpicacorn_fl_sean00001[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40 /* ,0x50,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fl_sean00002[] = { 0x11,0x37,0x04,0x05,0x06,0x47,0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x10};
unsigned char g_wpicacorn_fm_1[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00 /* ,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicacorn_fm_2[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x30,0x03,0x42,0x11 /* ,0x50,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x11,0x13,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fm_3[] = { 0x35,0x06,0x07,0x04,0x05,0x06,0x23,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02 /* ,0x41,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicacorn_fm_4[] = { 0x35,0x06,0x47,0x11,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02 /* ,0x41,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fm_5[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41 /* ,0x50,0x31,0x00,0x43,0x31,0x40,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fm_6[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x24,0x45 /* ,0x50,0x11,0x33,0x02,0x01,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fm_deeann00000[] = { 0x13,0x50,0x37,0x04,0x45,0x50,0x33,0x42,0x50,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x12,0x10};
unsigned char g_wpicacorn_fm_deeann00002[] = { 0x11,0x13,0x11,0x33,0x02,0x01,0x40,0x50,0x33,0x02,0x01,0x40,0x50,0x33,0x02,0x01,0x40,0x50,0x10,0x12,0x50,0x34};
unsigned char g_wpicacorn_fm_deeann00003[] = { 0x34,0x05,0x06,0x07,0x04,0x21,0x40,0x32,0x01,0x40,0x32,0x01,0x00,0x03,0x02,0x01,0x40,0x32,0x41,0x32};
unsigned char g_wpicacorn_fm_deeann00004[] = { 0x35,0x06,0x47,0x11,0x32,0x01,0x40,0x32,0x01,0x40,0x32,0x01,0x40};
unsigned char g_wpicacorn_fm_jerry00000[] = { 0x35,0x06,0x07,0x44,0x12,0x10,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41 /* ,0x50,0x12,0x50,0x31,0x00*/};
unsigned char g_wpicacorn_fm_jerry00001[] = { 0x35,0x06,0x07,0x04,0x21,0x00,0x03,0x42,0x30,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41 /* ,0x50,0x12,0x50,0x11,0x13,0x11,0x13,0x31,0x40*/};
unsigned char g_wpicacorn_fm_jerry00002[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x30,0x03,0x02,0x41 /* ,0x50,0x32,0x41,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x10,0x00*/};
unsigned char g_wpicacorn_fm_jerry00003[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x30,0x03,0x02};
unsigned char g_wpicacorn_fm_sean00000[] = { 0x34,0x05,0x06,0x47,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x10,0x32};
unsigned char g_wpicacorn_fm_sean00001[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x30,0x03,0x02,0x41 /* ,0x50,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicacorn_fm_sean00002[] = { 0x11,0x13,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x30,0x03,0x02,0x25,0x46,0x11 /* ,0x50,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicacorn_fn_1[] = { 0x11,0x13,0x11,0x50,0x30,0x03,0x02,0x41,0x12,0x10,0x50,0x13,0x11,0x13,0x50,0x12,0x10,0x12,0x10 /* ,0x50,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpicacorn_fn_2[] = { 0x11,0x13,0x31,0x00,0x43,0x50,0x10,0x32,0x41,0x10,0x12,0x10,0x50,0x13,0x11,0x13,0x31,0x40 /* ,0x50,0x12,0x10,0x12,0x10,0x12,0x50,0x11,0x37,0x04,0x21,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00,0x43,0x31,0x00*/};
unsigned char g_wpiccary1_00000[] = { 0x12,0x30,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41,0x37,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x20,0x03,0x42,0x30,0x03,0x42,0x30,0x27,0x04};
unsigned char g_wpiccary1_00001[] = { 0x10,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x36,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x20,0x03,0x42,0x10,0x32,0x01,0x00};
unsigned char g_wpiccary1_00002[] = { 0x30,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x36,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x12,0x30,0x03,0x02,0x01,0x00,0x43,0x35,0x06,0x47,0x35,0x06,0x23,0x02};
unsigned char g_wpiccary1_sean00000[] = { 0x30,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41,0x37,0x04,0x05,0x06,0x07,0x04,0x05,0x22,0x25,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x12,0x10,0x12,0x13,0x12,0x10,0x50,0x13,0x11,0x33,0x02,0x01,0x00};
unsigned char g_wpiccary1_sean00001[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x25,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x12,0x30,0x03,0x26,0x47,0x12 /* ,0x50,0x37,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x00*/};
unsigned char g_wpiccary1_sean00002[] = { 0x30,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41,0x37,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x44,0x36,0x07,0x20,0x03,0x42,0x33,0x42 /* ,0x50,0x37,0x04,0x21,0x00,0x43,0x31,0x00,0x27,0x04*/};
unsigned char g_wpiccurtis1_00000[] = { 0x11,0x37,0x04,0x05,0x06,0x47,0x35,0x46,0x34,0x45,0x13,0x34,0x05,0x06,0x47,0x31,0x40 /* ,0x50,0x11,0x33,0x02,0x41,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x11,0x33,0x02*/};
unsigned char g_wpiccurtis1_00001[] = { 0x11,0x37,0x44,0x12,0x35,0x46,0x34,0x45,0x37,0x44,0x36,0x47,0x31,0x40 /* ,0x50,0x11,0x37,0x04,0x45,0x13,0x35,0x06,0x23,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x35,0x06,0x23,0x02,0x41,0x13,0x35,0x46,0x00*/};
unsigned char g_wpiccurtis1_00002[] = { 0x11,0x37,0x44,0x36,0x47,0x35,0x46,0x34,0x45,0x37,0x44,0x36,0x47,0x11 /* ,0x50,0x10,0x50,0x31,0x00,0x43,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x12,0x00*/};
unsigned char g_wpiccurtis1_00003[] = { 0x11,0x37,0x44,0x36,0x47,0x35,0x46,0x34,0x45,0x37,0x44,0x36,0x47,0x11 /* ,0x50,0x10,0x50,0x31,0x00,0x43,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x12,0x00*/};
unsigned char g_wpiccurtis2_00000[] = { 0x12,0x10,0x37,0x20,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41 /* ,0x50,0x10,0x50,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x33,0x02,0x41,0x33,0x02*/};
unsigned char g_wpiccurtis2_00001[] = { 0x12,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41,0x10 /* ,0x50,0x36,0x07,0x04,0x45,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x41,0x13,0x00*/};
unsigned char g_wpiccurtis2_00002[] = { 0x12,0x34,0x45,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x41,0x10 /* ,0x50,0x31,0x00,0x43,0x11,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02*/};
unsigned char g_wpicjerry1_00000[] = { 0x12,0x10,0x11,0x13,0x50,0x10,0x12,0x10,0x13,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x10 /* ,0x50,0x13,0x31,0x40,0x13,0x11,0x13,0x31,0x40*/};
unsigned char g_wpicjerry1_00001[] = { 0x12,0x10,0x12,0x13,0x10,0x12,0x30,0x43,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00};
unsigned char g_wpicjerry1_00002[] = { 0x12,0x10,0x12,0x30,0x43,0x11,0x12,0x30,0x43,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40};
unsigned char g_wpicsean1_00000[] = { 0x31,0x00,0x03,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x42,0x13 /* ,0x50,0x11,0x37,0x04,0x45,0x13,0x11,0x13,0x11,0x13,0x11,0x12,0x00*/};
unsigned char g_wpicsean1_00001[] = { 0x31,0x00,0x03,0x02,0x25,0x06,0x23,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x43,0x12,0x13,0x11,0x13 /* ,0x50,0x37,0x04,0x45,0x33,0x02,0x25,0x06,0x23,0x02,0x41,0x33,0x42,0x31,0x00,0x43,0x31,0x00,0x27,0x04,0x05,0x06,0x23,0x02*/};
unsigned char g_wpicsean1_00002[] = { 0x11,0x33,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x12,0x11,0x13 /* ,0x50,0x33,0x02,0x41,0x33,0x02,0x25,0x06,0x23,0x02,0x41,0x13,0x11,0x36,0x47,0x11,0x13,0x31,0x40*/};
unsigned char g_wpicsean1_curtis00000[] = { 0x31,0x00,0x03,0x02,0x01,0x40,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x12 /* ,0x50,0x13,0x11,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicsean1_curtis00001[] = { 0x31,0x00,0x03,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x43,0x12 /* ,0x50,0x11,0x33,0x02,0x41,0x13,0x11,0x37,0x04*/};
unsigned char g_wpicsean1_curtis00002[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x12};
unsigned char g_wpicsean1_deeann00000[] = { 0x11,0x33,0x02,0x25,0x06,0x47,0x31,0x00,0x03,0x02,0x01,0x40,0x12,0x10};
unsigned char g_wpicsean1_deeann00001[] = { 0x11,0x33,0x02,0x25,0x06,0x23,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x12,0x10 /* ,0x50,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicsean1_deeann00002[] = { 0x30,0x03,0x42,0x10,0x36,0x23,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x12 /* ,0x11,0x13,0x31,0x00,0x43,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicsean1_eric00000[] = { 0x11,0x33,0x02,0x41,0x13,0x50,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x36,0x47 /* ,0x50,0x13,0x11,0x13,0x11,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x00*/};
unsigned char g_wpicsean1_eric00001[] = { 0x31,0x40,0x33,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x32,0x41 /* ,0x50,0x11,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04*/};
unsigned char g_wpicsean1_eric00002[] = { 0x11,0x33,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x12,0x10 /* ,0x50,0x11,0x37,0x04,0x45,0x13,0x11,0x13,0x11,0x37,0x04*/};
unsigned char g_wpicsean1_jerry00000[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x50,0x33,0x02,0x01,0x00,0x03,0x02,0x01,0x24,0x05,0x46,0x10 /* ,0x50,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicsean1_jerry00001[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x36,0x47 /* ,0x50,0x12,0x30,0x03,0x02,0x01,0x00*/};
unsigned char g_wpicsean1_jerry00002[] = { 0x31,0x00,0x03,0x02,0x01,0x40,0x13,0x11,0x33,0x02,0x01,0x00,0x03,0x42,0x10,0x36,0x07,0x44 /* ,0x50,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicsean1_xxx00000[] = { 0x11,0x33,0x02,0x41,0x13,0x50,0x31,0x00,0x03,0x02,0x01,0x40,0x12,0x10,0x50,0x31,0x00,0x03,0x02};
unsigned char g_wpicsean1_xxx00001[] = { 0x11,0x33,0x02,0x41,0x13,0x31,0x00,0x03,0x02,0x41,0x10,0x12};
unsigned char g_wpicsean2_00000[] = { 0x12,0x10,0x12,0x10,0x12,0x34,0x05,0x22,0x01,0x24,0x05,0x22,0x01,0x24,0x05,0x46,0x10,0x36,0x07,0x20,0x03,0x42,0x37,0x20,0x27,0x44 /* ,0x50,0x11,0x33,0x02,0x01,0x00,0x43,0x11,0x37,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x27,0x44,0x00*/};
unsigned char g_wpicsean2_00001[] = { 0x12,0x10,0x12,0x10,0x12,0x34,0x05,0x22,0x01,0x24,0x05,0x22,0x01,0x24,0x05,0x46,0x34,0x05,0x06,0x07,0x20,0x03,0x26,0x07,0x44,0x13 /* ,0x50,0x32,0x41,0x37,0x04*/};
unsigned char g_wpicsean2_00002[] = { 0x12,0x10,0x12,0x10,0x12,0x34,0x05,0x46,0x34,0x05,0x22,0x01,0x24,0x05,0x46,0x34,0x05,0x46,0x10,0x12,0x30,0x03,0x02,0x41,0x13 /* ,0x50,0x12,0x33,0x02,0x25,0x46,0x33,0x02,0x41,0x13,0x11,0x13,0x31,0x00,0x27,0x04*/};
unsigned char g_wpicsean2_00003[] = { 0x12,0x10,0x12,0x10,0x12,0x34,0x05,0x46,0x34,0x05,0x22,0x01,0x24,0x05,0x46,0x34,0x05,0x46,0x10,0x12,0x30,0x03,0x02,0x41,0x13 /* ,0x50,0x12,0x33,0x02,0x25,0x46,0x33,0x02,0x41,0x13,0x11,0x13,0x31,0x00,0x27,0x04*/};
unsigned char g_wpicsean2_cary00000[] = { 0x12,0x30,0x03,0x42,0x10,0x12,0x30,0x03,0x42,0x10,0x12,0x30,0x03,0x42,0x13,0x10,0x12,0x30,0x43,0x12,0x10,0x12,0x13 /* ,0x50,0x37,0x20,0x43,0x50,0x13,0x11,0x33,0x02,0x41,0x13,0x00*/};
unsigned char g_wpicsean2_cary00001[] = { 0x12,0x10,0x12,0x10,0x12,0x10,0x12,0x10,0x12,0x10,0x12,0x10,0x32,0x41,0x10 /* ,0x50,0x11,0x13,0x11,0x13,0x31,0x00*/};
unsigned char g_wpicsean2_cary00002[] = { 0x35,0x46,0x10,0x12,0x10,0x12,0x10,0x12,0x10,0x37,0x44,0x36,0x47,0x11,0x37,0x04,0x45,0x33,0x02};
unsigned char g_wpicsean2_jim00000[] = { 0x12,0x10,0x12,0x10,0x50,0x12,0x10,0x12,0x50,0x12,0x10,0x12 /* ,0x50,0x12,0x10,0x12,0x30,0x03,0x42,0x10*/};
unsigned char g_wpicsean2_jim00001[] = { 0x12,0x10,0x12,0x10,0x12,0x10,0x12,0x10,0x32,0x25,0x06,0x07,0x44,0x12,0x10,0x12,0x10,0x12,0x13,0x11 /* ,0x50,0x11,0x13,0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x04*/};
unsigned char g_wpicsean3_00000[] = { 0x36,0x07,0x44,0x32,0x01,0x00,0x27,0x04,0x45,0x13 /* ,0x50,0x37,0x04,0x05,0x06,0x47,0x35,0x06,0x47,0x35,0x06,0x47,0x35,0x06,0x47,0x11,0x13,0x11,0x37,0x04*/};
unsigned char g_wpicsean3_00001[] = { 0x36,0x07,0x44,0x32,0x01,0x00,0x03,0x26,0x07,0x04,0x45,0x13 /* ,0x50,0x37,0x04,0x45,0x13,0x11,0x33,0x02,0x41,0x33,0x02,0x41,0x33,0x02,0x01,0x00,0x03,0x02,0x41,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicsean3_00002[] = { 0x36,0x07,0x44,0x32,0x01,0x00,0x27,0x04,0x45,0x37,0x44,0x13 /* ,0x50,0x13,0x31,0x00*/};
unsigned char g_wpicsean3_curtis00000[] = { 0x36,0x07,0x44,0x33,0x02,0x01,0x40,0x50,0x33,0x26,0x07,0x04,0x05,0x06,0x07,0x44 /* ,0x50,0x11,0x13,0x11,0x37,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07,0x04*/};
unsigned char g_wpicsean3_curtis00001[] = { 0x34,0x05,0x06,0x07,0x04,0x45,0x50,0x31,0x00,0x03,0x42,0x34,0x05,0x06,0x07,0x44 /* ,0x50,0x11,0x13,0x11,0x37,0x04,0x45,0x13,0x11,0x13,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicsean3_curtis00002[] = { 0x35,0x06,0x07,0x44,0x32,0x01,0x00,0x03,0x42,0x34,0x05,0x06,0x07,0x44 /* ,0x50,0x13,0x31,0x00,0x43,0x11,0x37,0x04,0x45,0x37,0x04,0x05,0x06,0x07,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x45,0x37,0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x47,0x35,0x06,0x07,0x04,0x05,0x06,0x07,0x04,0x05,0x06*/};
unsigned char g_wpicsean3_deeann00000[] = { 0x11,0x10,0x31,0x40,0x12,0x10,0x31,0x40};
unsigned char g_wpicsean3_deeann00001[] = { 0x13,0x11,0x32,0x41,0x50,0x30,0x27,0x04,0x05,0x06,0x07,0x44 /* ,0x50,0x31,0x00,0x03,0x02,0x01,0x00,0x43,0x11,0x13,0x31,0x40*/};
unsigned char g_wpicsean3_deeann00002[] = { 0x35,0x06,0x47,0x11,0x32,0x01,0x00,0x43,0x34,0x05,0x06,0x47,0x11,0x33,0x02};
unsigned char g_wpicsean3_eric00000[] = { 0x35,0x06,0x07,0x04,0x45,0x33,0x02,0x01,0x40,0x37,0x44,0x36,0x07,0x44};
unsigned char g_wpicsean3_eric00001[] = { 0x34,0x05,0x06,0x47,0x11,0x33,0x02,0x01,0x40,0x37,0x04,0x05,0x06};
unsigned char g_wpicsean3_eric00002[] = { 0x34,0x05,0x06,0x47,0x11,0x33,0x02,0x41,0x37,0x04,0x45,0x13,0x10};
unsigned char g_wpicsean4_00000[] = { 0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x32,0x01,0x40 /* ,0x50,0x11,0x13,0x11,0x33,0x02*/};
unsigned char g_wpicsean4_00001[] = { 0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x12,0x34,0x45,0x10 /* ,0x50,0x13,0x11,0x33,0x02,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x33,0x02,0x41,0x33,0x02*/};
unsigned char g_wpicsean4_00002[] = { 0x31,0x40,0x32,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x43,0x30,0x43,0x12,0x31,0x40 /* ,0x11,0x33,0x02,0x01,0x00,0x03,0x02,0x41,0x33,0x02,0x41,0x13,0x31,0x40*/};
unsigned char g_wpicsean4_deeann00001[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x00,0x03,0x02 /* ,0x41,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x31,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x00*/};
unsigned char g_wpicsean4_deeann00002[] = { 0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02,0x01,0x40,0x32,0x01,0x24 /* ,0x45,0x13,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x13,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x13,0x11,0x00*/};
unsigned char g_wpicsean4_deeann00003[] = { 0x11,0x50,0x31,0x00,0x03,0x02,0x01,0x00,0x03,0x02 /* ,0x41,0x13,0x31,0x00,0x43,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x37,0x04,0x21,0x00,0x43,0x11,0x13,0x11,0x37,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x27,0x04,0x21,0x00,0x27,0x04,0x21,0x00*/};

#define PAT(n,group,quality)    { #n, n, sizeof(n), group, quality },

//
// group is the ID of the spell
// quality is how good the spellcast is.  The pattern for the spell is the one with 1.0
//
CkPattern g_patlist[] = {
#if 0
    PAT(g_wpicacorn_fg_1, 6, 0.5)
    PAT(g_wpicacorn_fg_2, 6, 0.9)
    PAT(g_wpicacorn_fg_3, 6, 1.0)
    PAT(g_wpicacorn_fh_1, 7, 0.9)
    PAT(g_wpicacorn_fh_2, 7, 0.9)
    PAT(g_wpicacorn_fh_3, 7, 0.9)
    PAT(g_wpicacorn_fh_curtis00000, 7, 0.9)
    PAT(g_wpicacorn_fh_curtis00001, 7, 0.9)
    PAT(g_wpicacorn_fh_curtis00002, 7, 0.9)
    PAT(g_wpicacorn_fh_deeann00000, 7, 0.9)
    PAT(g_wpicacorn_fh_deeann00001, 7, 0.9)
    PAT(g_wpicacorn_fh_deeann00002, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00000, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00001, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00002, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00003, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00004, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00005, 7, 0.9)
    PAT(g_wpicacorn_fh_sean00006, 7, 1.0)
    PAT(g_wpicacorn_fj_1, 8, 0.9)
    PAT(g_wpicacorn_fj_2, 8, 0.5)
    PAT(g_wpicacorn_fj_3, 8, 1.0)
    PAT(g_wpicacorn_fj_4, 8, 0.9)
    PAT(g_wpicacorn_fk_1, 9, 1.0)
    PAT(g_wpicacorn_fk_2, 9, 0.9)
    PAT(g_wpicacorn_fk_3, 9, 9.9)
#endif
    PAT(g_wpicacorn_fl_1, 10, 0.5)
    PAT(g_wpicacorn_fl_2, 10, 0.9)
    PAT(g_wpicacorn_fl_3, 10, 1.0)
    PAT(g_wpicacorn_fl_deeann00000, 10, 0.9)
    PAT(g_wpicacorn_fl_deeann00001, 10, 0.9)
    PAT(g_wpicacorn_fl_deeann00002, 10, 0.9)
    PAT(g_wpicacorn_fl_sean00000, 10, 0.9)
    PAT(g_wpicacorn_fl_sean00001, 10, 0.9)
    PAT(g_wpicacorn_fl_sean00002, 10, 0.5)
    PAT(g_wpicacorn_fm_1, 11, 1.0)
    PAT(g_wpicacorn_fm_2, 11, 0.6)
    PAT(g_wpicacorn_fm_3, 11, 0.9)
    PAT(g_wpicacorn_fm_4, 11, 0.6)
    PAT(g_wpicacorn_fm_5, 11, 0.9)
    PAT(g_wpicacorn_fm_6, 11, 0.9)
    //PAT(g_wpicacorn_fm_deeann00000, 11, 0.001)
    //PAT(g_wpicacorn_fm_deeann00002, 11, 0.001)
    //PAT(g_wpicacorn_fm_deeann00003, 11, 0.001)
    //PAT(g_wpicacorn_fm_deeann00004, 11, 0.001)
    PAT(g_wpicacorn_fm_jerry00000, 11, 0.8)
    PAT(g_wpicacorn_fm_jerry00001, 11, 0.1)
    PAT(g_wpicacorn_fm_jerry00002, 11, 0.1)
    PAT(g_wpicacorn_fm_jerry00003, 11, 0.3)
    PAT(g_wpicacorn_fm_sean00000, 11, 0.1)
    PAT(g_wpicacorn_fm_sean00001, 11, 0.7)
    PAT(g_wpicacorn_fm_sean00002, 11, 0.1)
#if 0
    PAT(g_wpicacorn_fn_1, 12, 1.0)
    PAT(g_wpicacorn_fn_2, 12, 0.1)
#endif
    PAT(g_wpiccary1_00000, 13, 0.9)
    PAT(g_wpiccary1_00001, 13, 1.0)
    PAT(g_wpiccary1_00002, 13, 0.9)
    PAT(g_wpiccary1_sean00000, 13, 0.9)
    PAT(g_wpiccary1_sean00001, 13, 0.9)
    PAT(g_wpiccary1_sean00002, 13, 0.9)
#if 0
    PAT(g_wpiccurtis1_00000, 14, 0.9)
    PAT(g_wpiccurtis1_00001, 14, 1.0)
    PAT(g_wpiccurtis1_00002, 14, 0.9)
    PAT(g_wpiccurtis1_00003, 14, 0.9)
    PAT(g_wpiccurtis2_00000, 15, 0.9)
    PAT(g_wpiccurtis2_00001, 15, 0.9)
    PAT(g_wpiccurtis2_00002, 15, 1.0)
    PAT(g_wpicjerry1_00000, 16, 0.9)
    PAT(g_wpicjerry1_00001, 16, 1.0)
    PAT(g_wpicjerry1_00002, 16, 0.9)
#endif
    PAT(g_wpicsean1_00000, 17, 1.0)
    PAT(g_wpicsean1_00001, 17, 0.1)
    PAT(g_wpicsean1_00002, 17, 0.9)
    PAT(g_wpicsean1_curtis00000, 17, 0.9)
    PAT(g_wpicsean1_curtis00001, 17, 0.9)
    PAT(g_wpicsean1_curtis00002, 17, 0.9)
    PAT(g_wpicsean1_deeann00000, 17, 0.5)
    PAT(g_wpicsean1_deeann00001, 17, 0.5)
    PAT(g_wpicsean1_deeann00002, 17, 0.5)
    PAT(g_wpicsean1_eric00000, 17, 0.1)
    PAT(g_wpicsean1_eric00001, 17, 0.1)
    PAT(g_wpicsean1_eric00002, 17, 0.1)
    PAT(g_wpicsean1_jerry00000, 17, 0.1)
    PAT(g_wpicsean1_jerry00001, 17, 0.1)
    PAT(g_wpicsean1_jerry00002, 17, 0.1)
#if 0
    PAT(g_wpicsean2_00000, 18, 0.9)
    PAT(g_wpicsean2_00001, 18, 0.9)
    PAT(g_wpicsean2_00002, 18, 0.9)
    PAT(g_wpicsean2_00003, 18, 1.0)
    PAT(g_wpicsean2_cary00000, 18, 0.8)
    PAT(g_wpicsean2_cary00001, 18, 0.8)
    PAT(g_wpicsean2_cary00002, 18, 0.8)
    PAT(g_wpicsean2_jim00000, 18, 0.1)
    PAT(g_wpicsean2_jim00001, 18, 0.1)
#endif
    PAT(g_wpicsean3_00000, 19, 0.9)
    PAT(g_wpicsean3_00001, 19, 0.9)
    PAT(g_wpicsean3_00002, 19, 0.9)
    PAT(g_wpicsean3_curtis00000, 19, 0.9)
    PAT(g_wpicsean3_curtis00001, 19, 0.01)
    PAT(g_wpicsean3_curtis00002, 19, 1.0)
    PAT(g_wpicsean3_deeann00000, 19, 0.01)
    PAT(g_wpicsean3_deeann00001, 19, 0.1)
    PAT(g_wpicsean3_deeann00002, 19, 0.9)
    PAT(g_wpicsean3_eric00000, 19, 0.9)
    PAT(g_wpicsean3_eric00001, 19, 0.7)
    PAT(g_wpicsean3_eric00002, 19, 0.7)
#if 0
    PAT(g_wpicsean4_00000, 20, 0.6)
    PAT(g_wpicsean4_00001, 20, 0.6)
    PAT(g_wpicsean4_00002, 20, 1.0)
    PAT(g_wpicsean4_deeann00001, 20, 0.1)
    PAT(g_wpicsean4_deeann00002, 20, 0.1)
    PAT(g_wpicsean4_deeann00003, 20, 0.1)
#endif

#if 0
    //
    // These patterns are not very good
    //
    PAT(g_wpicsean1_xxx00000, 17, 0.0)
    PAT(g_wpicsean1_xxx00001, 17, 0.0)
    PAT(g_wpicacorn_fa_1, 1, 0.5)
    PAT(g_wpicacorn_fa_2, 1, 0.5)
    PAT(g_wpicacorn_fa_3, 1, 1.0)
    PAT(g_wpicacorn_fb_1, 2, 0.5)
    PAT(g_wpicacorn_fb_2, 2, 0.5)
    PAT(g_wpicacorn_fb_3, 2, 1.0)
    PAT(g_wpicacorn_fc_1, 3, 0.5)
    PAT(g_wpicacorn_fc_2, 3, 1.0)
    PAT(g_wpicacorn_fd_1, 4, 0.5)
    PAT(g_wpicacorn_fd_2, 4, 0.5)
    PAT(g_wpicacorn_fd_3, 4, 1.0)
    PAT(g_wpicacorn_ff_deeann00000, 5, 0.3)
    PAT(g_wpicacorn_ff_deeann00001, 5, 0.3)
    PAT(g_wpicacorn_ff_deeann00002, 5, 0.3)
#endif
};

//###########################################################################
//############################### CODE ######################################
//###########################################################################

//===========================================================================
// CkInitTables() - initialize tables to default values
//===========================================================================
void CkInitTables(void)
{
    int p,m;
    for (m=0; m<CK_TOKSHAPE_CNT; m++) {
        p = m;
        g_gap[0][m] = 255; //3;
        g_gap[1][p] = 255; //3;
        for (p=0; p<CK_TOKSHAPE_CNT; p++) {
            if (p==m) {
                g_tables[0][m][p] = 0;
                g_tables[1][m][p] = 10;  // 127; //4;
                g_tables[2][m][p] = 20;  // 255; //5;
                g_tables[3][m][p] = 10;  // 127; //4;
                g_tables[4][m][p] = 30;  // 255; //7;
                g_tables[5][m][p] = 30;  // 255; //10;
            } else {
                g_tables[0][m][p] =  5;  // 20; //1;
                g_tables[1][m][p] = 10;  // 127; //5;
                g_tables[2][m][p] = 30;  // 255; //7;
                g_tables[3][m][p] = 20;  // 127; //5;
                g_tables[4][m][p] = 30;  // 255; //10;
                g_tables[5][m][p] = 30;  // 255; //15;
            }
        }
    }
}
// NOTE:  start all 127 -- converge on sum0 = 3,117,865

//===========================================================================
// CkPrintTablesSub() - print tables
//===========================================================================
void CkPrintTablesSub(FILE *fp)
{
    int p,m,t;
    for (m=0; m<CK_TOKSHAPE_CNT; m++) {
        fprintf(fp," gap[%d] = %3d  %3d\n",
            m,
            g_gap[0][m],
            g_gap[1][m]);
    }
    for (t=0; t<6; t++) {
        for (m=0; m<CK_TOKSHAPE_CNT; m++) {
            fprintf(fp," tbl[%d][%d] = ",t,m);
            for (p=0; p<CK_TOKSHAPE_CNT; p++) {
                fprintf(fp,"%3d ",g_tables[t][m][p]);
            }
            fprintf(fp,"\n");
        }
        fprintf(fp,"\n");
    }
}

//===========================================================================
// CkPrintTables() - print tables
//===========================================================================
void CkPrintTables(int pass)
{
    char *filename = "best_table.txt";
    char filename2[100];
    FILE *fp;

    if (pass >= 0) {
        snprintf(filename2,sizeof(filename2),"%s.pass%d",filename,pass);
        filename = filename2;
    }

    fp = fopen(filename,"w");
    printf("Saving new table to %s\n",filename);
    if (fp) {
        CkPrintTablesSub(fp);
        fclose(fp);
    }
    //CkPrintTablesSub(stdout);
}

//===========================================================================
// CkAdjustTableMap() - map of idx to table ptr
//===========================================================================
int CkAdjustTableMap(int **map)
{
    int idx = 0;
    int t,m,p;
    for (m=0; m<CK_TOKSHAPE_CNT; m++) {
        map[idx++] = &g_gap[0][m];
        map[idx++] = &g_gap[1][m];
    }
    for (t=0; t<6; t++) {
        for (m=0; m<CK_TOKSHAPE_CNT; m++) {
            for (p=0; p<CK_TOKSHAPE_CNT; p++) {
                if (t!= 0 || m!=p) {
                    map[idx++] = &g_tables[t][m][p];
                }
            }
        }
    }
    map[idx] = 0;
    return idx;
}

//===========================================================================
// CkAdjustTables() - adjust tables
//===========================================================================
//
// if val>0 set value
// if delta>0 multiply times old value
//
// return old value if successful
// return -1 if idx is too big
// return -2 if no change
//
int CkAdjustTables(int idx, int delta, int val)
{
    static int idxCnt = 0;
    static int *map[CK_TOKSHAPE_CNT*CK_TOKSHAPE_CNT*6 + CK_TOKSHAPE_CNT*2 + 5];
    int *ptr;
    int oldval;
    int newval;
    if (idx >= idxCnt) {
        if (idxCnt == 0) {
            idxCnt = CkAdjustTableMap(map);
        } else {
            return -1;
        }
    }
    ptr = map[idx];
    newval = oldval = *ptr;
    if (val >= 0) {
        newval = val;
    }
    newval += delta;
    if (newval < 0)   newval = 0;
    if (newval > 255) newval = 255;

    if (*ptr == newval) return -2;

#if 0
printf("Adjust idx=%-3d 0x%08x   %4d  -->  %4d\n",idx,(int)ptr,*ptr,newval);
#endif

    *ptr = newval;
    return oldval;
}

//===========================================================================
// CkInitMatrix() - initialize matrix
//===========================================================================
void CkInitMatrix(void)
{
    int m, p;
    for (p=0; p<MAX_PATTERN; p++) {
        g_mtx[0][p] = 0;
    }
    for (m=0; m<MAX_MOTION; m++) {
        g_mtx[m][0] = 0;
    }
}

//===========================================================================
// CkCalcMatch() - calculate score from matching pattern with motion
//===========================================================================
int CkCalcMatch(int mot, int pat)
{
    int p_shape = CK_TOKEN_SHAPE(pat);
    int p_ccw   = CK_TOKEN_CCW(pat);
    int p_quad  = CK_TOKEN_QUAD(pat);

    int m_shape = CK_TOKEN_SHAPE(mot);
    int m_ccw   = CK_TOKEN_CCW(mot);
    int m_quad  = CK_TOKEN_QUAD(mot);

    int table = 0;

    if (p_shape != CK_TOKSHAPE_PAUSE && m_shape != CK_TOKSHAPE_PAUSE) {
        table = (p_quad - m_quad) & 3;
        if (table == 3) table = 1;
        if (p_ccw ^ m_ccw) table += 3;
    }

#if SHOW_COVERAGE
    g_tables[table][m_shape][p_shape] += 1;
#endif

    return g_tables[table][m_shape][p_shape];
}

//===========================================================================
// CkCalcPatternGap() - calculate score from matching gap with motion
//===========================================================================
int CkCalcPatternGap(int mot)
{
    int m_shape = CK_TOKEN_SHAPE(mot);

#if SHOW_COVERAGE
    g_gap[0][m_shape] += 1;
#endif

    return g_gap[0][m_shape];
}

//===========================================================================
// CkCalcMotionGap() - calculate score from matching pattern with gap
//===========================================================================
int CkCalcMotionGap(int pat)
{
    int p_shape = CK_TOKEN_SHAPE(pat);

#if SHOW_COVERAGE
    g_gap[1][p_shape] += 1;
#endif

    return g_gap[1][p_shape];
}

//===========================================================================
// CkMotionScore() - get score for a motion/pattern pair
//===========================================================================
int CkMotionScore(CkPattern *pat, CkMotion *mot)
{
    int mlen = mot->len;
    int plen = pat->len;
    unsigned char *mtok = mot->tokens;
    unsigned char *ptok = pat->tokens;
    int m, p;
    int v_mp = 0;
    for (m=0; m<mlen; m++) {
        int mt = mtok[m];
        for (p=0; p<plen; p++) {
            int pt = ptok[p];
            int v_mg = CkCalcPatternGap(mt);
            int v_gp = CkCalcMotionGap(pt);
            v_mp = CkCalcMatch(mt,pt);
#if CK_DEBUG
printf("m=%3d  p=%3d  %4d  %4d  %4d  ",
m,p,v_mp,v_mg,v_gp);
#endif
            v_mp += g_mtx[m][p];
            v_mg += g_mtx[m+1][p];
            v_gp += g_mtx[m][p+1];
#if CK_DEBUG
printf("    %4d  %4d  %4d  ",
v_mp,v_mg,v_gp);
#endif
            v_mp = v_mp < v_mg ? v_mp : v_mg;
            v_mp = v_mp < v_gp ? v_mp : v_gp;
            g_mtx[m+1][p+1] = v_mp;

#if CK_DEBUG
printf("mtx=%4d\n",v_mp);
#endif
        }
    }
    return g_mtx[m][p];
}


//===========================================================================
// CkMotionMatch() - score motion against each pattern
//===========================================================================
double CkMotionMatch(CkMotion *mot, FILE *out)
{
    double suma = 0;
    double sumb = 0;
    double cnta = 0;
    double cntb = 0;
    int i;
    CkInitMatrix();

    for (i=0; i<sizeof(g_patlist)/sizeof(g_patlist[0]); i++) {
        CkMotion *pat = &g_patlist[i];
        int score;
        //int sval;

#if 1
        // only test against pattern spell
        if (pat->quality != 1.0) {
            continue;
        }
#endif

        score = CkMotionScore(pat, mot);
        if (out) {
            fprintf(out,"Score MOT=%-26s PAT=%-26s  %s%s score=%5d\n",
                mot->name,
                g_patlist[i].name,
                mot->group == g_patlist[i].group ? "*" : " ",
                mot == &g_patlist[i] ? "S" : " ",
                score);
        }

        if (pat->group == mot->group) {
            if (score > 100) {

                //
                // we want this score to be <100
                //
                score = score - 100;
                suma += ((double)mot->quality * (double)score * (double)score * (double)score);
                //suma += (score * score * pat->quality * mot->quality * 10.0);
            }
            cnta += 1.0;
        } else {
            if (score < 256) {

                //
                // we want this score to be >255
                //
                score = 256 - score;
                sumb += (double)score * (double)score * (double)score;
            }
            cntb += 1.0;
        }
        AC_ASSERT(suma >= 0);
        AC_ASSERT(sumb >= 0);
    }
    if (out) {
        fprintf(out," match:    suma=%15.8f / %d = %15.8f\n",suma,(int)cnta,suma/cnta);
        fprintf(out," mismatch: sumb=%15.8f / %d = %15.8f\n",sumb,(int)cntb,sumb/cntb);
    }
    return suma + sumb;
}

//===========================================================================
// CkTryAll() - try scoring each pattern as a motion
//===========================================================================
double CkTryAll(FILE *out)
{
    double sum = 0;
    int i;
    for (i=0; i<sizeof(g_patlist)/sizeof(g_patlist[0]); i++) {
        CkMotion *mot = &g_patlist[i];
        double val;
#if 0
        if (mot->quality != 1.0) {
            continue;
        }
#endif
#if CK_DEBUG
        printf("========================= %s\n", g_patlist[i].name);
#endif
        val = CkMotionMatch(mot,out);
        if (out) {
            fprintf(out,"============ %-26s    sum = %15.8f\n",mot->name, val);
        }
        sum += val;
    }
#if CK_DEBUG
    printf("FINAL SUM=%15.8f\n",sum);
#endif
    return sum;
}

//===========================================================================
// CkMinimize()
//===========================================================================
double CkMinimize(int delta)
{
    double sum0;
    int idx = 0;

#if SHOW_COVERAGE
    memset(g_tables,0,sizeof(g_tables));
    memset(g_gap,0,sizeof(g_gap));
#endif

    sum0 = CkTryAll(0);
    printf(" sum0 = %15.8f\n",sum0);

#if SHOW_COVERAGE
    printf("Number of times each entry was used:\n");
    CkPrintTablesSub(stdout);
    exit(0);
#endif

    for(idx=0; ;idx++) {
        double suma, sumb;
        int oldval = CkAdjustTables(idx, -delta, -1);
        if (oldval == -1) {
            return sum0;
        }
        if (oldval == -2) {
            continue;
        }
        suma = CkTryAll(0);
        CkAdjustTables(idx, delta, oldval);
        sumb = CkTryAll(0);

        printf(" idx=%d  sum0=%15.8f  suma=%15.8f  sumb=%15.8f \n",
            idx,
            sum0,
            suma,
            sumb);

        if (suma < sum0 && sumb < sum0) {
            printf("LOCAL MAX\n");

            if (suma < sumb) {
                CkAdjustTables(idx, -delta, oldval);
                sum0 = suma;
            } else {
                sum0 = sumb;
            }
            CkPrintTables(-1);

        } else if (suma < sum0) {
            CkAdjustTables(idx, -delta, oldval);
            sum0 = suma;
            CkPrintTables(-1);
        } else if (sumb < sum0) {
            sum0 = sumb;
            CkPrintTables(-1);
        } else {
            CkAdjustTables(idx, 0, oldval);
        }
    }
}

//===========================================================================
// CkShowResult
//===========================================================================
void CkShowResult(int pass, double sum)
{
    FILE *fp;
    char *result_filename = "check_result.txt";

    fp = fopen(result_filename,pass ? "a" : "w");
    if (!fp) {
        printf("could not open file\n");
        return;
    }


    fprintf(fp,"============== Pass[%d]  sum=%15.8f\n",pass,sum);

    CkTryAll(fp);

    fclose(fp);

    printf("Wrote %s\n",result_filename);
}

//===========================================================================
// main()
//===========================================================================
int main(int argc, char *argv[])
{
    char *log_filename = "check_log.txt";
    int pass = 0;
    int delta = 1;
    int dcnt=3;
    double sum0 = 0;
    int i;

    g_log = fopen(log_filename,"w");
    AC_ASSERT(g_log);

    CkInitTables();

    CkPrintTables(-1);


    fprintf(g_log,"============== STARTING LOG\n");
    
    for (i=0; i<sizeof(g_patlist)/sizeof(g_patlist[0]); i++) {
        CkMotion *mot = &g_patlist[i];
        fprintf(g_log,"motion %-27s l=%-3d grp=%-2d qual=%5.3f\n",
            mot->name,
            mot->len,
            mot->group,
            mot->quality);
    }
    fflush(g_log);

    sum0 = CkTryAll(0);

    for(pass=0; ; pass++) {
        double sum;
        fprintf(g_log,"============== START Pass[%d]  sum0=%15.8f   delta=%3d\n",pass,sum0,delta);
        CkShowResult(pass,sum0);
        CkPrintTables(pass);
        sum = CkMinimize(delta);
        if (sum == sum0) {
            delta--;
            if (delta == 0) {
                if (dcnt == 0) break;
                dcnt--;
                delta = 100;        // retry to find different local minima
            }
        }
        sum0 = sum;
        printf("============== END   Pass[%d]  sum0=%15.8f   delta=%3d\n",pass,sum0,delta);
        fprintf(g_log,"============== END   Pass[%d]  sum0=%15.8f   delta=%3d\n",pass,sum0,delta);
        fflush(g_log);
    }

    printf("No more changes detected after at pass %d  score=%15.8f\n",pass,sum0);

    CkShowResult(pass,sum0);
    CkPrintTables(pass);

    return 0;
}

This file Copyright (C) 2006 by Nathan (Acorn) Pooley
Go to TOP Wand page
Go to Acorn's personal webpage
Go to Hogwarts website: www.gotohogwarts.com
Snout: www.snout.org/game
Gadgets of Justice Unlimited
Snout GC (Wiki)
Snout Wiki
File created by do_doc at Wed May 30 03:25:17 PDT 2007