summaryrefslogtreecommitdiff
path: root/sirtet.c
diff options
context:
space:
mode:
Diffstat (limited to 'sirtet.c')
-rw-r--r--sirtet.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sirtet.c b/sirtet.c
index 2ec0b19..aa37feb 100644
--- a/sirtet.c
+++ b/sirtet.c
@@ -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;
}
}