TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Game Programming in Prolog

283 点作者 febin7 个月前

20 条评论

dang7 个月前
Normally we downweight posts that just have a Part 1 and then stop, but this one actually delivers the goods:<p><a href="https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-11.html" rel="nofollow">https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-11.html</a> (part 2)<p><a href="https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-12.html" rel="nofollow">https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-12.html</a> (part 3)<p><a href="https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-13.html" rel="nofollow">https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-13.html</a> (part 4)<p><a href="https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-14.html" rel="nofollow">https:&#x2F;&#x2F;thingspool.net&#x2F;morsels&#x2F;page-14.html</a> (part 5)<p>(and keeps going!)
评论 #41805000 未加载
评论 #41811746 未加载
评论 #41804559 未加载
iamwil7 个月前
The Breath of the Wild game design has a concept called the &quot;Chemistry Engine&quot;. In that game engines usually have a physics engine to figure out how things interact in a motion sense. The chemistry engine figures out how materials interact in an alchemy sense. It&#x27;s kinda like a rules-based engine to figure out how different things interact with different other things, so you get surprising interactions between everything in the world, like being able to light arrows on fire, because arrows are a &quot;wood&quot; material.<p>The Youtube link is here: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyMsF31NdNc&amp;t=2354s" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyMsF31NdNc&amp;t=2354s</a><p>It seems like most rule-based stuff in games is just hand-coded, as it&#x27;s relatively simple and doesn&#x27;t need to be general. When I asked the author of Baba is You, if he implemented a datalog engine for it, he said &#x27;no&#x27;. I suspect it&#x27;s the same for Breath of the Wild.<p>But still, I&#x27;ve often wondered if that sort of chemistry engine would be best implemented in a logic language like Prolog or Datalog, for fast experimentation. Just like how we use SQL to keep the flexibility of our queries, and we end up just shipping that. I&#x27;m sure, back in the day, lots of people lamented how slow SQL queries were. The flexibility was useful enough that we ended up pouring man-centuries into making them fast. Now, we think that&#x27;s just the way you ship things, and (almost) never think, &quot;I can hand-roll imperative code that will be faster than this query&quot;.
评论 #41809562 未加载
评论 #41810063 未加载
评论 #41812213 未加载
评论 #41810615 未加载
tannhaeuser7 个月前
This is an interesting take on Prolog game programming in that it&#x27;s going straight to &quot;action games&quot; with a realtime, timeline, 3D, ECS, and event aspect. When most introductory texts on Prolog game development start with adventure games, in particular classic text adventures, since those build directly on Prolog constructs such as facts and rules for eg. mazes and inventory puzzles, and also DSLs. Or card and board games, the rules of which can be expressed so conveniently using Prolog, and can then almost trivially be extended into basic combinatorical general-purpose game opponents, not dissimilar to Prolog planners in robotics, logistics, finance, industry, etc.
JoeDaDude7 个月前
When I took an AI class, the first thing they taught was Prolog and for exercises we all had to write adventure&#x2F;colossal cave style games in it. Prolog turned out be well suited to the task. The variety of simple games made in the class was astounding and I wish I could have collected the all the games made by the other students. We only spent a couple of weeks before moving on to other topics, like CLIPS and Lisp. In my own assignment, I made a Bureaucratic Maze [1], again, fairly straightforward in Prolog.<p>[1]. <a href="http:&#x2F;&#x2F;logicmazes.com&#x2F;bureau&#x2F;index.htm" rel="nofollow">http:&#x2F;&#x2F;logicmazes.com&#x2F;bureau&#x2F;index.htm</a>
评论 #41805530 未加载
评论 #41805350 未加载
评论 #41806081 未加载
ralferoo7 个月前
I skimmed through all 12 posts, and while it seems like it might be a good introduction to using Prolog, it seems a stretch to claim this has anything to do with game programming. Maybe that will develop later, but so far after 12 lessons, it&#x27;s been mostly concerned with trying to model a few OOP concepts in Prolog.<p>Not sure if I&#x27;m missing anything, but nothing yet has been concerned with any kind of user interaction which would seem to be a pre-requisite for a game, although there was a brief discussion about sending messages so maybe that&#x27;s what he was intending.
haolez7 个月前
In the same vein, I had a lot of fun reading a game programming book with logic programming, but instead of Prolog it used CLIPS:<p>Adventures in Rule-Based Programming: A CLIPS Tutorial <a href="https:&#x2F;&#x2F;a.co&#x2F;d&#x2F;7wVOcZp" rel="nofollow">https:&#x2F;&#x2F;a.co&#x2F;d&#x2F;7wVOcZp</a>
评论 #41805148 未加载
评论 #41805545 未加载
评论 #41805735 未加载
kelseyfrog7 个月前
There&#x27;s an interesting (to me at least) overlap between gamestate as a set of facts and relations(Prolog), and the point of ECS(&quot;This is a database&quot;[1]).<p>I personally experiment in Datascript as a gamestate db, but it&#x27;s still quite an early attempt to conclude if it&#x27;s a success. It&#x27;s great seeing how ideas in this tutorial map 1-to-1 to that idea.<p>1. <a href="https:&#x2F;&#x2F;www.gamedevs.org&#x2F;uploads&#x2F;data-driven-game-object-system.pdf" rel="nofollow">https:&#x2F;&#x2F;www.gamedevs.org&#x2F;uploads&#x2F;data-driven-game-object-sys...</a>
评论 #41808274 未加载
评论 #41808317 未加载
klaussilveira7 个月前
This is such a breath of fresh air on tackling the state machine issue in games with heavy logic (city simulation, for instance). I never thought about using Prolog for this.<p>Bravo!
sevensor7 个月前
From the causality and relativity discussion, it seems like you could do some really neat stuff. Like for instance, you could generate a random encounter with an NPC, and a history of events for that NPC that includes causal chains initiated by the player in the past. Because everything is relations, and you know that the NPC is present now, and we have a history of all observed world state and actions, we can work backwards to get an entirely consistent history for the NPC without having simulated it in advance.
sterlind7 个月前
I&#x27;d never considered how the commonplace actor-world&#x2F;entity-trait model is a neat fit for Prolog&#x27;s whole relational deal. Though predictable and efficient run-time is also critical, and Prolog typically brute-forces its way through matching terms to satisfy the query. I haven&#x27;t finished reading the series though - maybe they address it?
评论 #41805381 未加载
评论 #41805208 未加载
rustman1237 个月前
I admit to not having that much experience in prolog, but I&#x27;m having a hard time translating the time parameter `[n]` into executable prolog. Anyone got a clue?
评论 #41808769 未加载
brandonpollack27 个月前
Interesting note: I believe the scripting language that larian (creators of the highly dynamic divinity titles and baldurs gate 3) is a prolog variant.
评论 #41808076 未加载
bubblyworld7 个月前
I&#x27;m thoroughly enjoying the philosophy side of these posts (like the how of representing various common abstractions in prolog), but I would love to see an actual game implemented in prolog! Does anyone know of any examples that are more complex than simple text adventures?<p>Or any anecdotes from more experienced prologgers about the experience of writing a real game? At face value it looks like it would be very easy to accidentally tie yourself up in a knot of logical contradictions, but I guess there are tools in prolog land for debugging this kind of thing?
znpy7 个月前
A bit of OT, but if one would like to pick up a bit of Prolog, what&#x27;s the recommended book?<p>And what prolog implementation should one pick?
评论 #41808924 未加载
HexDecOctBin7 个月前
Is there a embeddable Prolog implementation (à la Lua) that can be linked in to an application as a scripting language?
评论 #41811244 未加载
klaussilveira7 个月前
I&#x27;ll leave this here since it is useful: <a href="https:&#x2F;&#x2F;github.com&#x2F;emacstheviking&#x2F;gnuprolog-libsdl2">https:&#x2F;&#x2F;github.com&#x2F;emacstheviking&#x2F;gnuprolog-libsdl2</a>
Philpax7 个月前
The centered monospace text is quite hard to read on mobile, but reader mode seems to work well. Back to reading it now...
评论 #41804702 未加载
beretguy7 个月前
I’m not too dumb but my brain is not wired sufficiently enough to be willing to try to understand what’s happening. I can only understand it on a high level, but not I’m not going down this rabbit hole.
greener_grass7 个月前
Is there a variant of Prolog that is less dynamic with AoT compilation?<p>Imagine if you can be in &quot;dynamic mode&quot; where you can add rules, facts, etc. in an adhoc way.<p>Then, once your game is better defined, you can compile the Prolog to native code so that it is highly optimized, executed in parallel, etc. The compiler could apply all sorts of optimizations we see in commercial game engines automatically.<p>This compiled object could then be embedded into a game engine with native performance.<p>Done right, this could even outperform imperative game engines, but be very easy to debug and modify.
评论 #41809605 未加载
评论 #41808446 未加载
Apocryphon7 个月前
Now, to put this on a cartridge for the Prolog-powered Sega AI:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39206529">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39206529</a>