Earlier I wrote about the Beginner’s Guide to Roguelikes in C/C++. The author has updated the tutorial with some new stuff, including NPC characters. The new articles are
The 7th article is all about writing NPC that can randomly wander around the map. This article has a gentle introduction into OOP, by creating class for Actor (who currently is used for NPCs, but I suspect will be used for player character too).
The 8th article especially was interesting to read, because, in progress of adding multiple NPCs, he explains three different ways of doing it and some of the ramifications of each of them. After all, it pays to think of these things some before committing to a specific implementation. You can of course change it later, but it might be harder at that point.
The 9th article breaks the code into smaller chunks and shows how it makes things more manageable. Very useful skill to have, since navigating a huge source file gets tedious pretty quickly.
When I was trying out the previous articles, I was having some trouble with console library (instead of @, I kept getting floating point number on screen). Craig was really helpful and made some changes in his console library to get it working on my system too (I’m using CodeLite with MinGW). So if you had the same problem, try again and see if it works now.
The guide can be found here.