Witchess puzzle helper

heeheehee

Developer
Staff member
Note: this does not solve your puzzles for you. If you want to take all the fun out of puzzle-solving, go download this other script.

I casually mentioned that I had rewritten some of the javascript / css for witchess.php via an ASH script to help with the solving process.

The main things this adds are
  • Color regions, with a separation of at least two between identically colored regions.
  • Count region size (and constraints) as a tooltip.
  • Allow for illegal moves (i.e. moving over a gap) via arrow keys, and denote when this is done (corresponding segments are colored red).
  • Add a third state when clicking on lines (for visually separating regions, or marking segments as unusable, or whatever else you want).
  • Visually indicate when a node has too many or too few adjacent active segments (orange if too many, pale blue if too few).
  • Fix a visual bug with the reset button.

This does not (yet?) handle marking oversatisfied / undersatisfied edge constraints or cycle detection. I can't think of other features I'd really want in this (maybe a confirm on reset?), so now seems like a reasonable time to share.

To use: put witchess.ash in your $MAFIAROOT/relay folder. Then go solve a witchess puzzle.

Requires r16800 for multi-line string support; otherwise, you can replace \\\n with \n globally, and it should work exactly the same.
 

Attachments

  • witchess.png
    witchess.png
    20.8 KB · Views: 137
  • witchess.ash
    8.3 KB · Views: 81
Last edited:

Veracity

Developer
Staff member
I stuck this in my relay folder and went to solve a witchess puzzle and saw nothing. My DEBUG log has this:

Code:
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1181&option=3
Retrieved: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1181&option=3
Encounter: Witchess Puzzles
Finished relay script: choice.ash
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1183&option=2
Retrieved: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1183&option=2
Field: location = [witchess.php]
Requesting: http://www.kingdomofloathing.com/witchess.php
Retrieved: http://www.kingdomofloathing.com/witchess.php
Finished relay script: choice.ash
Looks like it doesn't fire if your relay script calls visit_url and it follows a redirect to a different url (which happens to have a relay script of its own).

We have a recent discussion of this, somewhere, talking about reverting the change that made visit_url() automatically follow redirects.

Seems like I am being directly affected by this, myself, now.

Edit: I suppose another possibility would be to call a relay script - if present - to massage the result of the redirect, and pass that back to the enclosing relay script. I.e., when we detect a redirect, look for a relay script and let IT do visit_url() to fetch the page and manipulate it.
 
Last edited:

Veracity

Developer
Staff member
Yeah, I have a build to try that hack ready, once we come back after rollover. I suspect it will work, but it will not solve the issue of the browser being told that the result of the redirected request is the result of the request that IT made.

If it works, I'll submit it it and we can continue thinking about the bigger issue.
 

heeheehee

Developer
Staff member
Yeah, the problem here is the presence of a choice.ash override; for this reason I've temporarily disabled mine. Too many weird things to justify the info it adds.

Chaining relay scripts sounds... potentially messy? I still think I'd prefer a solution that returns an empty page to the relay script, then follows the redirect, calling any relevant relay scripts along the way.

- There's certainly a use case for a relay script that doesn't always invoke visit_url (e.g. custom adventure.php warning pages -- I had one of those at one point; dunno what happened to it).
 

Veracity

Developer
Staff member
Yeah, OK, it still doesn't work.

Code:
Encounter: Witchess Puzzles
invalid 'since' format (witchess.ash, line 1)

Change line 1 from

Code:
since 16800;

to

Code:
since r16800;

and now it executes.

Code:
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?forceoption=0
Retrieved: http://www.kingdomofloathing.com/choice.php?forceoption=0
Starting ASH script: icehole.ash
Finished ASH script: icehole.ash
Finished relay script: choice.ash
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1181&option=3
Retrieved: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1181&option=3
Finished relay script: choice.ash
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1183&option=2
Retrieved: http://www.kingdomofloathing.com/choice.php?pwd&whichchoice=1183&option=2
Field: location = [witchess.php]
Starting relay script: witchess.ash
Requesting: http://www.kingdomofloathing.com/witchess.php
Retrieved: http://www.kingdomofloathing.com/witchess.php
Finished relay script: witchess.ash
Finished relay script: choice.ash
and, as you can see, it called your script - but the arrow keys do not actually move around and highlight segements for me any more.
 
Last edited:

heeheehee

Developer
Staff member
I ran into that problem myself when testing it out post-rollover. I apparently had some typos in some last-minute changes that I'd added, so I fixed those and reuploaded a new version just now.
 

Veracity

Developer
Staff member
Revision 16805 includes my hack - and allows me to use your relay script even in the presence of a choice.php override.

I agree that this is not the "correct" solution - and we should probably just continue our discussion on the other thread and not follow redirects, requiring the browser to follow them.

I also don't actually know how to use your script to "help" me - but I see colors now, at least. I'll figure it out. :)
 

heeheehee

Developer
Staff member
Clicking on segments cycles through grey (inactive), blue (active), and black (flagged, not submitted as part of your solution).

Hovering over a region tells you the size of the region, as well as constraints on the size of the region (e.g. if you have two oxen and a knight, that'll evaluate to 12). What I usually do is combine that with manually outlining the shapes in black to check that I can indeed arrange these pieces into the region.
 
Top