Live data from Hacker News

Prolog Adventure Game

github.com

11–20 of 29 posts

Re: Prolog Adventure Game

#17
post #6
post #3

Earlier quoted context omitted.

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

This one? [0] [0] https://amzi.com/AdventureInProlog/

[deleted]

Re: Prolog Adventure Game

#18
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)).

Re: Prolog Adventure Game

#19
post #6

Earlier quoted context omitted.

This one? [0] [0] https://amzi.com/AdventureInProlog/

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.

> I guess if your reading this you now know my HN handle

No worries. A great philosopher once wrote:

"There is a theory which states that if ever anyone discovers exactly what your HN handle is for and why it is here, it will instantly disappear and be replaced by an HN handle even more bizarre and inexplicable."

Re: Prolog Adventure Game

#20
I only learned Prolog as a hobby, so I may be mistaken, but the quality of the code seems really bad? Starting from keeping game state in a bunch of magic globals (assert/retract everywhere), to a lack of input parsing (even though DCGs would be a perfect match), to comments that disagree with the code[1], to the game logic coupled with game mechanics as side effects (the winning condition is checked inside `take`)... I may be too used to Prolog code from books and tutorials, but the number of cuts also seems much larger than expected.

...now that I look at this, it's 3 years old. I wonder how much better today's LLMs would fare?

[1] https://github.com/stefanrodrigues2/Prolog-Adventure-game/bl... - no, the routine does not "wait" on Windows, you'd need to put `get_char(_)` or something before `halt`.

Post reply on HN