Wednesday, April 14, 2010

[scxfghdg] Packing squares in rectangles

Given a set of squares of various sizes, pack them into the smallest rectangle of a given aspect ratio.

Inspired by an interface for Advanced Chess.  Every possible move 1-ply from a given position is shown as a board position, with moves the computer evaluates highly shown larger.

Two simple layout algorithms.  Sort the squares by descending size. Place each square as far up as possible, and if a tie, as far left as possible.  Another algorithm: alternate up-left and down-right. 

No comments :