diff options
-rw-r--r-- | sirtet.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -158,6 +158,11 @@ void sirtet(int H, int W, int P) { pc_idx = (pc_idx + P - 1) % P; if (hand[pc_idx] != NULL) { pc = hand[pc_idx]; + // move piece inside boundary if necessary + if (row + (pc->h) > H) + row = H - pc->h; + if (col + (pc->w) > W) + col = W - pc->w; break; } } @@ -168,6 +173,10 @@ void sirtet(int H, int W, int P) { pc_idx = (pc_idx + 1) % P; if (hand[pc_idx] != NULL) { pc = hand[pc_idx]; + if (row + (pc->h) > H) + row = H - pc->h; + if (col + (pc->w) > W) + col = W - pc->w; break; } } |