float CheckMetrics(float piece, float orgx, float orgy, float rot);
void ClearPiece(float piece, float orgx, float orgy, float rot);
void CementPiece(float piece, float orgx, float orgy, float rot);
float CheckMetrics(float piece, float orgx, float orgy, float rot);
void ClearPiece(float piece, float orgx, float orgy, float rot);
void CementPiece(float piece, float orgx, float orgy, float rot);
float BastetSearch(float buf, float pc, float x, float y, float rot, float move_bias)
// returns best score, or -1 if position is impossible
{
float BastetSearch(float buf, float pc, float x, float y, float rot, float move_bias)
// returns best score, or -1 if position is impossible
{
bufstr_set(buf, b, "0"); // in case we READ that, not that bad - we already got that value in another branch then anyway
bufstr_set(buf, b, "0"); // in case we READ that, not that bad - we already got that value in another branch then anyway
if(CheckMetrics(pc, x, y, rot))
if(CheckMetrics(pc, x, y, rot))
s = BastetSearch(buf, pc, x+1, y, rot, move_bias - 1); if(s > sm) sm = s;
s = BastetSearch(buf, pc, x, y, rot+1, move_bias - 1); if(s > sm) sm = s;
s = BastetSearch(buf, pc, x, y, rot-1, move_bias - 1); if(s > sm) sm = s;
s = BastetSearch(buf, pc, x+1, y, rot, move_bias - 1); if(s > sm) sm = s;
s = BastetSearch(buf, pc, x, y, rot+1, move_bias - 1); if(s > sm) sm = s;
s = BastetSearch(buf, pc, x, y, rot-1, move_bias - 1); if(s > sm) sm = s;
- s = BastetSearch(buf, pc, x, y+1, rot, move_bias + 2); if(s > sm) sm = s;
+
+#ifndef ALWAYS_CHECK_METRICS
+ if(CheckMetrics(pc, x, y+1, rot))
+ {
+#endif
+ s = BastetSearch(buf, pc, x, y+1, rot, move_bias + 2); if(s > sm) sm = s;
+#ifndef ALWAYS_CHECK_METRICS
+ }
+ else
+ s = -1;
+#endif
if(s < 0)
{
//print(sprintf("MAY CEMENT AT: %d %d %d\n", x, y, rot));
// moving down did not work - that means we can fixate the block here
if(s < 0)
{
//print(sprintf("MAY CEMENT AT: %d %d %d\n", x, y, rot));
// moving down did not work - that means we can fixate the block here
CementPiece(pc, x, y, rot);
s = BastetEvaluate();
ClearPiece(pc, x, y, rot);
CementPiece(pc, x, y, rot);
s = BastetEvaluate();
ClearPiece(pc, x, y, rot);
var float t1 = gettime(GETTIME_HIRES);
b = buf_create(); bastet_piece[0] = 1; bastet_score[0] = BastetSearch(b, 1, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[0]; buf_del(b);
var float t1 = gettime(GETTIME_HIRES);
b = buf_create(); bastet_piece[0] = 1; bastet_score[0] = BastetSearch(b, 1, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[0]; buf_del(b);
b = buf_create(); bastet_piece[6] = 7; bastet_score[6] = BastetSearch(b, 7, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[6]; buf_del(b);
var float t2 = gettime(GETTIME_HIRES);
b = buf_create(); bastet_piece[6] = 7; bastet_score[6] = BastetSearch(b, 7, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[6]; buf_del(b);
var float t2 = gettime(GETTIME_HIRES);
{
print(sprintf("piece %s value = %d\n", substring("OJLIZST", bastet_piece[i]-1, 1), bastet_score[i]));
}
{
print(sprintf("piece %s value = %d\n", substring("OJLIZST", bastet_piece[i]-1, 1), bastet_score[i]));
}