Before we get started... ● Slides: ● Purpose of this talk ● Who are YOU!? ● Who we are – BlueLine Game Studios
Hive
TABLE OF CONTENTS ● In The Lab – Abstract Strategy Games, Minimax, Alpha-Beta, Killer Heuristic, OpenBGE, Measuring Complexity – 4x, Genetic Algorithms, MTAIF, Further Reading ● In The Wild ● Wrap Up
IN THE LAB
Abstract Strategy Games ● Decades of research – Chess, Checkers, Go, Tic-Tac-Toe ● Use AI Agents (Strategy Model) ● Bonus for AI vs AI – Find bugs and exploits – Evolve AI and analyze progress
Abstract Strategy Games: Minimax Algorithm ● This is the best ever. – Deep Blue – 12 Plies deep, +5 points for Blue ● Heuristic Evaluation Function (parameterized) ● [show how it works] ● Parameterize weights – 2 huge benefits... will see them later in the presentation
Abstract Strategy Games: Minimax Algorithm
● This is the best ever. – Deep Blue – 12 Plies deep, +5 points for Blue ● Heuristic Evaluation Function (parameterized) ● gif source: [wikipedia - cc by-sa 3.0 us]wikipedia – for more ● Parameterize weights – 2 huge benefits... will see them later in the presentation
Abstract Strategy Games: Minimax Optimizations ● Alpha-Beta Pruning [in action] ● Killer Heuristic – Optimization on Alpha-Beta – Configurable ● Variants on Minimax – Negamax (code cleanup for zero-sum games) – Maximin (for non-zero-sum games)
Abstract Strategy Games: Minimax Optimizations
● Alpha-Beta Pruning [wikipedia cc by-sa 3.0]wikipedia ● Killer Heuristic – Optimization on Alpha-Beta – Configurable ● Variants on Minimax – Negamax (code cleanup for zero-sum games) – Maximin (for non-zero-sum games)
OpenBGE (Open Board Game Engine) ● Save yourself some time! ● C#, XNA ● Well commented, poorly documented otherwise ● OpenBGE.org OpenBGE.org
Abstract Strategy Games: Measuring Complexity ● Branching Factor – 4 average in Tic-Tac-Toe (9 - move#) – average in Chess – ~198 max in Hive ● Board Size – 9 in Tic-Tac-Toe – 64 in Chess / Checkers (“Draughts”) – ~1,290 in Hive ● State-Space Complexity ● Game Tree Size
4x Games ● 4x = Explore, Expand, Exploit, Exterminate ● Civilization III, etc. ● Similar Heuristic Evaluation Function – Usually not worth looking into the future plies – Must be really good – Parameterize here too! ● Genetic Algorithms / evolution strategies – “Shattered Throne”
4x Games: MTAIF Multi-Tiered AI Framework ● Very useful in 4x, but also in other AI (eg: RTS) ● Different sub-systems with different AI Agents – General – Lieutenant – Sergeant / Private ● Advantages – Code clarity – Incremental improvement (swapping) – Performance ● not all systems each turn
4x Games: Further Reading ● “An Introduction to Genetic Algorithms” by Melanie Mitchell ● Checkmark Games' AI blog seriesblog series – “Shattered Throne” for Xbox 360 ● “AI Game Programming Wisdom 2” edited by Steve Rabin – Fireaxis re: Civ III – up to at least v4 by now
TABLE OF CONTENTS ● In The Lab ● In The Wild – Features to make AI fast, fun & realistic. Harsh realities learned while making Hive ● Wrap Up
IN THE WILD
Humans & Fun Factor ● Your game is usually not play-by-mail! ● Fast enough to be fun – Need timeouts – Limits on Branching Factor – Progress bars! – AI on a different thread from UI (*multithreading) – “move now” option. Often bad though.
Humans & Fun Factor ● Human enough to be fun – Small amounts of randomness ● Unstable sorts such as most QuickSorts (Hive) ● Programmed random/weighted openings in Hive – Don't fail in non-human ways ● Repeating, then un-doing a move ● Doing something any move that is visibly “stupid” even if the overall AI is good, will give a bad impression.
AI Configuration ● Not just good for Genetic Algorithms ● “Personalities” – Opening – Normal – balanced – Winning – go on the attack – Losing – switch to defensive – Can also be a tool for character development ● Infinite Configurability (even saving)
Warning! / Uwaga! / Försiktig! ● Make sure player is learning to be good at winning the game, not at beating the AI. ● Real world examples – Civ III “cheating” – Hive Spider slowness
Harsh Realities: Lessons learned from Hive ● Real hardware is a huge constraint – Xbox 360 == 7.5 year old hardware – Cut top 2 levels of AI (will be on PC/Mac/Linux) ● AI Estimation – Off by orders of magnitude in dev-time – Spent ~month killing all runtime allocations to avoid Xbox Garbage Collections – AI didn't make initial release – Was a free update 2.5 mo.'s later
TABLE OF CONTENTS ● In The Lab ● In The Wild ● Wrap Up – I'll make it fast so that you still ask questions... lunch approaches!
WRAP UP ● Download this whole presentation online! – ● Play Hive (soon Khet 2.0) to see this in action – ● Then check out the source code: –
QUESTIONS? ● If you have more questions later: – – –