"Programming Game AI by Example" - your opinion?

Started by
4 comments, last by Rybo5001 10 years, 2 months ago
I read that the book "Programming Game AI by Example" is a good beginner book for learning to program game AI.
But I also read that the code examples in the book are C++. This I guess won't be a problem because Java is similiar to C++ (will it be a problem?), but I still don't have any idea about 3D game programming. I'm still studying 2D. Would the book be useful to me even if some of the examples (I assume) are for 3D implemetations? (are they?)
Also, your general opinion on the book would be great.
This question obviously is for anybody who read this book or some of it.
Thanks
Advertisement

I don't recall anything in the book focusing on 3D implementations, if there were any they weren't emphasized on enough for me to remember. Most of what it focused on was implementing AI in a 2D game environment. Here's some of the things the book goes through:

  • A quick primer on on Math and Physics.
  • State machines.
  • Steering behaviors/Navigation.
  • Group steering behaviors.
  • Sports simulation.
  • Collision detection.
  • Graphs and a few graph search algorithms.
  • Pathfinding.
  • Scripting in Lua and writing an interface to invoke C++ code from Lua and vice versa.
  • Goal driven behavior.
  • Fuzzy Logic.

I really loved the book, as it helped me understand the basics with clear and detailed wording and source code, and helped me learn quite fast. It covers most of the basics really well. Looking back at it now, I'd say it doesn't cover some newer algorithms and techniques, an updated version would be very nice. To make the learning more fun for myself, I didn't use the provided 2D engine (I think there was one), but instead wrote a lot of the sample code from scratch to fit into my own 2D engine.

I wouldn't say Java is similar to C++, it might be but in a small way. One thing you're not dealing with in Java is memory management, and another thing you're used to in Java is having lots of libraries to do simple tasks in simple ways. C++ is beautiful and powerful, but sometimes the syntax can become hard to grasp, even when you want to accomplish something new, until you get used to it that is.

Something you should keep in mind when learning C++ is that you not only have to allocate memory, you also have to deallocate it, or else you'll get memory leaks.

In Java you would do something similar to this to allocate memory for an object:


SomeObject myObj = new SomeObject();

and then Java would automatically take care of deallocating it for you.

In C++, you have to deallocate memory yourself and ONLY when no other objects are using the one you want to deallocate.

At some point in time, you would have to call:


delete myObj;

I recommend reading a little bit about pointers and memory management and understanding them before you try following the examples in the book.

An alternative would be to write the book's examples and algorithms yourself in Java if you already have a 2D engine working. Both tasks would be a good challenge, but I personally recommend having good C++ knowledge in your toolkit as a game developer.

Sorry if I typed too much, I tend to do that a lot xD

Thanks smile.png Would you say I need to teach myself some C++ in order to understand the examples in the book properly? (regardless of your opinion that I should know a little C++ in general. I'm asking specifically about the examples in the book).

I mean, the book is about AI design, not about low-level things like memory management. I should be able to ignore C++ stuff like pointers and memory than I don't entirely understand, and still be able to see the AI logic in the code. Am I wrong?

EDIT: Also, would you recommend reading the book all the way through?


Would you say I need to teach myself some C++ in order to understand the examples in the book properly? (regardless of your opinion that I should know a little C++ in general. I'm asking specifically about the examples in the book).

No, you should be able to understand the code examples without having to teach yourself C++. I was mostly talking about C++ specifics in case you decided to build upon or tweak the sample code in C++.


I mean, the book is about AI design, not about low-level things like memory management. I should be able to ignore C++ stuff like pointers and memory than I don't entirely understand, and still be able to see the AI logic in the code. Am I wrong?

No, you are correct. You don't need to know all the intricate C++ details to understand the AI logic.


EDIT: Also, would you recommend reading the book all the way through?

Yeah, even if you only planned on learning a specific area from the book, it still has good material that will maybe help you think of game AI problems in different ways and come up with your own solutions.

Thanks a lot :)

Just to add, I think this book is amazing, one of the best I've read

This topic is closed to new replies.

Advertisement