#include <stdio.h> #include "globals.h" #include "graphics.h" #include "trie.h" extern char *currentmove; eval(char fill[17][17], int trans[17][17], unsigned int r, unsigned int c) { register int c1, xscore = 0, fscore = 0, factor = 1, count = 0; register char ch, *moveptr=currentmove; register int l, t; if (!*moveptr) return; for (c1 = c - 1; ; c1--) if (ch=fill[r][c1]) fscore += lettervalue[ch]; else if (ch = *moveptr--) { l = lettermult[r][c1] * lettervalue[ch]; t = trans[r][c1]; if (t >= 0) xscore += (t + l) * wordmult[r][c1]; fscore += l; factor *= wordmult[r][c1]; count++; } else break; xscore += fscore * factor + 50 * (count == 7); fscore = xscore; if (fscore > bestmove.value) { for(moveptr=currentmove, t=0; *moveptr; moveptr--, t++) bestmove.word[t] = *moveptr | NEWBIT; bestmove.word[t] = 0; bestmove.r = r; bestmove.c = c; bestmove.fill = fill; bestmove.score = xscore; bestmove.value = fscore; } }