All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Games
Disarray - Anarchy At the White Court (Posted on 2007-10-19) Difficulty: 3 of 5
Turmoil reigns at the Court of the White King; all pieces oppose one another.

The King and his entourage (The queen, king, and the 3 pieces to his right) can be spread inside the 5 x 5 domain from [Q1 - KR5] with only the King on the first rank, where he is at home.

During this state of upheaval no piece threatens another.

Within a smaller domain than the given 5x5 space, place the pieces such that the Queen can force "mate" in just one move while remaining free from aggression herself, though possibly threatening others. (I note two different arrangements)

Note:
1. Other than the "domestic aggression" all chess rules still apply.
2. No dimension of the smaller domain is greater than 5.

Bonus:
1. How many cases of the White Court's disarray can you find? I have slightly over 30.

2. Offer one where Q and KB files are vacant.

See The Solution Submitted by brianjn    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution re(3): Solution -- another correction to my program | Comment 17 of 18 |
(In reply to re(2): Solution by Dej Mar)

DECLARE FUNCTION qAttack! (qRow!, qCol!, kRow!, kCol!, isQMove!)
DECLARE FUNCTION checkmate! ()
DIM SHARED br, bc, nr, nc, rr, rc, kr, kc, qr, qc, ht, wd
ht = 5: wd = 5
CLS
'oPEN "anarchy2.txt" FOR APPEND AS #2
REDIM SHARED bd$(ht, wd)
kr = ht: kc = 2
bd$(ht, kc) = "k"
FOR br = 1 TO ht - 1
 FOR bc = 1 TO wd
   IF (br < kr - 1 OR ABS(bc - kc) > 1) AND ABS(br - kr) <> ABS(bc - kc) AND (ABS(br - kr) + ABS(bc - kc)) MOD 2 = 1 THEN
     bd$(br, bc) = "b"
     
FOR nr = 1 TO ht - 1
 FOR nc = 1 TO wd
   IF (nr < kr - 1 OR ABS(nc - kc) > 1) AND ABS(br - nr) <> ABS(bc - nc) THEN
    nkDiffR = ABS(kr - nr): nkDiffC = ABS(kc - nc)
    nbDiffR = ABS(br - nr): nbDiffC = ABS(bc - nc)
    IF (nkDiffR <> 2 OR nkDiffC <> 1) AND (nkDiffR <> 1 OR nkDiffC <> 2) AND (nbDiffR <> 2 OR nbDiffC <> 1) AND (nbDiffR <> 1 OR nbDiffC <> 2) THEN
     bd$(nr, nc) = "n"
    
FOR rr = 1 TO ht - 1
 FOR rc = 1 TO wd
   IF (rr < kr - 1 OR ABS(rc - kc) > 1) AND ABS(br - rr) <> ABS(bc - rc) THEN
    IF rr <> kr AND rc <> kc AND rr <> nr AND rc <> nc AND rr <> br AND rc <> bc THEN
      nrDiffR = ABS(rr - nr): nrDiffC = ABS(rc - nc)
      IF (nrDiffR <> 2 OR nrDiffC <> 1) AND (nrDiffR <> 1 OR nrDiffC <> 2) THEN
           bd$(rr, rc) = "r"
         
FOR qr = 1 TO ht - 1
 FOR qc = 1 TO wd
   IF (qr < kr - 1 OR ABS(qc - kc) > 1) THEN
    IF qr <> kr AND qr <> rr AND qr <> br AND qr <> nr AND qc <> kc AND qc <> rc AND qc <> bc AND qc <> nc THEN
     IF ABS(qr - kr) <> ABS(qc - kc) AND ABS(qr - br) <> ABS(qc - bc) AND ABS(qr - nr) <> ABS(qc - nc) AND ABS(qr - rr) <> ABS(qc - rc) THEN
      nqDiffR = ABS(qr - nr): nqDiffC = ABS(qc - nc)
      IF (nqDiffR <> 2 OR nqDiffC <> 1) AND (nqDiffR <> 1 OR nqDiffC <> 2) THEN
           bd$(qr, qc) = "q"

 

good2 = checkmate

'IF good2 OR ABS(rc - kc) <> 1 AND ABS(qc - kc) <> 1 AND ABS(bc - kc) <> 1 AND ABS(nc - kc) <> 1 THEN
  r0 = (ct \ 8) * 6 + 1
  c0 = (ct MOD 8) * 10 + 1
  SELECT CASE (ct \ 8) MOD 2
     CASE 0
      COLOR 14
     CASE 1
      COLOR 7
  END SELECT

  FOR r = 1 TO ht
  FOR c = 1 TO wd
   LOCATE r0 + r, c0 + c
   IF bd$(r, c) > "" THEN
    PRINT bd$(r, c);
    'IF bd$(r, c) = "Q" THEN bd$(r, c) = ""
   ELSE
    PRINT ".";
   END IF
  NEXT
  IF r = 1 THEN
    IF ABS(rc - kc) <> 1 AND ABS(qc - kc) <> 1 AND ABS(bc - kc) <> 1 AND ABS(nc - kc) <> 1 THEN
      PRINT "*";
      IF good2 THEN PRINT "!";
    ELSE
      IF good2 THEN PRINT "!";
    END IF
  END IF
  'PRINT
  NEXT
  'PRINT
  ct = ct + 1
'END IF

FOR rw = 1 TO ht
 FOR cl = 1 TO wd
  IF bd$(rw, cl) = "" THEN
   ph$(rw) = ph$(rw) + "."
  ELSE
   ph$(rw) = ph$(rw) + bd$(rw, cl)
  END IF
 NEXT
 IF rw = 1 THEN
  IF ABS(rc - kc) <> 1 AND ABS(qc - kc) <> 1 AND ABS(bc - kc) <> 1 AND ABS(nc - kc) <> 1 THEN
   ph$(rw) = ph$(rw) + "*"
  ELSE
   ph$(rw) = ph$(rw) + " "
  END IF
  IF good2 THEN
   ph$(rw) = ph$(rw) + "< "
  ELSE
   ph$(rw) = ph$(rw) + "  "
  END IF
 ELSE
  ph$(rw) = ph$(rw) + "   "
 END IF
NEXT
rwCt = rwCt + 1
IF rwCt = 8 THEN
  FOR rw = 1 TO ht
'    PRINT #2, ph$(rw)
    ph$(rw) = ""
  NEXT
'  PRINT #2, : PRINT #2,
  rwCt = 0
END IF

 

fff = 0
FOR r = 1 TO ht: FOR c = 1 TO wd
 IF bd$(r, c) = "Q" THEN
  bd$(r, c) = ""
 END IF
NEXT: NEXT
ct2 = ct2 + 1


           bd$(qr, qc) = ""
      END IF
     END IF
    END IF
   END IF
 NEXT qc
NEXT qr

           bd$(rr, rc) = ""
      END IF
    END IF
   END IF
 NEXT rc
NEXT rr

     bd$(nr, nc) = ""
    END IF
   END IF
 NEXT nc
NEXT nr

     bd$(br, bc) = ""
   END IF
 NEXT bc
NEXT br

PRINT ct2

IF rwCt > 0 THEN
  FOR rw = 1 TO ht
'    PRINT #2, ph$(rw)
    ph$(rw) = ""
  NEXT
'  PRINT #2, : PRINT #2,
  rwCt = 0
END IF

CLOSE

FUNCTION checkmate
cmate = 0
FOR dr = -1 TO 1
FOR dc = -1 TO 1
 IF dr <> 0 OR dc <> 0 THEN
  q2r = qr + dr: q2c = qc + dc
  DO WHILE q2r > 0 AND q2r <= ht AND q2c > 0 AND q2c <= wd
   IF (q2r < kr - 1 OR ABS(q2c - kc) > 1) THEN
    IF qAttack(q2r, q2c, kr, kc, 1) THEN
     IF q2r <> rr AND q2c <> rc AND ABS(q2r - br) <> ABS(q2c - bc) THEN
      nqDiffR = ABS(q2r - nr): nqDiffC = ABS(q2c - nc)
      IF (nqDiffR <> 2 OR nqDiffC <> 1) AND (nqDiffR <> 1 OR nqDiffC <> 2) THEN

good = 1
FOR kdr = -1 TO 1
FOR kdc = -1 TO 1
 hid = 1
 k2r = kr + kdr
 k2c = kc + kdc
 IF k2r <= ht AND k2r > 0 AND k2c <= wd AND k2c > 0 THEN
   IF qAttack(q2r, q2c, k2r, k2c, 0) THEN hid = 0
   ' again, this doesn't check for a blocked queen, so may get false checkmate
   nkDiffR = ABS(k2r - nr): nkDiffC = ABS(k2c - nc)
   IF (nkDiffR = 2 AND nkDiffC = 1) OR (nkDiffR = 1 AND nkDiffC = 2) THEN
     hid = 0
   END IF
   IF k2r = rr OR k2c = rc OR ABS(k2c - bc) = ABS(k2r - br) THEN hid = 0
 
   IF hid THEN good = 0: EXIT FOR
 END IF
NEXT
IF good = 0 THEN EXIT FOR
NEXT
IF good THEN
 bd$(q2r, q2c) = "Q"
 cmate = 1
END IF

      END IF
     END IF
    END IF
   END IF
   q2r = q2r + dr: q2c = q2c + dc
  LOOP
 END IF
NEXT dc
NEXT dr
 checkmate = cmate
END FUNCTION

FUNCTION qAttack (qRow, qCol, kRow, kCol, isQMove)
  IF qRow = kRow OR qCol = kCol OR ABS(qRow - kRow) = ABS(qCol - kCol) THEN
    qa = 1
  ELSE
    qAttack = 0: EXIT FUNCTION
  END IF

  dr = SGN(kRow - qRow): dc = SGN(kCol - qCol)
  r = qRow + dr: c = qCol + dc
  DO UNTIL r = kRow AND c = kCol
   IF bd$(r, c) > "" AND bd$(r, c) <> "k" AND bd$(r, c) <> "Q" THEN qAttack = 0: EXIT FUNCTION
   IF isQMove THEN
    IF ABS(br - r) = ABS(bc - c) THEN qAttack = 0: EXIT FUNCTION
    IF rr = r OR rc = c THEN qAttack = 0: EXIT FUNCTION
    nRowDiff = ABS(nr - r): nColDiff = ABS(nc - c)
    IF nRowDiff = 1 AND nColDiff = 2 OR nRowDiff = 2 AND nColDiff = 1 THEN
      qAttack = 0: EXIT FUNCTION
    END IF
   END IF
   r = r + dr: c = c + dc
  LOOP

  qAttack = qa
END FUNCTION

Now produces

 
 
bn...     b.n..     .nb..     .nb..     ..bn.     ..bn.!    ..b.n     ..b.n
..r..     ...r.     r....     ....r     r....     q....     r....     q....
....q     .....     .....     .....     .....     .....     .....     .....
.....     ....q     ...q.     ...q.     ....q     ....r     ...q.     ...r.
.k...     .k...     .k...     .k...     .k...     .k.Q.     .k...     .k...
..b..     .n..b!    .n..b     ..n.b!    ...nb     ....b     ....b     ....b
q....     r....     ..r..     .....     ..r..     q....     ..r..     q....
...r.     .....     .....     r....     q....     ....n     q....     ...r.
....n     ...q.     ...q.     ...q.     .....     ...r.     ....n     ....n
.k...     .k.Q.     .k...     .k.Q.     .k...     .k...     .k...     .k...
...r.     ...r.     ....q     ...q.     ...q.!    ...r.*    ...n.!    ...n.
nb...     nb...     nb...     nb...     nb...     .b...     ...b.     ...b.
....q     .....     ...r.     ....r     .....     .n...     r....     q....
.....     ....q     .....     .....     ....r     ....q     ....q     ....r
.k...     .k...     .k...     .k...     .k.Q.     .k...     .k.Q.     .k...
r....!    .....!    q....     n....     n....     ...r.     ....r     ....q
.n.b.     .n.b.     ...b.     ...r.     ...q.     n....     n....     n....
.....     r....     ...n.     b....     b....     b....     b....     b....
....q     ....q     ....r     ....q     ....r     ....q     ...q.     ...r.
.k.QQ     .k.QQ     .k...     .k...     .k...     .k...     .k...     .k...
...q.     ...r.     ....q     ...r.     .....!    .....     q....     ...r.
n....     .....     ..r..     .....     r....     q....     ..r..     q....
b....     bn...     bn...     .nb..     .nbQ.     ..bn.     ...nb     ....b
....r     ....q     .....     ....q     ....q     ....r     .....     ....n
.k...     .k...     .k...     .k...     .k...     .k...     .k...     .k...
...q.!    q....     ...n.     ...n.     ....r     ..r..     ..q..     .....
r....     ..r..     ..r..     ....r     ...n.     q....     r....     ..r..
.Q..b     ....b     q....     q....     q....     .....     .....     q....
....n     ....n     ...b.     ...b.     ...b.     ...bn     ...bn     ...bn
.k...     .k...     .k...     .k...     .k...     .k...     .k...     .k... 48

showing all the valid queen positions for checkmate.


  Posted by Charlie on 2007-10-22 16:50:17
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information