Algorithm for step 3 of a four step procedure for solving puzzles

I posted a four step procedure for solving puzzles where steps 1,2 and 4 could be automated in software. Here are some thoughts on an algorithm for automating step 3.

Step 1 - Fill stacks with alternating A-U U-A pairs
Step 2 - Stabilise loops by placing Gs
Step 3 - Place G-C pairs (and G-U pairs if required) to solve structure and all constraints except the number of G-U pairs
Step 4 - Place G-U pairs

Step 3

  1. Define two structures

STACK
XX… XX
XX AU UA alternating pairs from step 1 XX

includes the shorter forms
XXX
XXX

XX
XX

PENTAGON (imagine the bend)
…U
XX…XX
XX…XX

  1. Algorithm
    Start at base 1 and move along the bases.

When to apply the procedure P:

STACK
P…P

STACK…PENTAGON…STACK
P…P…P

Procedure P:
Try all combinations of AU UA CG GC in the four positions… X
…X
Select the combination that best meets the CRITERIA (see later).
[There are four possibilities for four positions giving 4x4x4x4 combinations (256)]

Keep going round until the CRITERIA are fully satisfied OR no changes were made in that pass.

If no changes were made in the last pass try combinations where at least one pair is UG or GU.

  1. CRITERIA
    The selected combination must satisfy constraints on consecutive Gs and consecutive Cs.
    It should be white locally (if possible) and have the largest white overall. [I’m referring to the red/white schematic on the puzzle page]

  2. TRIM
    The last step is to satisfy constraints on G-C pairs.

Start at base 1 and move along the bases.
Replace a GC or CG pair with AU. If this breaks the CRITERIA try UA then UG then GU

Keep going until the constraint on G-C pairs is satisfied OR no changes were made in that pass.

3 Likes

Really neat to see you as a new player, this quick start to make puzzle solving strategies. If you can do a bit of scripting you might have fun with tweaking the puzzle solving scripts in our scripting area or add your own.

Thanks. I’ll do that.

Yes, welcome davidbuderim!

I don’t have the bandwidth to follow up on this right now. But your breakdown into steps corresponds very closely to how I manually go about solving most puzzles, although I have different strategies for the individual steps. That leads to the following idea, which could be fun if enough coders (and/or wannabes) wanted to take part.

With the in-game scripting, it is possible to invoke one script from another script as though it were a procedure call. So it should be possible to create a “master” execution script that took a list of parameters consisting of script IDs to call for each of these steps. Some scripters might want to create all new scripts for all the steps. Others might try to improve only one step, and use the most successful versions of the other steps. Someone who doesn’t have much coding experience could certainly learn enough to try different combinations of the steps written by others.

Just a thought :slight_smile:

1 Like

I really like the idea with a “master” execution script. I know that jandersonlee has his puzzle solving script build up in modules, which can be specifically called for and combined at will. I think what you suggest, Omei, could really help us make even stronger puzzle solving scripts, in the future.

Here is a link to the description of the modules and how to call them in jandersonlee’s puzzle solving script:

jandersonlee’s puzzle solving bot