Project 7: Advanced Computer Graphics: Artificial Intelligence
Behind the Graphics
Reference for this project:
Chapter 7
- Save the pieces of the project so you can later demonstrate
each one
- Make a directory ~/video/project7 in your home directory
Basic AI: aiDumbBiped01 "Dumb AI Bipeds(01)"
- In
game design, the algorithms underlying
intelligent behavior are referred to as AI, or Artificial Intelligence.
The aiDumbBiped01.wdl script provides basic animation of models,
enabling characters other than the player to move about in a game.
- Copy one of the levels from a previous project to the project7
directory, and use it for the current project.
- Then, place a player model and add the behavior
script plBiped01.wdl by right-clicking the model.
- Add a third-person camera.
- Build and run the game to check for errors.
- Next, add a second model to the level, such as hero.mdl and place
the new model directly in front of the player, away from any walls, and
facing away, as illustrated below.
Figure
1. A player plus opponent.
- Add the AI script "Dumb AI Bipeds(01)" aiDumbBiped01.wdl to the
game
- Add the behavior aiDumbBiped01 to the opponent
- Then, build and run the game.
- When the game first runs, the new character should run away from
the player. However, the player will probably stop after hitting
the first obstruction (due to some script bugs? in current version)
<>- Make a new copy of the aiDumbBiped.mdl (from the
template_6/code subdirectory of 3D GameStudio), and place the copy in
the directory of the game.
- Rename the copy aiDumbtw.wdl, and avoid using a long file name
since this may cause errors in the game.
- Open the new aiDumbtw.wdl script file in SED, and edit as
described in Chapter 8, including lines as below:
ifndef aiDumbtw_wdl;
define aiDumbtw_wdl;
- Further down in the file,
else
{
// scale rotation and linear input by the force modifiers
//aiDumbBiped01_ang_force_vec.pan = 0;
aiDumbBiped01_ang_force_vec.pan =
my._max_ang_force_pan__003; //tw
aiDumbBiped01_ang_force_vec.tilt = 0;
aiDumbBiped01_ang_force_vec.roll = 0;
aiDumbBiped01_force_vec.x = my._max_force_x__003;
//aiDumbBiped01_force_vec.y = 0;
aiDumbBiped01_force_vec.y = my._max_force_y__003;
//tw
//aiDumbBiped01_force_vec.y = 0;
aiDumbBiped01_force_vec.z = 0;
}
- Near the bottom of the aiDumbtw.wdl file, rename the action
AiDumbtw.
- In the newer versions of 3D GameStudio, new templates
must be placed in the template_6/code subdirectory of 3D
GameStudio. Since this directory cannot be written to by
students, we must work around the problem. First, use
File::ProjectManager to add a 3rd person camera, Biped Player, and Dumb
AI Bipeds scripts to your game, then recompile. To include the
new action in your game, copy the entire contents of aiDumbtw.wdl to
the end of your main game script (game7.wdl). In WED, make sure
that File::Prefernce::Advanced::Reload is set to Prompt so that WED
will reload the script when edited in SED. After editing and
saving the main game script, your new action "AiDumbtw" should be
available to be added to entites in your game.
In addition, it might be necessary to add three "define
statements" to
the code, since it seems that these are somehow ignored even
though these statements should have be loaded from BipedPhy01.wdl. As
below, the define statements should be added
just ahead of the corresponding code that was given above.
- Open the behavior customization window and set values as
suggested in the book
- Hopefully the opponent will reun around the level, and slide
along walls
- Once the game is running properly, experiment with different
settings for the AI model.
Randomizing aiDumbBiped01
- Even more erratic behavior can be created with some
randomization.
- As described in Chapter 8, add code
if( random(10) > 7.9 )
//randomization
{
aiDumbBiped01_ang_force_vec.pan =110;
} //end tpw
- Rebuild and run the program.
- The model should exhibit fairly random behavior.
- Experiment with other randomizations
FPS AI: aiFPS01 "Simple FPS AIs(01)"
- Add a Spider model as an opponent (download
from Conitec
http://au.conitec.net/ models )
- Add the "Simple FPS AIs(01)" script
- Change to a first-person camera
- Add the AIFPS01_Guard behavior to the spider
- Rebuild and run the game
- When running the program, "Parameter Unknown" errors may occur
in some wdl scripts at run-time. This may occur if the sequence
of
include files is incorrect or if an include file is missing
altogether. In some versions of GameStudio, the "unknown
parameter
FXA_Exp1_Flash" error is caused because fxa01.wdl was not included
before weaponfx00.wdl. This should have been automatically
included
when "Simple FPS AIs(01)" was added. It will be necessary to
manually
add the include statement to your game's main wdl script file as
illustrated below:
include <fxa01.wdl>;
include <weaponfx00.wdl>;
include <weapons00.wdl>;
include <aiFPS01.wdl>;
- You should have spiders
chasing the player as below (after walking near the spiders)
Figure
2. Spiders.
FPS AI: Path Following
- The random movements of the preceding section may be fine for
some games, but often it is desirable to have characters follow defined
paths.
- Add a path for one of the spiders to follow as shown below
Figure
3. Path added for path-following spider.
- Add the path number ot the propertirs of the AIFPS01_Guard
behavior of the spider. Remove any other opponents from the game.
- Rebuild and run the game.
Report and demonstration:
- Prepare a 10-page report exactly in the following format;
- Cover sheet with names
- 1 Page summary of project
- 1 Page Printout
as in Figure 1 above.
- 1 Page Printout
as in Figure 2 above.
- 1 Page Printout
as in Figure 3 above.
- Q1 No questions for this lab....
- Q2 above
- Q3 above
- Q4 above
- Q5 above
- Q6 above
- Q7 above
- Q8 above
- Q9 above
- Q10 above
- Demonstration: Show your
- DumbBiped game (not getting stuck)
- Path-following spider Game
Copyright © 2005- 2007 by Thomas
Paul Weldon
ACKNEX,
WED, MED, and 3D GameStudio are trademarks of Conitec Corporation.
Microsoft, DOS, MS-Dos, Windows, DirectX,
Halo, and
Direct3D are trademarks of Microsoft, Inc.
PAC-MAN trademarks or registered trademarks of Namco Limited
Nintendo, Mario, are trademarks of Nintendo
Atari, Pong, are trademarks of Atari
Intel, 8086, are trademarks of Intel Corporation
id, DOOM, and Quake are trademarks or registered trademarks of Id
Software, Inc.
Autodesk, 3D Studio, and 3ds Max are trademarks or registered
trademarks of Autodesk, Inc.
Alias and Maya are trademarks or registered trademarks of Alias Systems
Corp.