PYTHON: AI games system, Nodes, Bots, Waypoints, Pathfinder, Astar


TUTORIALS:
http://en.wikipedia.org/wiki/A*_search_algorithm
http://www.policyalmanac.org/games/aStarTutorial.htm
http://theory.stanford.edu/~amitp/GameProgramming/
http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html#S2
http://www.geocities.com/jheyesjones/astar.html
http://www-cs-students.stanford.edu/%7Eamitp/gameprog.html#Paths



************************************** PROYECT BORGES( PATCH AI FOR GAME ENGINE) **************************************
finish date : MAY 2008
-----------------------------------------------------------------------------------------------------------------------------
Ok people here some advanced of my new proyect of Artificial Intelligent
Name Proyect : “BORGES” ( in honor my favorite Argentine writer : :wink: http://es.wikipedia.org/wiki/Jorge_Luis_Borges )

OBJECTIVE : New LogicBricks for Artificial Intelligent , new module of AI :

A - one visual editor in the controller for " FINITE STATE MACHINES " , or FSMs .
http://ai-depot.com/FiniteStateMachines/FSM.html
http://pochoblender.googlepages.com/FSM1.png

B - one actuator with “ALGORITHMS OF PATHFINDER”
http://en.wikipedia.org/wiki/Graph_search_algorithm

DATE OF POSSIBLE FINISH : MAY OF 2008 ( or someday when i fishinsed this :wink: )
PATIENCE PLEASE…
When i Get a stable version of my patch , I post some advanced file for download and Test…( Possibly March 2008 not guarantees :o)

screenshots:


EXAMPLE SCABOOTSSCA FOR BULLET
I am learning on the algorithm a* and to pathfinder
and to find example of pathfinder of “SCABOOTSSCA” for blender 2.41 ( VERY NICE EXAMPLE MAN )
http://blenderartists.org/forum/show…ght=pathfinder
i take this example an adapted to the blender 2.43 bullet
you can dowload here:
http://pochoblender.googlepages.com/…PATHFINDER.zip
you need python 2.4 install in you pc , for this example works:
http://www.python.org/download/releases/2.4.4/


BOT WITH WAYPOINT AND PATHFINDER
ok i working in the script
and learning the module Astar of SCABOOTSSCA
http://blenderartists.org/forum/show…ght=pathfinder
-characther “guy” of monkey insland 5
by Blengine
i create a very simple example of bots
with wayPoints system and pathfinder Astar
KEYS:
you change the camera 1 or 2
and visible / invisible WAYOPOINTS whith F1 . F2

YOU NEED PYTHON 2.51 INSTALL IN YOU PC
http://www.python.org/download/
you can download the blende file:
http://files.filefront.com/bots1zip/…/fileinfo.html
or here:
http://www.savefile.com/files/887430
now i continning learning python and implementation of Player pursuit pathfinder in the next example.


FPS PATHFINDER:
here advance file
i take the example of fps of MARTINSH : ( i love this example of fps ,greats works MARTINSH)
http://blenderartists.org/forum/showthread.php?t=85913
and i adapts to him a pathfinder module of saluk:
http://blenderartists.org/forum/showthread.php?t=67442

YOU CAN DOWNLOAD THE FILE HERE:
http://files.filefront.com/fpsBOTzip…/fileinfo.html
or here:
http://www.savefile.com/files/909529
you need PYTHON 2.51 install in your Pc:
http://www.python.org/download/



EXAMPLE OF CLICKPOINT:
you move the cursor with the mouse
and click where you oto walk.(blue cursor)
if you click on the crate( red cursor) oto atack this with missile.
characther of OTO
the module Astar of SCABOOTSSCA:

you can download here:
http://files.filefront.com/PochoclickPointzip/;8478004;/fileinfo.html
or here:
http://www.savefile.com/files/1029161

you need python install in your pc:

the capture:


MULTIPLE BOTS IN ACTION PATHFINDER
spacebar (spawn botton) = add bots in scene
control player:
move keys: W A S D
ROT =mouse
shot = left botton mouse
cameras = 1 or 2
you can download the blend example here:
http://files.filefront.com/MULTIPLES+BOTSzip/;8639194;/fileinfo.html
or here:
http://www.savefile.com/files/1222606

ok you need python 2.51 ,install in your pc :

That is nice :slight_smile:

I like your Maze , Hope to see someone do a Pac-Man game in blender.
Thank you for sharing this with us .

four close variants of RandomWander with SeekPacMan. that was the first example in my AI for Games text. complex ghost strategies appear to be emergent…

did you rewrite all the astar or just inspired by them ? if it hard to learn ? because I’m trying to understand saluk one and there is nothing that I’ve already seen on the code.

Anyway thereis a way to make a 3d array ? or maybe it took too many cpu. anyway if you still have some good link to understand how do we can make our a* program tell us

wow! nice! that a*script will be very helpfull for the AI of my game! thkx a lot POCHO for sharing !!

thanks mico27 for your commentaries
i post new example in the list
“multiples bots in action”
this can hepl you in your games
thanks very much to “SCABOOTSSCA” for his module astar and the another examples scripts…etc
I could learn much of them

:eek::eek:wuaaaa man excelent works:eek::eek:
the last example is just
right what needed for my
fps games :yes:
Thank you for sharing this with us;)

I’m modifying your code for my own need and I barely understand how it’s works. I wanted to know how do you define the array ? I mean how do you know what g.array you are gonna use. Any value is possible ? For example if I’m planning to do an rts and I want the unit to go to the end of the level or next to its position … the computing is not the same … how could I know ?

The multiple bots aren’t using astar ?

What exactly do you need to run these?

Do you download Python.51 manually and put the file in your Blender folder, or can you just download Blender 2.45 since it probably comes with that version?

blends are working perfectly. The only question I had was about the coding. You have to choose an array to subdivide the an area but I don’t know if the size is depending on the size of the level or not.

By the way I have another question about the way to move the character. You are using a tracker to move it ? I don’t see anywhere a move actuator or anything … Is it a way to accelerate the movement of your character?

hello black reaper . now i write a short a simple tutorial for to explain the SALUKs module pathfinder and how inmplementation in games.
In the example of multiple bots pathfinder
A -for move the actuator i used the MOTION ACTUATOR: “IR”
B - i remplace the track to actuator .
(because many problems to appear with i used an external objects and the track to actuator.)
For tWO function
in python i learn for the function of Herman.Tulleken:
http://www.luma.co.za/labs/tutorials/rotation.zip

A- FOR TRACK TO:


from GameLogic import *
from math import *
 
def euclidSize(vec):
 """
 Calculates the Euclidean size of a 3D vector.
 """
 return sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])
def cross(vec1, vec2):
    """
    Calculates the crossproduct of two 3D vectors.
    """
    return [vec1[1]*vec2[2]-vec1[2]*vec2[1],
  vec1[2]*vec2[0]-vec1[0]*vec2[2],
  vec1[0]*vec2[1]-vec1[1]*vec2[0]]
def pointToUpright(pos0, pos1):
 """
 Calculates the orientation of
 an object sothat its local y-axia
 can point to another object. The
 arguments are the positions of the
 two objects, with pos1 the position
 of the target object
 """
 y = [pos1[0] - pos0[0], pos1[1] - pos0[1], pos1[2] - pos0[2]]
 size = euclidSize(y)
 
 for i in range(0, 3):
  y[i] = y[i] / size #nomalise size
 
 x1 = sqrt(1 - y[1]*y[1] - y[2]*y[2])
 #z = cross(cross(y, [0, 0, 1]), y)
 z = [-y[0]*y[2], -y[1]*y[2], y[0]*y[0] + y[1]*y[1]]
 
 size = euclidSize(z)
 
 for i in range(0, 3):
  z[i] = z[i] / size #nomalise size
 
 x = cross(y, z) 
 res = [[], [], []]
 
 for i in range(0, 3):
  res[i] = (x[i], y[i], z[i])
 return res
 
controller = getCurrentController()
owner = controller.getOwner()
target = getCurrentScene().getObjectList()['OBTarget']
R = pointToUpright(owner.getPosition(), target.getPosition())
owner.setOrientation(R)
 

b -FOR FLIP THE ACTOR:


#---------------------------------------------
# Flips the conected object so that it's
# z-axes point up and the y-axis point in 
# the same direction (viewed from the top).
#---------------------------------------------
from GameLogic import *
from math import *
controller = getCurrentController()
owner = controller.getOwner()
R = owner.getOrientation()
#Take the second column (we do not need R[2][1])
R01 = R[0][1]
R11 = R[1][1]
S = sqrt(R11*R11 + R01*R01)
#Construct the new matrix
R1 = [[R11/S, R01/S, 0], [-R01/S, R11/S, 0], [0, 0, 1]]
owner.setOrientation(R1)
 

the next step of the proyects is create a wrapper of c++ of the module pathfinder SALUKS or dll file, for used in python script in blender game engine. for accelerate the velocity of compile .
now i learn this documents:
http://www.suttoncourtenay.org.uk/duncan/accu/integratingpython.html
http://www.boost.org/libs/python/doc/

( for the 2008 …I hope to can to finish it)
The final step is implentation the module of pathfinder and others algorithms ( MiniMax , IDA*, D*.etc) in the code internal of blender game engine and Actuator logic bricks.

PD : BLACK REAPER si tu entiendes algo de español puedes contactarte conmingo por messenger :
mi mail : [email protected]
tratare de ayudarte en todo lo posible.

I looked before the saluk’s method and It didn’t fit to my needs. I mean it’s not so portative ! I only need a reaaly simple way to move a character to a place B from the place A like in scaboosta demo.

I’m looking at your bot astar demo, and I hope I’ll find a way to simplify your version. I was wondering if you could explan how it work just few explanation I’ll do the rest mysefl. I just want to knwo what is the tracker’s use and the end( object) use.

pd : entiendo el espanol pero el problema que tengo es que no consegui a ponerte en el msn. Si vez a algun kensukeiron sera mi direction.

Ok people here some advanced of my new proyect of Artificial Intelligent
Name Proyect : “BORGES” ( in honor my favorite Argentine writer : :wink: http://es.wikipedia.org/wiki/Jorge_Luis_Borges )

EDIT : MOVED TO THE FIRST POST…

A pathfinding AI logic brick?!:eek:

Please submit the patch, many would even use it in its current state.

:eek::eek:Wow, that’s crazy… AI actuators.

Hmm… is this almost working already, or is the picture of the logic bricks just showing how it’s going to look like?

I’m wondering why you still need a PATH_FINDER python script for the controller, if the actuator should essentially take care of everything.

Jason Lin

Along with the recent 2D filter patch, the static geometry speed up patch, physics still being worked on, and this upcoming patch, as well as Toonist’s GE rewrite development of the GE is starting to finally get to a decent level:yes:

Hi cyborg Dragon and goldentaiji thanks very much for your menssages
this proyects is Just beginning. I works in this proyect only 1 or 2 hour for day because :frowning:
I dont much time free:(
. But patience . I think finish most possible faster this proyect.:wink:

really nice pocho ! As Always ! I’m reading your book really interesting ! does this idea come from there ?

Black Reaper:
Como estas amigo te escribo en español porque se que tu manejas mi idioma . Si a ese libro que te refieres me fue de gran ayuda para aprender a manejar algunos conceptos basicos , ademas de varias paginas web que tienen unos buenos tutoriales para la lectura.
ejemplo esta:
http://www-cs-students.stanford.edu/~amitp/gameprog.html
Pero aun me falta mucho trabajo por delante . Sobre todo el ¿“Como”? poder incorporar el algoritmo MINIMAX para juegos con adversarios.
Bueno te mando un saludo y nos estamos comunicando.

si tengo que mandarte un blend porque no entiendo el error que me mandan la pantalla de python

“astarNew.py”, line 90 , i get node

return self.array [y][x]
indexError : List index out of range

Si sabes lo que es me puedes dar una mano en eso ?

espero verte en el msn