AI for Game Developers by David M. Bourg & Glenn Seemann
Author:David M. Bourg & Glenn Seemann [Bourg, David M. & Seemann, Glenn]
Language: eng
Format: epub, mobi
Tags: Reference, Computers, Programming, General, Software Development & Engineering, Games
ISBN: 9780596005559
Google: Sz-Sqvm-hSYC
Amazon: 0596005555
Publisher: O'Reilly Media
Published: 2004-08-02T00:00:00+00:00
contain the distances to move in both the row and column directions. The next two variables are newRow and newCol. These two variables contain the new row and column positions of the ant. The final four variables, foodRow, foodCol, poisonRow, and poisonCol, are the new positions used to replace any food or poison that might get consumed.
We then proceed to calculate the new position. We begin by assigning a random number between -1 and +1 to the rowMove and colMove variables. This ensures that the ant can move in any of the eight possible directions in the tiled environment. It's also possible that both values will be 0, in which case the ant will remain in its current position.
Once we have assigned rowMove and colMove, we proceed to add their values to the current row and column positions and store the result in newRow and newCol. This will be the new ant position, assuming, of course, it's a legal position in the tiled environment. In fact, the next block of if statements checks to see if the new position is within the legal bounds of the tiled environment. If it's not a legal position, we exit the function.
Now that we know the position is legal, we go on to determine what the ant will be standing on in its new position. The first if statement simply checks for kGround or kWater at the new position. Neither of these two elements will cause a change in state, so we simply update the ant row and col with the values in newRow and newCol. The ant is shown in its new position after the next screen update.
The next section shows a critical part of the finite state machine design. This if statement checks to see if the new position contains food. This section is critical because it contains a possible state transition. If the new position does contain food, we update the ant's position, erase the food, and change the state of the ant. In this case, we are changing from kForage to kGoHome. The final do-while loop in this if statement replaces the consumed food with another randomly placed piece of food. If we don't continuously replace the consumed food, the ant population won't be able to grow.
The final part of the Forage function shows another possible state transition. The last if statement checks to see if the new position contains poison. If it does contain poison, the ant's position is updated, the poison is deleted, and the ant's state is changed from kForage to kDead. We then use the do-while loop to replenish the consumed poison.
Download
AI for Game Developers by David M. Bourg & Glenn Seemann.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Blood, Sweat, and Pixels by Jason Schreier(3472)
Dawn of the New Everything by Jaron Lanier(2675)
Godot 4 Game Development Cookbook by Jeff Johnson(2446)
The Art of Doom by Bethesda(2033)
Significant Zero by Walt Williams(1875)
Creative Character Design by Bryan Tillman(1828)
World of Warcraft Chronicle Volume 3 by Blizzard Entertainment(1650)
The Ultimate Roblox Book by David Jagneaux(1610)
Art Of Atari by Tim Lapetino(1557)
Pillars of Eternity Guidebook by Obsidian Entertainment(1530)
Dawn of the New Everything: Encounters with Reality and Virtual Reality by Jaron Lanier(1527)
1628927445Game by Unknown(1467)
Unreal Engine 4 Virtual Reality Projects by Kevin Mack(1459)
Unreal Engine Virtual Reality Quick Start Guide by Jessica Plowman(1436)
Mission Python by Sean McManus(1421)
The Ultimate Player's Guide to Minecraft by Stephen O'Brien(1412)
Learning D by 2015(1408)
Unity 2018 By Example by Alan Thorn(1387)
Road Games by Road Games(1360)
