// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Five-by-five knight tour // Not compiled or tested in-world // Setup: Enter coordinates a1 through e5. Start a1; no square may be revisited. Owner-touch starts a fresh game; type reset to restart. Input times out after 90 seconds. // Stop / restore: Let the input timeout expire or remove the script. No world geometry, avatar or inventory is changed. // Notes: Original compact educational game. Owner-only local input; no scores or avatar identities are sent to a service. Output is short ASCII text. Not a competition authority. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer channel; integer handle; integer x; integer y; list visited; close() { if(handle)llListenRemove(handle); handle=0; llSetTimerEvent(0.0); } start() { x=0; y=0; visited=[0]; } string board() { return "Current "+llGetSubString("abcde",x,x)+(string)(y+1)+" | visited "+(string)llGetListLength(visited)+"/25"; } show() { llOwnerSay(board()); if(!handle) { channel=-1000-(integer)llFrand(1000000.0); handle=llListen(channel,"",llGetOwner(),""); } llTextBox(llGetOwner(),"Enter coordinates a1 through e5. Start a1; no square may be revisited. Type reset to restart.",channel); llSetTimerEvent(90.0); } default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; close(); start(); show(); } listen(integer incomingChannel,string name,key id,string input) { if(!handle||incomingChannel!=channel||id!=llGetOwner())return; input=llToLower(llStringTrim(input,STRING_TRIM)); if(input=="reset")start(); else { if(llStringLength(input)==2) { integer nx=llSubStringIndex("abcde",llGetSubString(input,0,0)); integer ny=llSubStringIndex("12345",llGetSubString(input,1,1)); integer dx=llAbs(nx-x); integer dy=llAbs(ny-y); integer square=ny*5+nx; if(nx>=0&&ny>=0&&((dx==1&&dy==2)||(dx==2&&dy==1))&&llListFindList(visited,[square])<0) { x=nx; y=ny; visited+=[square]; if(llGetListLength(visited)==25)llOwnerSay("Tour complete!"); } else llOwnerSay("Not a fresh knight move."); } } show(); } timer() { close(); } }