These series of scripts analyze a game board image from Block Blast, detects which grid cells are filled or empty, classifies new shapes from the image, and determines the placement of those shapes on the grid using a basic algorithm.
- Grid Detection: Identifies the current 8x8 game grid state from an input image.
- Shape Classification: Splits and classifies shapes from the game UI using template matching.
- Optimal Placement: Computes the best placement for classified shapes and updates the grid.
- Line Clearing: Clears fully populated rows and columns after shape placement.
- Batch Processing: Processes and saves cropped shape images for training or visualization.
- Place your input image (e.g.,
Image.jpg) in the project root. - Ensure the
Block Blast Cropped Maskedfolder contains template images of shapes named by their array representation (e.g.,[1,1]_[mask].png).
Run the main script:
python blockblast.pyThis will:
- Detect the 8x8 grid (
blockblast_detect.get_grid). - Classify shapes from the UI (
blockblast_classify.classify). - Determine optimal placements and clear lines.
- Print the final grid state and placement grid.