   making an bot simulator... what kid of functionality do you recommend?
  Hello, I think I should've asked this stuff a long time ago, but anyway...For my finnal year project i've created a bot simulator. The goal of this simulator is to provide a framework for testing out AI implementations. The simulator is 2D and tile based, so nothing too fancy. So the simulator is integrated with lua, and to control a bot, you first create a script that has 3 functions - Init, Update and Shutdown. The init function is called when the environment is initialized and the shutdown when the environment is destroyed. The update method is called once per bot per x seconds.So anyway, I want the functionality provided to make AI development as easy as possible with this thing... problem is I've never done AI development and wouldnt know what kind of functionality is really really needed, so I'm here to ask:As in what kind of funnctions do I need to bind to lua to be more precise. I already have the following:Go() - tells simulator that your bot is moving in the direction you've setSetDir(Dir) - points the bot whereverGetDir() - gets your directionStop() - stops your bot movement in the direction that its set inFire() - fires a bulletGetHealth() - return how much health points you have leftGetLeftTile() - tells you what tile type is on your leftGetRightTile() - tells you what tile type is on your rightGetFrontTile() - tells you what tile type is in front of youGetBackTile() - tells you what tile type is behind youSo anyway, those are the functions I currently have. The few final caveats are that you can only have 5 active bullets at a time, if you Fire() when after you already have 5 in teh field, Fire() does nothing. Your Update() function is executed every 150 millisecods to be precise, that means you can do a bunch of stuff every 150 millisecs... and each bots script is carried out in turn or creation. Next is that if you Fire() you cannot SetDir() in the same Update call... You can call both, but only one or the other will be executed (The first one the script finds)What I'm asking is will I need a function like GetNumActiveBots() or a function like GetTileAtPos(x, y) or whatever other function to be made available to the lua scripter?I've already created a thread in Your Announcements forum announcing the completion of this software with a download link, but after playing with this thing a lot yesterday, I've realized that I need design opinions before people actually start testing this thing out...   
  what you have should be enough aslong as its possible to store data between updates,however a long range scanner with modifiable scan arc could be nice.I.E you set the scan arc , scan and it returns the distance to the nearest enemy within the arc. (then it would be possible to cut the arc in half, and make 2 new scans to determine the targets position in more detail, and even track its movement and calculate shot trajectories.   ;  Don't do getDir and setDir. The abstraction is broken, and anyway, the scripter should be able to track for him/herself what direction s/he's facing (assuming s/he cares). I would only offer the set, or perhaps instead a Rotate().   ;  hi Zahlman... what do you mean exactly when you say the abstraction is broken? with the getDir()? ok, i think i know what you mean, but the thing is that bots are placed inside the level randomly and with a random direction, so without the getDir, there really is no way to see which direction your bot is facing...Does the getDir give an unfair advantage to a scripter? Is it information that should not be given? oh and why?Anonymous: A what? what's an arc scanner? And how would you go about this in a tile based application where you can only move either left up down or right?Thanks guys.   ;  The 'arc scanner' Anon described is just one way, but some long-range 'vision' is probably a good idea. You can implement this whichever way you think suits the game: Having direct access to the entire map will probably make for boring matches (where each bot immediately locks a target and fires madly), whereas the current 360° one-tile field-of-view would probably be worse: I can only imagine a number of bots running around blindly in straight lines for ages, looking for game which, when found, will be too close for any tactical behaviour.You should decide how far each bot can see and what its field of view would be. Something similar to that of a human would make for the most intuitive results. If I were in charge, I'd let the bots see the contents of every tile that's within 45° (in either direction) of the heading vector.RegardsAdmiral   ;  Yeah, i got it. Thanks for the feedback... I've been looking into some methods of getting a bunch of tiles that are viewable and not being blocked... does anyone know of any existing algos that can do that? I read around and from what i undestand:First get the tiles that intersect with a view cone (any algo for that?)Then, use bresenhams to see which tiles are visible.   ;  I think that having a getDir() method is fine, but I also agree with a rotate() method as well. Maybe rotateLeft(), rotateRight(), and flip(). You could also have faceTowardObject() and faceAwayObject() methods and pass in the object you want the bot to face.Algorithm to determine if an object is within a bot's view (more or less in C; I'm sure it'd be easy to convert into Lua):bool isInView(int x, int y){  int offsetMajor, offsetMinor;  Direction direction = getDir();  if (direction == left)  {    offsetMajor = getPosX() - x;    offsetMinor = abs(getPosY() - y);  }  else if (direction == right)  {    offsetMajor = x - getPosX();    offsetMinor = abs(getPosY() - y);  }  elseif (direction == up)  {    offsetMajor = getPosY() - y;    offsetMinor = abs(getPosX() - x);  }  else if (direction == down)  {    offsetMajor = y - getPosY();    offsetMinor = abs(getPosX() - x);  }  return offsetMajor >= 0 && offsetMajor <= getSightRange() && offsetMinor <= offsetMajor;};Quote:Original post by transformationDoes the getDir give an unfair advantage to a scripter? Is it information that should not be given? oh and why?No, and yes.Because the bot shouldn't *care* which way it's facing.Do you need a compass to navigate your way out of a building? No, you make decisions to turn (and go down stairwells, etc.) based on *relative* direction.