2 ms·
Oh? How do you traverse vertical and horizontal structures that are wider than one block? If you have vertical lists, following a horizontal row wild involve lo
by TuringTest 13y ago
Oh? How do you traverse vertical and horizontal structures that are wider than one block? If you have vertical lists, following a horizontal row wild involve lots of find-nth-position calls, which I wouldn't call "natural"
- rrradical 13y agoThe basic data structure is this ((0 (73 84 92)) (1 (17 95 31))) Where the 2 digit numbers are id numbers for the blocks. The single digit number to left of each row is the horizontal offset. So, shifting a row, the most elementary operation in the game, just requires incrementing the offset. Vertical shifts are done with a 90 degree rotation operation, then a horizontal shift, then a -90 degree rotation. Sometimes traversing the lists is necessary, but the most common operations are fast, and then rest are fast enough. The limiting factor in performance is definitely rendering, not the game logic.