Prolog Adventure Game

(github.com)

118 points | by shakna 11 hours ago ago

15 comments

  • agiacalone 10 hours ago

    Very nice. I gave a lab assignment like this once! It's a great way to learn Prolog.

    https://github.com/agiacalone/cecs-342-lab-prolog

    • pacaro 10 hours ago

      There's even a book "Adventure in Prolog" by Dennis Merritt (ISBN 1520918917)

      It's a lot of fun to work through, other prolog resources can be a little dry

      • shakna 7 hours ago
        • pacaro 7 hours ago

          Yes! that one!. I have a paper copy, so it didn't occur to me that there would be an online version

        • Sn0wCoder 5 hours ago

          Going to tell the Preface story tomorrow at work, I guess if your reading this you now know my HN handle ;) Not sure I will do the 'game' but that into was worth clicking the link.

    • nottorp 4 hours ago

      Yep. That's how I passed my Prolog course as well :)

  • ForOldHack 8 hours ago

    If you wrote an adventure game in Prolog, you could write a client that would also solve the adventure.

    • mcv 4 hours ago

      I can imagine it's easier to write that client in Prolog than the adventure.

  • hazymemory an hour ago

    Just for curiosity I just asked chat deepseek to load and solve the game and it solved it in half a second.

    It suggested adding some riddle, for example:

       path(castle, up, tower) :-  
           at(blueprint, holding),  
           (solved_riddle -> true ;  
            write('Answer the riddle first: What walks on four legs in the morning...?'), nl,  
           read(Answer),  
            (Answer = 'human' -> assert(solved_riddle) ;  
             write('Wrong! Try again.'), nl, fail)).
  • 2mlWQbCK 3 hours ago

    Reminds me of Dialog, a domain-specific language for writing adventure games, heavily inspired by Prolog:

    https://github.com/Dialog-IF/dialog/

    https://linusakesson.net/dialog/

  • codesnik 2 hours ago
  • wfurney 5 hours ago

    I have never heard of Prolog before so this was cool. I did think the "make sure the flashlight is turned on" point was kind of confusing. I have the battery and flashlight, but there's no way to turn it on. I couldn't run it with gprolog but swipl works fine.

  • asciii 8 hours ago

    Cool! I got stuck trying to figure out how to turn on the flashlight and then got stuck in the woods and died.

  • twothamendment 7 hours ago

    When I was in school I had to do some stuff with prolog. I got my wife interested enough that she added some rooms and items to a game like this. Good times!