2012-10-22

Nicomachus Conversion for Twine

Here is a conversion of Nicomachus for Twine. This was a much simpler program than Highnoon so I further restricted myself to making all program logic happen in Twine's tweecode.

Twine surprised me with its arithmetic handling. Up until now I had been ducking into Javascript for all but the simplest of expressions. Twine was easily able to handle an arithmetic statement with three sets of parentheses and about six terms.

Twine does lack a loop function (like a while). I was able to simulate this with an if, else, endif macro that keep displaying another passage (itself) until the condition expired. You can check the code for how I implemented this. The technique is known in computer science as recursion.

The verdict; A fun quick conversion.

Checkout the other games I have converted

2 comments:

  1. Looks like it's bugged for numbers under 7 (or I'm making a bozo math mistake).

    If I choose 6, my answers should be 0-1-0, but it guesses 21. If I choose 3, my answers should be 0-0-0, but it returns "Your number is right?"

    ReplyDelete
    Replies
    1. Thanks for pointing this out to me; "6" was indeed bugged and I have now fixed this. I verified all numbers under 8 are now working fine.
      Do check the math for "3". It should be 0,3,3 and that gives the correct answer. My straw polling of a few adults reveals this is a common mistake.

      Delete