Sign in to follow this  
Followers 0
oskdemon

Avoiding Obstacles

4 posts in this topic

#1 ·  Posted (edited)

Hey guys.

Currently im trying to make a game macro that can move around, level, and much more.

right now im using a simple means of transportation, moving up 1 x coordinate would be clicking above the character, down below, same thing for y but left, right.

As every game has, there is obstacles in this game. I havent started this part yet, but this is where i am.

I plan on creating functions, move up, down,left,right.

If (xcoordinate) < (destination x coordinate)

_MoveRight

ElseIf (xcoordinate) > (destination x coordinate)

_MoveLeft

(same thing for y)

I was wondering if there is a easy way to avoid a set number of coordinates without making the script complicated

example,, say if i wanted to avoid coordinates 169 79 - 172 82

kind regards,

oskdemon.

(edit: I assume its possible to do an IF coord = (obstacle coord), do not move up or w.e but something neat would be nice)

Edited by oskdemon

Share this post


Link to post
Share on other sites



Hi,

Obstacle avoidance is one of the more difficult things to make in the field of artifical intelligence. Especially when writing a bot for a game when you do not have direct access to the internal workings of the game.

An example of why this is hard are bots in a game like Counterstrike: Source. Bots move around strangely, such as they move sideways and always walk in perfect lines. When they hit into an obstacle (prop_physics) their behaviour is unpredictable and strange, at best.

I think, however, that you're not trying to make real obstacle avoidance, but instead want to use something like a path finding algorithm. I really recommend A* for this purpose ( say: A star ), as it is very widely used and as a bonus: It has been implemented in AutoIt before!

For a reference on A* see this Wikipedia article: http://en.wikipedia.org/wiki/A*_search_algorithm ( Don't forget to look at the external links!! )

For the AutoIt implementation of A* see here: http://www.autoitscript.com/forum/index.ph...=47161&st=0

Also a cool and valuable reference of a website about path finding is below. It has a list of Java applets and explains some of the basics of path finding in a 2D environment. This can be translated into a 3D environment if you do a bit of creative programming, as most of the movement in 3D games is only horizontal and not vertical. This is the web page: http://www.red3d.com/cwr/steer/

I like to work with the Source engine when doing these kind of things. Mostly because it is free and is very well documented. Below is a list of links that helps when working in the Source engine or when you just want examples of an already implemented system!

http://developer.valvesoftware.com/wiki/AI_Programming

http://developer.valvesoftware.com/wiki/Navigation_Meshes

http://developer.valvesoftware.com/wiki/Server-Side_Bots

I hope this sets you on your way to writing a great application.

Kind regards,

Manadar

Share this post


Link to post
Share on other sites

Ah, I've heard of that before. But I don't honestly plan on spending time like that into such a small botting project.

Couldn't help downloading that script and playing with it though haha.

Any simple suggestions?

When you spawn in this game, you spawn a random spot in a very small town, with about 8 obstacles not including walls.

I have already calculated all of the coordinates where the obstacles sit, I'm thinking that I could tell the bot to:

If x coordinates are lower than what the destination x coordinates are, move right, If a set obstacle exists,

Continute on to moving using y coordinates, then when they reach a coordinate that is set as an obstacle, loop bot and start on x again.

Share this post


Link to post
Share on other sites

Hey guys.

Currently im trying to make a game macro that can move around, level, and much more.

right now im using a simple means of transportation, moving up 1 x coordinate would be clicking above the character, down below, same thing for y but left, right.

As every game has, there is obstacles in this game. I havent started this part yet, but this is where i am.

I plan on creating functions, move up, down,left,right.

If (xcoordinate) < (destination x coordinate)

_MoveRight

ElseIf (xcoordinate) > (destination x coordinate)

_MoveLeft

(same thing for y)

I was wondering if there is a easy way to avoid a set number of coordinates without making the script complicated

example,, say if i wanted to avoid coordinates 169 79 - 172 82

kind regards,

oskdemon.

(edit: I assume its possible to do an IF coord = (obstacle coord), do not move up or w.e but something neat would be nice)

Manadar - Amazing!

oskdemon,

This is my initial thought of a way of avoiding areas using a function from here.

http://www.autoitscript.com/forum/index.ph...st&p=639786

A non- working example.

;Define area to avoid
     Local $iLeft = 169, $iTop = 79, $iRight = 172, $iBottom = 82
     
     Local $MOx = 166, $MOy = 80;Current position of moving object
     
    ; Next proposed position of moving object
    ; $MOx = 166 + 1, $MOy = 80 moving to right
     
    ; Avoid area if object moving to left or to right
     If _WinAPI_PtInRectEx($MOx + 3, $MOy, $iLeft, $iTop, $iRight, $iBottom) _
             Or _WinAPI_PtInRectEx($MOx - 3, $MOy, $iLeft, $iTop, $iRight, $iBottom) Then _MoveUp() Or _MoveDown()
     
    ; Avoid area if object moving up or down
     If _WinAPI_PtInRectEx($MOx, $MOy + 3, $iLeft, $iTop, $iRight, $iBottom) _
             Or _WinAPI_PtInRectEx($MOx, $MOy - 3, $iLeft, $iTop, $iRight, $iBottom) Then _MoveLeft() Or _MoveRight()
     
     Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom)
         Local $aResult
         Local $tRect = DllStructCreate($tagRECT)
         DllStructSetData($tRect, "Left", $iLeft)
         DllStructSetData($tRect, "Top", $iTop)
         DllStructSetData($tRect, "Right", $iRight)
         DllStructSetData($tRect, "Bottom", $iBottom)
         $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
         If @error Then Return SetError(@error, 0, False)
         Return $aResult[0] <> 0
     EndFunc ;==>_WinAPI_PtInRectEx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0