[HN Gopher] AI Toolkit: Give a brain to your game's NPCs, a head...
___________________________________________________________________
AI Toolkit: Give a brain to your game's NPCs, a header-only C++
library
Author : todsacerdoti
Score : 103 points
Date : 2024-01-09 13:16 UTC (9 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| Philpax wrote:
| To be clear, this is conventional game AI and does not involve
| any ML. Still a cool project, though! Very compact.
| whatyesaid wrote:
| What do you mean by non-conventional game AI?
| BoppreH wrote:
| Not the person you're asking, but I think it's clear from
| context that they meant "no artificial neural networks" and
| other forms of AI that are trained from data. From the Github
| repo: It provides: Finite State
| Machines Behavior Tree Utility AI
| Goal Oriented Action Planning
|
| All of these are "AI", but handcrafted ones.
| whatyesaid wrote:
| I'm not aware of any DL based game AIs.
|
| I'm not sure you can really design a well put together
| experience around a DL agent, but if you can, it might as
| well just be handcrafted with some of these abstractions
| anyway.
|
| Because in the end, you essentially need high
| understanding/constraints of how it will behave otherwise
| you've lost control over the experience as the designer.
| linkdd wrote:
| You can use Q-Learning which is simple enough to have an
| AI that "learns".
|
| IANAPGD (I Am Not A Professional Game Dev), I haven't
| seen this as a gameplay mechanic either.
| DistractionRect wrote:
| Conventional game AI is usually search algorithms for
| movement (like A*) + finite state machines for behavior. No
| network calls to LLMs, no machine learning, etc. At the
| fringes, throw in the odd markov chain for procedural text
| generation.
|
| Basically AI post 2019 usually means LLM, and they're making
| the distinction that this is not that.
| linkdd wrote:
| Yup, conventional game AI is just bunch of ifs :)
| mjburgess wrote:
| if rule(mean(training_data, weightings)): ...
|
| isnt so different than
|
| if rule(programmer_params): ...
| Etheryte wrote:
| Depends. Conceptually there is no difference between a
| few ifs and a few billion ifs, in practice it's a whole
| different ballgame.
| NerdiDotOrg wrote:
| This is very true
|
| Code format for a 1 line like this example is nowhere
| close to # of lines in other files, the networking
| delays, and also can't be done client-side with current
| hardware to the scale needed for multiple entities all
| weighted uniquely in the current 2023 "AI" tools.
| tensor wrote:
| Planning / A* search is hardly a bunch of ifs, and is a
| crucial component of these systems. Expert systems are
| closer to a bunch of ifs, but that overlooks that the
| challenge is in coming up with the conditions, not
| writing if statements.
| rdedev wrote:
| All AI systems (including A* and LLMs) can be thought of as
| a system that explores a search space to obtain a certain
| goal. At least this is what I understood from reading
| artificial intelligence -a modern approach by Peter norvig.
|
| Both A* and deep learning explores a search space based on
| a goal. The difference is DL explores when it's training
| and learns to use the right moves for a given input.
| jameshart wrote:
| _Artificial Intelligence - a Modern Approach_ was
| published in 1995.
|
| It should be fairly obvious that what we think of as
| 'conventional AI' might have changed in the last 28
| years, even if we _hadn 't_ just been living through a
| twelve month or so explosion in the availability and
| power of generative AI models that transformed what
| people associate the term with.
| bee_rider wrote:
| It still seems worthwhile to make the distinction; it
| might be possible to think of them as the same thing at a
| high enough level, but the actual libraries and
| algorithms used are different.
| signaru wrote:
| Any book recommendations for conventional game AI?
| (Particularly with the "game" part, as games always have
| interesting constraints.) Thanks in advance.
| swyx wrote:
| basically the entire GameDevCon youtube channel has tons
| of examples
| DistractionRect wrote:
| I can't think of any books off hand, it'll vary depending
| on what kind of game you're making. Like the AI in
| F.E.A.R. will be different from Starcraft, which
| different than that in XCOM, etc.
|
| And if you're scaling difficulty, then you're likely
| tuning how the AI behaves.
|
| GDC, GDCVault, academic papers, and dev blogs//post
| mortems of similar games to what you're interested in
| will have a lot of good information.
| boarnoah wrote:
| http://www.gameaipro.com/ the content falls somewhere
| between a developer talk like at GDC and a textbook, very
| interesting stuff to read.
| gumballindie wrote:
| I don's see the issue?
| smegma2 wrote:
| Really cool
| linkdd wrote:
| Author here, feel free to ask any question :)
| robblbobbl wrote:
| How is this different from
| https://github.com/AkshitIreddy/Interactive-LLM-Powered-NPCs ?
| linkdd wrote:
| It's not an LLM. It's just Finite State Machines, Behavior
| Trees, Utility AI and Goal Oriented Action Planning.
|
| This should cover all you need to make an NPC a bit smarter
| (but it is still "scripted").
|
| LLMs are not what you would use to make a bot in
| Civilization, or Age of Empires.
| bogwog wrote:
| The number of emojis in that readme is ridiculous. It non-
| sarcastically makes me doubt the quality of the project.
| (although having the repo URL point to a LinkedIn page is
| probably worse)
| cthalupa wrote:
| Emoji in readmes seem to be a fairly consistent trend in
| the generative AI/ML space.
|
| The generative AI/ML scene seems to be very meme-y, from
| that, to all of the anime related stuff, to Mistral
| releasing models as torrents with warez-scene style .nfos,
| etc.
| Jemaclus wrote:
| I'm not a C or C++ programmer. Well, I know my way around, but
| I don't write real programs with it.
|
| Here's my potentially dumb question: what's the benefit of
| header-only libraries versus regular C/C++ code?
| linkdd wrote:
| The header-only part is actually accidental, I'm using C++
| templates which requires to be fully defined at their
| declaration site (the header).
|
| On top of that, the "Installation" instructions are just
| "copy the file in your project", no CMake, no Meson, not any
| kind of build system.
| robinwassen wrote:
| I would like to say thank you for posting this, I am currently
| building a similar toolkit in Lua and will most likely restart
| and just port your code instead :)
|
| It is extremely clean and concise.
| linkdd wrote:
| Thank you for the feedback :)
|
| Feel free to open issues or discussions on the repository if
| you have any difficulty.
| swyx wrote:
| related question to @Jemaclus above - why is C++ the popular
| language for gamedev? not C# or some other higher level
| language. is it only for when you're working on console games
| or does it also matter on desktop games?
| linkdd wrote:
| IANAPGD (I Am Not A Professional Game Dev) but,
|
| Unreal Engine uses C++. You have boost, SDL, Ogre3D,
| Irrlicht, EnTT, ImGui, etc... aka: C++ has a good ecosystem
| for gamedev.
|
| The "Zero Cost Abstraction" philosophy of C++ makes it easier
| to squeeze out the performance you want.
|
| Unity (and recently Godot 4) uses C# but they are still
| relatively young in the field. We were making games long
| before those :)
|
| I would not say it's "THE" popular language, but it does have
| an history.
| lainga wrote:
| And more anciently Godot also uses C++.
| refulgentis wrote:
| Context: Spent most of my C-ish experience on Objective-C
|
| What is the advantage of header-only?
|
| My mental model was headers ~= implementation as far as compiler
| is concerned, thus limiting the size of headers is a way to
| indicate API surface area and document.
| linkdd wrote:
| The "header-only" is actually accidental.
|
| It's all C++ template classes, which must be fully defined at
| their declaration site (so the header). When using the
| template, the compiler will generate the code needed by
| "instantiating the template" (for lack of a better word).
|
| The other advantage is that it requires no build system to
| include in your project.
| klaussilveira wrote:
| That is a very clean GOAP implementation.
|
| FYI, GOAP was what made F.E.A.R such a cool game:
| https://www.youtube.com/watch?v=PaOLBOuyswI
|
| https://archive.org/details/GDC2006Orkin
| senkora wrote:
| GOAP := Goal-Oriented Action Planning
| fullspectrumdev wrote:
| I now have a strong need to go and replay F.E.A.R and see how
| well it holds up! I remember back in the day comparing it
| favorably to Half Life 2, which still holds up well.
| adamrezich wrote:
| if you do, be sure to check PCGamingWiki to see what you
| should do to make it run as well as possible on modern
| machines--I ran into issues both with F.E.A.R. and Condemned:
| Criminal Origins, another title from the same developer https
| ://www.pcgamingwiki.com/wiki/F.E.A.R.#Essential_improve...
| alyandon wrote:
| Yeah, F.E.A.R. left a lasting impression on me. NPCs charted a
| path around the level to sneak up behind me and kill me while I
| was in a protracted firefight with the rest of their buddies.
| hesdeadjim wrote:
| GOAP has worked very well for us for an open-world game with
| tons of NPCs taking part in non-linear interweaving quest
| lines. Planning performance is an ever growing issue however...
| shadowpho wrote:
| I am looking to do same! What do you mean by planning
| performance? How bad is it?
| linkdd wrote:
| The performance of the planning algorithm (which is a path-
| finding algorithm essentially, which can be costly).
| hesdeadjim wrote:
| Goals have to evaluate their preconditions/etc and
| depending on your game to do so might be expensive. If a
| precondition for a goal is that a place in the world is
| reachable, you'd need to be able to run a pathfinding query
| to satisfy it. Other game systems might have bad Big-O as
| content gets added. The mission availability system in our
| game is one example, as we doubled the number of quests and
| NPCs post-launch and had to do some optimization.
| mikhmha wrote:
| I've been working on a multiplayer (MMO-ish) game. Currently at
| the point where most of the core stuff is in place and now I'm
| implementing the A.I. Recently there have been some great links
| posted on HN regarding Game A.I, and I'm very grateful for it!
| Implementing A.I has been a ton of fun and not as overwhelming as
| I thought it'd be. I think my game will be dependent on "smart"
| A.I behavior so I'm really trying to get this part down.
|
| The language i'm using - Elixir - also has some very interesting
| features that make it easy to integrate async a.i planning + a.i
| to a.i group communication. Ahh, I find it so exciting. The main
| simulation loop is never blocked. Meanwhile the A.I planner just
| chugs along as a separate process, spawning and despawning new
| agents in the world, creating and merging control groups, and
| setting new goals.
| linkdd wrote:
| Nice use case about Elixir! You should definitely write about
| it, I'm getting sick of the "We used Elixir/Phoenix/LiveView"
| articles out there. MMOs are one field where Erlang/Elixir can
| shine a lot due to their concurrency model, their fault
| tolerance, and especially no-downtime upgrades thanks to hot
| code reloading (very attractive to upgrade the server without
| disconnecting people).
| pdimitar wrote:
| I've been meaning to write a StarCraft 1 AI bot and put in
| the 24/7 SSCAIT tournament on Twitch but... never enough
| time. Elixir seems like the perfect fit, though it's unclear
| whether it can handle the computations when things get
| hectic.
| linkdd wrote:
| For performance intensive tasks, you could rely on Rust
| NIFs, there is this great project:
| https://github.com/rusterlium/rustler
|
| My last project with Elixir was using Elixir merely as an
| orchestrator of static binaries (developed in golang) which
| were talking in JSON via stdin/stdout.
| pdimitar wrote:
| Yep I've used Rustler with great success.
|
| And yep Elixir is an amazing orchestrator. But when the
| time comes I'll gauge whether I can't get most of the
| benefits with async Rust.
| brcmthrowaway wrote:
| Is there an AI "theory of everything" that can combine
| conventional AI with LLMs?
___________________________________________________________________
(page generated 2024-01-09 23:01 UTC)