void TetrisEmulator::getFeature(double *f, TetrisBoard b) { // printBoard(b); int heights[10] = {}; int max = -1; for (int x = 0; x < T_WIDTH; ++x) { for (int y = 0; y < T_HEIGHT; ++y) { if (b[x][y]) { int h = T_HEIGHT - y; if (h > max) max = h; heights[x] = h; break; } } } f[0] = max; f[1] = getHoleCount(b); for (int i = 2; i < 12; i++) { f[i] = heights[i - 2]; } for (int i = 12; i < 21; i++) { f[i] = heights[i - 11] - heights[i - 12]; } int i; i = 1; return; }
void TetrisEmulator::showFeatures(TetrisBoard b) { double feature[FEATURE_COUNT] = { lastLandingHeight, (double)lastClearLines, (double)getRowTransition(b), (double)getColTransition(b), (double)getHoleCount(b), (double)getHoleDepth(b), (double)getCumulativeWells(b), }; for (int i = 0; i < FEATURE_COUNT; ++i) { std::cout << feature[i] << '\n'; } }
QList<double> Skeleton::vectorization(int type) { QList<double> result; int count = getDim(type); int endCount = getEndCount(type); int junctionCount = getJunctionCount(type); int holeCount = getHoleCount(type); int massCenterCount = getMassCenterCount(type); int totalCount = getTotalCount(type); int partCount = getPartCount(type); int index = 0; for (int i = 0; i < count; i++){ result.push_back(0.0001); } for (int i = 0; i < listLineEnds.size() && i < endCount; i++){ result[index] = (listLineEnds[i].x); index++; result[index] = (listLineEnds[i].y); index++; } for (int i = 0; i < listJunctions.size() && i < junctionCount; i++){ result[index] = (listJunctions[i].x); index++; result[index] = (listJunctions[i].y); index++; } for (int i = 0; i < listHoles.size() && i < holeCount; i++){ result[index] = (listHoles[i].x); index++; result[index] = (listHoles[i].y); index++; } for (int i = 0; i < massCenterCount; i++){ result[index] = (massCenter.x); index++; result[index] = (massCenter.y); index++; } for (int i = 0; i < totalCount; i++){ result[index] = (total); index++; } for (int i = 0; i < partCount; i++){ for (int x = 0; x < PART_X; x++){ for (int y = 0; y < PART_Y; y++){ result[index] = parts[x][y]; index++; } } } return result; }