Java sources of
Programming Game AI by Example
Programming Game AI by Example is a book written by Mat Buckland.
(September 30, 2004 | ISBN-10: 1556220782 | ISBN-13: 978-1556220784 | Edition: 1)
It is a good book about artificial intelligence in games. Very good for beginners.
But its example sources are written in C++, use Windows libraries and
are designed for Visual Studio 2006 and VS 2008. It was very complicated for me
to force them to compile in VS 2010 (Express edition). I had to repair some
source code, set up VS 2010 (set include and library directories),
download and compile new version of luabind etc.
At the end I succeded to setup it – but it is impossible to do it under Linux!
And because I prefere Linux to Windows (no surprise, right?) and Java to C++, I decided to rewrite all examples from C++ to Java. Other reason to do it was that It helped me to practice Java (I am new in Java programming) and it also helped me to understand better all the examples from the book.
Now I decided to provide all my Java source to the world. I hope it could help other people struggling with the C++ source, and Linux (or MAC) users. I also hope to becomme famous all over the world, so don't forget to like my facebook page (a way how you can say thank you :-).
I have repaired bugs in method PlayerBase.InHotRegion() (in SimpleSoccer project - this bug is also in the original C++ source) and SteeringBehavior.Hide(). Thanks to Nakasya Masuta and Shane Feehily for sending this bugs.
I have repaired a bug in classes Smoother.java and SmootherV2.java, where variable m_ZeroValue was not copied to variable sum, but only a reference of m_ZeroValue was assigned to sum. Thanks to Nakasya Masuta for sending this bug.
Raven game is out! This is the last update unless someone send me a bug report.
I have repaired a lot of bugs in Raven game and it is almost ready to be published!
I have repared method
clampand it's usage in all chapters.
I have repared methods
LuaHelperFunctionsclass in all projects in Chapter6.
Good news! I worked on Chapter7 for a while, and I am able to run it now. But it is still not working as it should, therefore it is not ready to be published yet.
I have repaired in a WestwoodMessaging project In
theEntermethod – the closing bracket for the
ifclause needs to include the message dispatch. And I have improved
CruderTime.GetCurrentTimeso it produces results similar to C++ code. (Both thaks to A. Rick Anderson who send me this patches).
I have created How to set up Visual Studio (Express Edition) page.
I have repared the
Telegramclass in Chapter 4 Simple Soccer. HashCode did not always return the same value for two equals telegram.
- All chapters (3.8 MiB, ZIP)
This includes all chapters listed below (as NetBeans projects).
You don't need to download anything else.
- Chapter 2 State Machines (203 KiB, ZIP)
First project in the book. I have rewritten only those parts of the source code,
witch I have to. In every other chapter there is
rewritten more code from the "common" directory.
There might be some differences between "common" packages in the others chapters
(the newer the better).
Remember, that i tried to write the code as similar to the original C++ source as possible. Therefore I used a lot of "import static" and other weird concepts, witch are not a "good Java practise".
- Chapter 3 Steering Behaviors (86 KiB, ZIP)
- Code for individual and group movement including the behaviors of seek, flee, arrive, pursuit, wander, evade, obstacle avoidance, wall avoidance etc.
- Chapter 4 Simple Soccer (113 KiB, ZIP)
- Implementation of a simple but entertaining artificial intelligence for a team based sports game.
- Chapter 5 Pathfinder (98 KiB, ZIP)
- Code of graph node class, graph edge class, graph class, depth first search, breadth first search, edge relaxation, shortest path trees, Dijkstra's search and A*.
- Chapter 6 Scripting Source (2.2 MiB, ZIP)
This chapter is about using lua language with C and C++ source.
It describes lua and luabind. But in Java, there are different projects
providing lua support. I decided to use LuaJ.
I managed to rewrite all examples without the need of changing any lua script, but I had to write help lua scripts imitating luabind behavior.
- Chapter 7 – 10 Raven (1.1 MiB, ZIP)
- This last 3 chapters sum all knowledge acquired before and add more (for example path planer, goal arbitration or fuzzy logic).
- Python code for Blender 3D.
- Bonus: A ported AI code from Programming Game AI By Example Cap.3 'How to Create Autonomously Moving Game Agents' to Python (Blender Game Engine) by Nakasya Masuta.
Subscribe, if you want to be notified about all updates:
- Buy Programming Game AI by Example on Amazon or read the customer reviews.
- Original C++ source to download (in Samples Materials section).
- Mat Buckland site about the book