예제 #1
0
파일: MainForm.cs 프로젝트: jayvan/TPwn
        int scoreBoardTwo(DropResult result)
        {
            int score = result.clears * 4;
            int height = 0;
            for (int y = 0; y < BOARD_HEIGHT; y++) {
                for (int x = 0 ; x < BOARD_WIDTH; x++) {
                    if (result.grid[x,y] == 2) {
                        if (old(result.grid, x - 1, y)) score++;
                        if (old(result.grid, x + 1, y)) score++;
                        if (old(result.grid, x, y - 1)) score++;
                        if (old(result.grid, x, y + 1)) score++;
                        if (!filled(result.grid, x, y - 1)) score -= 5;;
                        height = y;
                    }
                }
            }

            return score - height;
        }
예제 #2
0
파일: MainForm.cs 프로젝트: jayvan/TPwn
        DropResult dropPiece(Orientation piece, int column)
        {
            DropResult dr = new DropResult();

            int[,] grid = (int[,])board.Clone();
            int depth = 3;
            bool collision = false;

            while(!collision) {
                depth++;
                for (int y = 0; y < 4; y++) {
                    for (int x = 0; x < piece.width; x++) {
                        if (BOARD_HEIGHT - depth + y < 0 || (grid[column + x, BOARD_HEIGHT - depth + y] != 0 && piece.blocks[x, y])) {
                            collision = true;
                            break;
                        }
                    }
                    if (collision) break;
                }
            }

            depth--; //Return to last acceptable depth

            //TODO: FIX THIS FRIGGEN EXCEPTION!!!
            try {
                // Move the piece into the board
                for (int y = 0; y < 4; y++) {
                    for (int x = 0; x < piece.width; x++) {
                        if (piece.blocks[x, y])
                            grid[column + x, BOARD_HEIGHT - depth + y] = 2;
                    }
                }
            } catch {
                dr.grid = new int[BOARD_WIDTH, BOARD_HEIGHT];
                dr.clears = -100;
                return dr;
            }

            for (int y = 0; y < 4; y++) {
                if (BOARD_HEIGHT - depth + 3 - y >= BOARD_HEIGHT) continue;
                bool clear = true;
                    for (int x = 0; x < BOARD_WIDTH; x++) {

                        if (grid[x, BOARD_HEIGHT - depth + 3 - y] == 0) {
                            clear = false;
                            break;
                        }
                    }

                    if (clear) {
                        dr.clears++;
                        clearLine(grid, BOARD_HEIGHT - depth + 3 - y);
                    }
                }
            dr.grid = grid;
            return dr;
        }