ID:1750321
 
(See the best response by Zecronious.)
Code:
mob/proc/Krillin()
var/mob/Krillin/K = new(locate(x,y+5,z))
world << "test K [K]"


Problem description:I'm starting my own thread for AI as I want to create something specific to my game. While possibly helping others searching for forums for what I was trying to do.

Right now my code is very basic and I could throw some basic code to make him walk towards the player but I want to see what other code you might suggest.

I would like to have a battle system for several mobs that gets increasing tougher. Not just because they will be stronger or faster but smarter too.

The battle will be placed in a small 8x8 arena. Other then making the mob walk randomly or towards the player I want to get more idea's on whats possible with byond.

One idea I had was to teleport the mob at random times to a different location within the arena. The turf used for the arena is different then anywhere else in the game. I'm not sure how I would implement it without making the mob possibly teleport outside the arena.

I will post another post in this thread in the next 24 hours with an update of what I've made. In that time if anyone post something here that might help me I will try to implement that also. Thanks for taking the time to read and helping me out!

Something I've done to handle random AI movement is to periodically pick a random nearby turf and move towards it. It looks more natural than walk_rand(), which picks a somewhat-random direction every step.

The nice part about this is that you can pick your turf with pick(), from an arbitrary list of potential turfs. In your case, you might want a list of every turf in the arena, and pick from that. Or if the arena is an axis-aligned rectangle, you could pick a turf with locate() and rand() instead of a list.
Best response
I enjoyed the challenge of programming my concept. The only change I made was bounding Krillin to a 9x9 arena. Odd numbers are better because it makes the tile the player is standing on the centre of the arena. Otherwise the centre of the arena is hard to define.

What mine does is disallow krillin to move if he tries to move outside the arena and defines the arena boundary points in a Bounding object.

Tested this and it works. Here's the code on pastebin as well, cos these forums hate tabs. http://pastebin.com/MWPCCiM5

Bounding
var
maxX
minX
maxY
minY

New(MAX_X, MIN_X, MAX_Y, MIN_Y)
maxX = MAX_X
minX = MIN_X
maxY = MAX_Y
minY = MIN_Y

proc
isValid(X,Y)
return X < maxX && X > minX && Y < maxY && Y > minY

mob/Krillin
var/Bounding/bounding

Move(var/atom/NewLoc,Dir,step_x,step_y)
if(bounding.isValid(NewLoc.x, NewLoc.y)) return ..()
else return 0

New()
AI()

proc
AI()
spawn()
while(src)
var/nextAction = pick("move","attack","teleport")
switch(nextAction)
if("move")
// Fill this
if("attack")
// Fill this
if("teleport")
// Fill this
sleep(10)

mob/verb/Krillin()
var/mob/Krillin/K = new(locate(x,y+3,z))
K.bounding = new/Bounding(x+4,x-4,y+4,y-4)