/*************************************************************************** begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include "cfg.h" #include "field.moc" Field::Field(TQWidget* parent, const char* name) : TQWidget( parent, name ) { clearField(); } Field::~Field() { } void Field::clearField() { for(int y=0; y=0) && (x=0) && (y= NUMCELLSW) || (iy >= NUMCELLSH)) continue; int b = field[iy][ix].getColor(); //printf("[%d,%d]%d", ix,iy,b); if (b == NOBALL) { run++; empty++; } else if (b == current_color) { run++; score++; empty = 0; } else { run = empty+1; score = 1; current_color = b; empty = 0; } if (run > lpr) { lpr = run; lprscore = score; } } if (lpr < 5) lprscore = -10; else lprscore = lprscore*lprscore; // printf("= %d\n", lprscore); return lprscore; } int Field::calcPosScore(int x, int y, int whatIf) { int score = -10; int color = field[y][x].getColor(); field[y][x].setColor(whatIf); score = TQMAX(score, calcRun(x, y-4, 0, 1)); score = TQMAX(score, calcRun(x-4, y-4, 1, 1)); score = TQMAX(score, calcRun(x-4, y, 1, 0)); score = TQMAX(score, calcRun(x-4, y+4, 1, -1)); field[y][x].setColor(color); return score; }