TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Prolog Adventure Game

166 pointsby shaknaabout 1 month ago

11 comments

2mlWQbCKabout 1 month ago
Reminds me of Dialog, a domain-specific language for writing adventure games, heavily inspired by Prolog:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Dialog-IF&#x2F;dialog&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;Dialog-IF&#x2F;dialog&#x2F;</a><p><a href="https:&#x2F;&#x2F;linusakesson.net&#x2F;dialog&#x2F;" rel="nofollow">https:&#x2F;&#x2F;linusakesson.net&#x2F;dialog&#x2F;</a>
agiacaloneabout 1 month ago
Very nice. I gave a lab assignment like this once! It&#x27;s a great way to learn Prolog.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;agiacalone&#x2F;cecs-342-lab-prolog">https:&#x2F;&#x2F;github.com&#x2F;agiacalone&#x2F;cecs-342-lab-prolog</a>
评论 #43758187 未加载
评论 #43759848 未加载
hazymemoryabout 1 month ago
Just for curiosity I just asked chat deepseek to load and solve the game and it solved it in half a second.<p>It suggested adding some riddle, for example:<p><pre><code> path(castle, up, tower) :- at(blueprint, holding), (solved_riddle -&gt; true ; write(&#x27;Answer the riddle first: What walks on four legs in the morning...?&#x27;), nl, read(Answer), (Answer = &#x27;human&#x27; -&gt; assert(solved_riddle) ; write(&#x27;Wrong! Try again.&#x27;), nl, fail)).</code></pre>
ForOldHackabout 1 month ago
If you wrote an adventure game in Prolog, you could write a client that would also solve the adventure.
评论 #43764585 未加载
评论 #43759828 未加载
wfurneyabout 1 month ago
I have never heard of Prolog before so this was cool. I did think the &quot;make sure the flashlight is turned on&quot; point was kind of confusing. I have the battery and flashlight, but there&#x27;s no way to turn it on. I couldn&#x27;t run it with gprolog but swipl works fine.
评论 #43764258 未加载
codesnikabout 1 month ago
is it generated by LLM using prompt at <a href="https:&#x2F;&#x2F;github.com&#x2F;stefanrodrigues2&#x2F;Prolog-Adventure-game&#x2F;blob&#x2F;main&#x2F;README.md">https:&#x2F;&#x2F;github.com&#x2F;stefanrodrigues2&#x2F;Prolog-Adventure-game&#x2F;bl...</a>?
评论 #43760306 未加载
klibertpabout 1 month ago
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&#x2F;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.<p>...now that I look at this, it&#x27;s 3 years old. I wonder how much better today&#x27;s LLMs would fare?<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;stefanrodrigues2&#x2F;Prolog-Adventure-game&#x2F;blob&#x2F;main&#x2F;treasure_hunt.pl#L216-L225">https:&#x2F;&#x2F;github.com&#x2F;stefanrodrigues2&#x2F;Prolog-Adventure-game&#x2F;bl...</a> - no, the routine does not &quot;wait&quot; on Windows, you&#x27;d need to put `get_char(_)` or something before `halt`.
asciiiabout 1 month ago
Cool! I got stuck trying to figure out how to turn on the flashlight and then got stuck in the woods and died.
twothamendmentabout 1 month 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!
johnisgoodabout 1 month ago
I love text-based adventure games in Prolog.
mparnisariabout 1 month ago
I can&#x27;t get this game to start, am I stupid?<p>$ swipl -s treasure_hunt.pl<p>and then what?
评论 #43764713 未加载