• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

DarkMage139

Civilian AI

5 posts in this topic

I''m making an RPG that has plenty of civilians in it. My question is HOW DO I MAKE A "WANDERING" AI. The civilians are supposed to wander around aimlessly, but I don''t know how to write an AI for that. - DarkMage139
0

Share this post


Link to post
Share on other sites
Randomless AI == rand() %8

If you have eight directions, do a rand(), mod it by 8, and use a switch statement to see what to do in each case:

switch (rand() % 8)
{
case 0: // go up
locationY--;
break;
case 1: // go up & right
locationY--;
locationX++;
break;
.. etc.

}

There''s nothing intelligent about it.
0

Share this post


Link to post
Share on other sites
The other thing to do is to design some patterns for the people to follow. You can have some do circles, or whatever. Once you get numerous civilians, each running one of a few set patterns, it will seems like they are wandering around aimlessly.

You can make an array of integers, each with a number 1 throgh 8 (for the 8 directions described above). Then, each civilian has a pattern integer and location integer (the location in the pattern''s array) in the structure/class. You then use the code in the previous post to move the people around. Of course, when the pattern comes to completion, you reset the pattern location integer to 0. At this point in time, the civilian may or may not be in the same position he started. It doesn''t really matter, just be sure you don''t put a lot of the same numbers in the pattern, in case the civilian gets next to a wall or something.

This will add a little more control to what the civilians do.

Ben
0

Share this post


Link to post
Share on other sites
By ''wandering'' I assume you do not mean entirely random, just that you want them to look like they are going about their own business.

You could try a simple state-based system. Maybe a moving state and a choice state, or something like that.

Basically you could use the random idea from above each time the civilian is in the choice state, to select a direction to move in. From there the civilian switches into the moving state and might move in the random direction for ten spaces, or ten units of time or whatever.

Then they return to the choice state to make a new decision on direction.

Just an idea.

Woop
0

Share this post


Link to post
Share on other sites
quote:
Original post by DarkMage139

I''m making an RPG that has plenty of civilians in it. My question is HOW DO I MAKE A "WANDERING" AI. The civilians are supposed to wander around aimlessly, but I don''t know how to write an AI for that.

- DarkMage139


Hey DarkMage:


Well, I assume you''re after some behavior on the part of the NPCs that at least makes them look like they''re actually "living a life", right? The Ultima games do a pretty darn good job of that.

As one person already suggested, a simple state system can help you with this. Pick out a half-dozen occupations your NPCs will do in their village or town or whatnot, then set up a simple 3- or 4-state engine for each of them. For example, a ticket salesman at a railroad station might do the following:

State 1 (default) - Sits on bench at window waiting
to sell somebody a ticket.
State 2 - Puts up the "Went to Lunch" sign and walks
to the railroad cafeteria. Returns to ticket
counter.
State 3 - Sings a little diddy about a travelling
salesman and a minister''s daughter.
State 4 - Stands up in his office behind the counter
and shuffles some papers around; returns to State
1 when somebody comes up to buy a ticket.


A crude example, but with just a few of these you can quickly bring an area to life. Of course, if a player stands around forever and watches everybody he''ll sooner or later pick up the pattern--but if they just move through the railroad station en route to other areas of the game it''ll look pretty good.





Ferretman

From the High Mountains of Colorado
0

Share this post


Link to post
Share on other sites