Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

trapped in an infinte loop?

I have designed a random labyrinth-maker, that populates a 2d grid/sets gates open closed etc, chooses a random direction and checks if visited before etc.

Now it works fine if i link the twine pages with link->link but when i try to automate it (60 keypresses before a game would be tiresome!) by linking with (print:"link") it gets the wiggins, bugs out and panics that it's trapped in an infinte loop!

Any idea how this can be avoided?

Comments

  • edited February 2017
    First. You should always state the story format you're using and its version, because advice will tend to vary based on that information.

    You're going to need to show your code. We can't tell you exactly what the issue is if we can't see the code.

    PS: Please use the code tag when posting code or markup—it's C on the editor bar.
  • Thanks, and yeah.. sorry!

    I'm using Twine 2.1.0 and using Harlowe.
    I'm attempting to attach a html file, it works - but you have to keypress through a whole load of turns until map completion, as i say replacing the link with a (print:"link") type command to automate it causes the program to assume a recursive infinite loop, whic it is not - the code otherwise does work. the "graphic" displays are purely for feedback to check the code is working, so it looks very untidy - but you'll get the idea. Any feedback/comments or suggestions would be most welcome!

    <img src="http://twinery.org/forum/uploads/Uploader/57/3ae9e6b85e09465adbf9e7b0f0b14a.html"; />
  • edited February 2017
    When asking a question you need to state both the name and version of the story format you are using, as answers can be different for each one.

    Your example uses a recursive displaying of the random direction passage to simulate a for $turns is 1 to 4 loop, I strongly suggest that you use Harlowe v2.0.0's (for: ) macro instead.
  • the loop is good, but it doesn't produce a random direction, hence i included a variable $turns to count how many attempts made at finding a valid direction to continue in. Not all directions are detected as randomly sometimes the same direction is picked repeatedly thence reporting "No more ways you can go", which i didn't mind as it produced randomness.. This is the first thing i have done in TWINE and in fact the first thing i have coded since i last wrote in BASIC in 1988. :) I think you are right, reducing the opportunities for repetition of loops will reduce the likelihood of TWINE thinking it is stuck forever. What i didn't quite get was why when you break it down into steps with a keypress pause it doesn't produce an error - i suppose its the speed of page repetition?

    Thanks for the advice.
Sign In or Register to comment.