Challenge 10 Knight's Maypole Dance PLEASE DO NOT RESPOND UNTIL 4/1/2012 12 am EST
A conventional chess board has 8 rows and 8 colums of red and black squares in an alternating pattern. ]a=:8 8$'.' ........ ........ ........ ........ ........ ........ ........ ........ ]a1=: 'W' (<4 3) } a ........ ........ ........ ........ ...W.... ........ ........ ........ ]'x' (2 2;2 4;3 1;3 5;5 1;5 5;6 2;6 4)}a1 ........ ........ ..x.x... .x...x.. ...W.... .x...x.. ..x.x... ........ If the "White Knight" is in the position above, it has 8 possible moves as shown by an x . ]b=: }."2 (}."1) 9 9$'o.' o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o ]b1=:'W' (<1 1)}b o.o.o.o. .W.o.o.o o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o ]b2=:'B' (<6 6)}b1 o.o.o.o. .W.o.o.o o.o.o.o. .o.o.o.o o.o.o.o. .o.o.o.o o.o.o.B. .o.o.o.o For this challenge, a Black Knight and a White Knight are in the starting positions shown above. Your challenge is to design a way to randomly choose the Knight which will begin. 1. Each Knight has 4 possible positions to move at the start. 2. It must always move based on a random selection of all possible moves from its current position. 3. Once it moves, it is obviously no longer where it was. 4. The Black and White Knights must wander around the board in this aimless fashion until one "captures" the other and is thus the winner. 5. Announce the winner and the number of moves taken. 6. It would be Knice to also have a trace of their movements. I'm finding that the fewer restraints on how a program is approached leads to the most interesting results. 'til May Day. Linda ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm