Live data from Hacker News

Ask HN: Where to start on creating AI for games?

news.ycombinator.com

31–40 of 49 posts

Re: Ask HN: Where to start on creating AI for games?

#31
post #14
post #2

http://codecombat.com/ may be a good starting point for writing simple AI logic.

That does look like fun. There are many online programming contests that work similarly to that, and I would recommend starting with one of them. I'd also add that while everyone suggesting AI resources is helpful, the best thing to do is just jump in and start coding. One of the problems with our formal education system is that it often ends up trying to present solutions to problems before the students actually und…

"I'd also add that while everyone suggesting AI resources is helpful, the best thing to do is just jump in and start coding."

I'd modify that slightly: skim (an hour per chapter? something like that) one or more comprehensive books (for this subject, Russell and Norvig is good) enough to get some idea what is known, then jump in and hack seriously, then interrupt your hacking when appropriate by going back to study the particularly relevant stuff that you know is already known. Jumping in is good and important, but it tends to be a lot more efficient when you have some idea about the outlines of what has already been worked out for you.

The times I haven't been able to follow this advice --- notably not having physical access to university libraries when I was trying to write a C compiler for a Z-80 as a teen back in the 1980s, hence having no very practical way to learn about existing work on parsers and stuff --- have been better than nothing, interesting and educational but not as efficient as doing stuff when I had a lot of stuff to study as needed.

Incidentally, a similar strategy can be very helpful for formal study of nontrivial subjects, e.g. various college-level engineering courses. Skim the text, and maybe another text from the library too, and/or an online Wikipedia-level survey/tutorial/whatever before the course starts. Then you have a much better chance of seeing how things fit together and of finding ways to clarify things you're puzzled by.

Re: Ask HN: Where to start on creating AI for games?

#32
I would say that it's best to start with turn-based games, like Bridge or Chess or (shameless plug) Ambition (and if you take on Ambition, let me know how your AIs do). Some games, like Othello, aren't hard to beat. Or you could do one of the German board games if you want to take on a more heterogeneous environment than in, say, Checkers.

This will get you familiar with game AI as a topic. Then you want to take on RTS and FPS games, which are similar but have deadlines (frame rates) and more complexity in the environment. But it's important to get the basics down before taking on a complicated game.

Re: Ask HN: Where to start on creating AI for games?

#33
You could start at the beginning. Some people are still unaware that the four ghosts from Pac-Man each have a different decision-making algorithm. The red ghost always targets the player. The pink ghost targets four spaces away from the player in the direction it faces. The cyan ghost uses a combination of player position, player facing, and the position of the red ghost to determine its target tile. The orange ghost targets the player when far away, and a home corner position when the player is close.

Those four strategies in combination, along with some global behaviors for pathfinding and behavior modes, are often enough to defeat an unaware player. (search: "Pac-Man dossier")

This introduces the concept of strategic archetypes. Human players have them, too. I, for instance, often favor stealthy sniper strategies. The various strategic archetypes often have a complex relationship web from who tends to defeat whom. The player that always tries to do an early rush to overwhelm slower opponents before they can mount a defense may be easily defeated by a trap-and-decoy opponent, whereas that player may lose to a gather-intel-then-send-ninjas player.

To create a competitive AI, first identify how humans play the game, identify the strategic archetypes, then model your bot to pursue archetypal goals. Then, most importantly, determine when to switch archetypes. An early rusher AI has no strategy for midgame or endgame, so perhaps that AI evolves into aggressive expansion, or an ambusher.

But also remember that the point of the game is for the humans to have fun. Avoid cheating, or overusing a game-breaking strategy. Your bot won't care if it loses, but a human may ragequit if he loses to a bot with a perceived unfair advantage.

Of course, there are some games with no human players. There's the "rock paper scissors programming competition" (rpscontest.com), where players submit algorithms, who then fight each other to the death for rank points. It is interesting to see new strategies rise and fall, including those who win by "cheating", such as by manipulating the match-generating program itself, setting the opponent's random seed, examining the opponent's heap or stack, or causing the opponent to be improperly disqualified for cheating.

Re: Ask HN: Where to start on creating AI for games?

#35
Battlecode (https://www.battlecode.org/) is a programming competition run by MIT every January for programming an AI to compete in a game (the exact nature of the game changes every year. It's vaguely Starcraft-like, except completely played by AIs)

It's open to non-MIT students, as well.

They also offer lectures in January which will be streamed on twich.tv - these may be of some interest to you, even if you decide not to compete.

Re: Ask HN: Where to start on creating AI for games?

#37
AI programmer here...generally "bots" are just AI that is intended to take the place of a player (typically in a versus setting and not a co-op setting).

If anything bots are tougher to make then "normal" AI since their value is measured by their performance against humans. Also the less you cheat (perfect knowledge of the other players, perfect aim, etc) the better your bot. Having a non-cheating bot beat a human is a major achievement.

The bots for a strategy game like StarCraft is fundamentally different than the bot for an FPS. They use completely different techniques and it's much harder to cheat in strategy game (though ignoring the fog of war is the most egregious). Strategy game AI is more akin to chess AI - lots of search (minimax and stuff). It's a whole field onto itself and you can only learn by studying the AI for that type of particular game.

FPS bots (like counter strike) are much closer to traditional game AI (shooters and such). Books on "Game AI" are a good place to start. Basically the two major problems is where should I go (evaluating cover, analyzing line of sight, estimating where enemies are and trying to pick a good place to stand) and how to I get there (pathfinding and pathfollowing). What you do when you get there is generally pretty straightforward (shooting at the appropriate guy). If you have a cover system you need to be able to tell them how to use cover and this involves a lot of animation (syncing my animations and position up to the cover in the world). But in an FPS this is usually just a question of crouching or not.

The big difference for FPS bots (versus single player enemy AI) is that bots need to choose between conflicting goals (should I go get ammo, should I go get health, should I attack the enemy). If you have a strict hierarchy of behaviours your bots won't be competitive (enter fuzzy logic systems, utility theory and the like - normal behaviour trees won't cut it).

Have fun!

Re: Ask HN: Where to start on creating AI for games?

#39

Creating "AI/bots" for games comes in three parts/flavors/divisions: First, and the most critical to most games, is basic behavioral AI. This includes things like pathfinding, locating targets, attacking, and otherwise making an entity in the game interact with the environment in the game. Second, you've got the more abstract parts, the "high-level decisionmaking". This is the AI's strategies and tactics, such as com…

Building off of your #3) An example for this would be the botting programs made for Runescape. Developers wrote an application that would sit on top of the game client and then use reflection in Java to see what's happening in the game: Various objects being created that are now on screen, the players direction, the map grid, etc.

The developers of this botting program would then expose their own API and scripting language that would allow other developers to interact with the game through their program. The could then write scripts such as: Go to this location via map coordinates, pick up some object, solve a puzzle, fight some boss, eat when below a certain health, etc.

Note: I used to run a VPS company that would specifically cater to those that were botting in Runescape; this allowed them to run their bots 24/7 without using their own hardware.

Re: Ask HN: Where to start on creating AI for games?

#40

1. Grab Unreal Engine[1]. It's $20 per month, but you can cancel after the 1st month if you don't want to receive updates. 2. Download the Unreal Tournament project[2] 3. Examine the bot code and start tweaking [1] https://www.unrealengine.com/ [2] http://www.unrealtournament.com/ Unreal is an industry-grade game engine that is also quite accessible. AI can be scripted in Blueprint (a visual dataflow scripting langua…

I plan to start looking into the Unreal engine soon after I get experience with a more basic engine. Have you found a lot of the resources available are able to get you started well? Or is there a large learning curve? My main experience is in writing Rails apps, Ruby gems, a couple basic Android apps, and everything DevOps.
Post reply on HN