How would somebody make an entity smart? Like in Age of Empires, the guys walk around stuff, and the like. How do they do that?
How to make Smart Guys...
Blitz3D Forums/Blitz3D Programming/How to make Smart Guys... Its called Artificial Intelligence and its a vast subject.
You might want to start off reading up on path-finding.
You might want to start off reading up on path-finding.
Vast subject! I think I'll wait a few years before I try tackling that stuff...
its not that complicated, just learn how to use functions and types well, and you can start building decent AI with just abit of common sence.
This is my AI loop for a simulation of a load of ants going out, looking for food, and if they then found it brought it back to the nest. This is most of the code involved, apart from a sub routine handeling the way the ants move (just move in z):
'Hive' is my type for each individual ant, this code is run for each ant every turn to determin what they are doing this loop.
This is my AI loop for a simulation of a load of ants going out, looking for food, and if they then found it brought it back to the nest. This is most of the code involved, apart from a sub routine handeling the way the ants move (just move in z):
Select Hive\Mode Case "Looking For Food" If Hive\AttentionSpan > 0 Gosub MoveAnt Hive\AttentionSpan = Hive\AttentionSpan - 1 Else SeedRnd MilliSecs() : Delay 1 TurnEntity Hive\Model,0,Rnd(-90,90),0 Hive\AttentionSpan = (AntAttentionSpan * Rnd(1,AntAttentionRnd)) * FPS End If If EntityCollided ( Hive\Model,ColType_Food ) Then Hive\Target= CollisionEntity (Hive\Model, 1) Hive\Mode = "Found Food" End If Case "Lost" PointEntity Hive\Model, Nest Hive\Mode = "Looking For Food" Case "Found Food" If EntityDistance (Hive\Model,Nest) <1.2 Then PointEntity Hive\Model, Hive\Target End If If EntityDistance (Hive\Model,Hive\Target) <1.2 Then For Food.FoodT = Each FoodT If Hive\Target = Food\Model Then Food\Amount = Food\Amount -1 ScaleEntity Food\Model, (Food\Amount/300),(Food\Amount/300),(Food\Amount/300) Next PointEntity Hive\Model, Nest End If Gosub MoveAnt End Select
'Hive' is my type for each individual ant, this code is run for each ant every turn to determin what they are doing this loop.
Theres a good AI function in the Tanks game in the code archives, that helped me out alot when i first started my AI Lib.