2012-10-28

Camel Conversion for Twine

Here is a conversion of Camel. I can vaguely remember coding and playing this game as a kid in the early '80s. If it left that kind of impression then it must've been a fun game so I decided to give this a shot for a Twine conversion. It is similar in many ways to Highnoon in that there is an underlying game system represented by some quirky text.

The game play can be frustrating! Oases appear frequently enough that water is almost never a problem (just don't forget to drink). The biggest problem is the pygmies. They have a 10% speed advantage on your moderate speed, but running your camel at full speed burns it out three times faster.

SPOLIER: The mathematically optimal strategy is to go full speed twice, moderate speed once then rest. Drink when warned (actually the turn after). If you are captured then wait for the ransom. Even with an optimal strategy a win is not assured. In this game the player loses more often than not. Prepare for frustration.

I made extensive use of the custom macro <<randomp>> that I made for another project. This simplified a lot of the handling where things were triggered by random events.

I intentionally left as much logic in place as it is in the BASIC code with a couple of small changes. The capture submenu display the request for sub-command before the menu and the "Miles travelled" text appears more than in the original. There was also something where asking for a status report would fall through to also taking a drink. I assumed that this was a bug and changed status report to not force a drink at the same time.

From the viewpoint of 2012 the text could appear offensive. I prefer to think of it is ironically anachronistic because there are many obviously mismatched facts and intentional mispellings. Many of the other books edited by David Ahl do contain some quite detailed information about the historical context of the games so I do not assume the authors of this game were naively flavouring the game they way they did.

Checkout the other games I have converted

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

2012-10-21

Arduino LCD: Mugwump

This is an old game I never recall playing but it was one of the inspirations for Hunt the Wumpus and it has some elements of a game I was thinking of writing. There are four mugwumps hiding at random locations in a 10x10 grid. The user supplied an x & y coordinate to scan and is told if they have located a mugwump. The user is also told the distance to any mugwumps not yet found. The game ends after all mugwumps are found or then turns.

Code: http://eturnerx.com/files/arduino/011_mugwump_eturnerx_arduino_lcd.html

Mine differs from the original in a few minor respects; distances are rounded to the nearest integer in order to fit the display. Distances over 9 are simply not given. These small changes only make the game slightly tougher and most games can be completed in seven turns.

This looked like an easy game to convert; and it certainly is much less complex than many others. The kicker is that much of the supporting historical information is not in place and the game is kinda tough. I spent more time writing a wikipedia article and creating an HTML5 based game cheater *cough* helper than doing the Arduino code.

Checkout the other games I have converted

2012-10-15

Arduino LCD: Acey Deucey

There's something satisfying the challenge of fitting games into the limits of a 16x2 character display. This week I did a version of a card game called Acey-Deucey. The basic rules of the game are: first the player antes into the pot. Then two cards are dealt. The player may then bet on whether or not a third card will be between the first two cards. All you need to do is outlast an Arduino-AI opponent.

Code: http://eturnerx.com/files/arduino/005_acey_deucey_eturnerx_arduino_lcd.html

I did make some small changes to the game as it is played live:

  1. Ace is always higher than King and never lower than 2
  2. Pairs do not result in an automatic penalty
  3. The ante increases every few turns

A player can pass by betting "0". A player's maximum bet is limited by the size of their stack and the amount still left in the pot. The AI will bet only when the spread (distance between the two cards) is seven or greater. The AI bets more with wider spreads but will bet only up to half its stack. This is not a bad default strategy.

Since this game is mathematically solveable for optimal long-term play I intentionally made the Arduino-AI a little stupid; the AI does not count cards. There is a single standard 52 deck (4 suits, 13 ranks) being tracked and you are told when the deck is reshuffled.

You can gain a big advantage by simple card counting. Counting 234|QKA versus 6789T should do better than chance. You gain even more of an edge by tracking ALL cards and counting the ratio of good vs bad cards; Just how poker players count "outs". If you're really nerdy you might even try Kelly betting. Hey, whatever you find fun :)

Checkout the other games I have converted

2012-10-07

Highnoon Conversion for Twine

This week's creative project is a conversion of Highnoon for the Twine interactive fiction system. While I was converting/reimagining for Arduino I had two thoughts. The first was that I'd like to do a more faithful conversion with the original dialogue and secondly that such a conversion would be a way to demonstrate the power of Twine.

So, you know the game; You're in a showdown with Black Bart. You each have four shells and are 100 paces apart. In this original version there are more win/loss conditions than straight death.

Twine allows quite a lot of expressiveness and flexibility when writing interactive fiction. It also outputs the results to a single .html file that require no supporting libraries or other files. If you are interested in the basics of Twine then I'd suggest looking at this tutorial.

The conversion to Twine was fairly straightforward. I used the Jonah Story Format because it places passages one after the other without clearing the screen like Sugarcane does. I made a few tweaks to the inbuilt functions; the first to totally suppress the output of passage titles and the second to totally deactivate old choices. This was not difficult; it was more a matter of removing the bits of code from existing functions that I did not need.

I also based passage names around the line numbers in the original code. This eased moving from the GOTO style of the original code to the structured coding style of Twine.

The verdict; a very playable old-style game.

Checkout the other games I have converted

2012-10-01

Arduino LCD: Highnoon Conversion

This week is a conversion (strictly a re-imagining) of a game from 1970 called High Noon. Try to kill Bart in a shoot out! Your have a range of options that can be accessed using the left, right and select buttons on the Freetronics 16x2 LCD shield. After your turn Bart has his turn. The video shows only a few of the things that happen in the game.

Code: http://eturnerx.com/files/arduino/004_high_noon_eturnerx_arduino_lcd.html

The AI is probably tougher than the original. The text prompts were shortened to fit the screen and a few new things added for flavour though the essential game is the same. A few edge cases (running away) were changed and the being shot in the back was also changed. Any action the fails, standing still or walking/running 0 paces results in a penalty making you easier to hit.

The implementation uses a state machine in the main loop in the same way that the Hunt the Wumpus conversion did. In addtion, the static string data grew too big for the working memory on the Arduino so I needed to use the PROGMEM trick and create a string table.

If you are interested in a more faithful, online playable version then check out my HTML conversion of Highnoon.

Checkout the other games I have converted