I was bored the other day so I decided to port the game "Dukedom" from C to Perl. Here is the result, I'd greatly appreciate comments/feedback on how to make it display agnostic so it can be used for websites, Tk, etc. besides command line scripts. I have code refs now that can be changed out, but I'm pretty sure I need to do more. I am toying with using exception objects to signal the need for display/input and to provide callbacks to re-enter the state machine at the proper point.

Please keep in mind that this is only the first draft and no docs or tests have been written yet. However, the command line script will work and allow you to play the game.

https://github.com/boftx/Games-Dukedom

You can find the original code that I ported from here: https://github.com/caryo/Dukedom/blob/master/imports/dukedom.c

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Replies are listed 'Best First'.
Re: A port of "Dukedom" to Perl
by Nemo Clericus (Beadle) on Oct 07, 2014 at 20:24 UTC

    To clarify, are you more interested in setting up a particular display system that's portable or, say, creating a layer of some sort so that different display systems could be accommodated? I'm assuming the latter...

      For portability and speed, I would advice to use Sereal instead of Storable.


      Enjoy, Have FUN! H.Merijn

        Thanks for the tips, Tux and YM!

        I'm thinking about Storable because it is in CORE. JSON is also high in my opinion (and probably should be part of CORE given how pervasive it is.) I'll have to check the others.

        You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

      Yes, the latter. I seem to be coming up with a state-machine approach that saves state whenever input is needed (via Storable and SQLite?) and then throws an exception object (Throwable) that alerts the application code to what kind of input is needed and how to re-enter the state-machine once it is available.

      Conceivably there could be helper modules implementing a Display Role.

      You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

        And there are others besides what Tux brought up; Data::MessagePack for (maybe best?) speed and JSON::XS for Storable-level speed + human readability + best portability.