Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 May 2001
Offline Last Active May 03 2011 03:22 PM

#4803028 Should all of the agent's rays be of the same length?

Posted by on 26 April 2011 - 06:41 AM

If the distance to the object is farther, your rate of turn can be slower.

but the jerky movement still occurs with a slower turn rate, as shown in the last video.

Could the following line cause a problem:

avoidance -= agent.Velocity;

I ask because it is not included in the OpenSteer source code but causes the agent to move way too fast without it.

Well, steering shouldn't make you accelerate over your maximum velocity. Everytime I've written a steering component (it's been a while though, so I might be missing some details) I made it return 2 things:
1) heading
2) braking factor

The braking factor can be optional, depending on the feel you want to have. In the examples you showed, you just need to modify the heading of your cube.

If I understand correctly in the code you posted destForward is steeringForce? If so, from what you posted you only use it to calculate a turn angle, how would it make the agent move way too fast? Have you tried clamping your velocity to your max velocity?

#4793935 Neural Networks book for newbies.

Posted by on 03 April 2011 - 02:31 PM

Probably because the name sounds cool, like genetic algorithms :)

#4786753 fingerpaint

Posted by on 16 March 2011 - 03:27 PM

i want to make a fingerpaint app for ipad. can someone tell me how to detect a drag event on ipad?

i basically need to get these for the drag event


I never developed for iOS but this should be one of the basic event you can handle and it's for sure in the documentation... did you search for more than 30 secs before posting here? ;)

#4784054 XY Map class

Posted by on 10 March 2011 - 11:11 AM

In the past I have been using a 2 dimensional array to store my map structure like so:

struct MapInfo
int tile;
int blah;
MapInfo MyMap[x][y];

I want to try to move this into a class so I can easily pass around a pointer to a specific location to various classes that would need it, I started with this, but I cannot figure out how to insert and access the locations properly, I think it may just be too early for me to wrap my mind around what im doing.

Below is sort the route that I was trying to go, but as you see the way X and Y map locations are added, (and accessed) I can't figure out a way to add them in the correct order to my vector, and then be able to access them correctly by just specifying a x and y location.

I know my logic as below is completely flawed but I figured posting what I was trying to do would make more sense than explaining it, thanks!!


#ifndef MAPCLASS

#define MAPCLASS

/*------------------------------------------------------------------------------------------------- */
/*  this class Deals with our map data													             */
/*																									*/
#include <vector>
#include <iostream>
using namespace std;

class MapTile
		int x;
		int y;
		int iCurrentTileGraphic;	//Tile in this location
		int iOriginalTileGraphic;	//this was the tile we started with (for animation)
		int Lighting;				//Lighting value associated with this tile
		int Alpha;					//Transparency value
		bool Blocked;				//If this tile is blocked or not

class MapInfo
		vector <MapTile> TileLoc;				//this stores all of our map info	
		MapTile* GetMapLocPtr(int X, int Y);	
		void CreateMap(int Xsize, int Ysize);	//Creates a map with X*Y size


#include "Map.h"

MapTile* MapInfo::GetMapLocPtr(int X, int Y)
	int TileNum = X * Y; //get our tile location (problem here)

	if(TileNum < (int) TileLoc.size() || TileNum < 0) //make sure its in bounds
		return &TileLoc.at(TileNum);

	else //else this is out of range
		cout << "Tried to access a out of range map location: " << X << " - " << Y << " = " << TileNum << endl;

	return NULL;

void MapInfo::CreateMap(int Xsize, int Ysize)	//Creates a map with X*Y size
	int MapSize = Xsize * Ysize; //get our tile location
	TileLoc.reserve(MapSize +1); //reserve enough memory space

	for(int x=0;x<Xsize+1;x++) //(problem here)
		for(int y=0;y<Ysize+1;y++)
			MapTile NewTile;
			NewTile.Alpha = 0;
			NewTile.Blocked = false;
			NewTile.iCurrentTileGraphic = 0;
			NewTile.iOriginalTileGraphic = 0;
			NewTile.Lighting = 0;
			NewTile.x = x;
			NewTile.y = y;
			TileLoc.push_back(NewTile); //add to struct

	cout << "Created map with: " << MapSize << " Members" << endl;
	cout << "TileLoc contains: " << TileLoc.size() << endl;

Part of your problem (i didn't read the entire code) is that your TileNum should be something like X + Width * Y;

Also, when you reserve your array you can then simply index it so when adding new tiles you'd use the same X + Width(Xsize) * Y to access elements of your vector.

Hope this helps

#4782841 Recommended Ai Books And Sites

Posted by on 07 March 2011 - 09:29 AM

If I can add to this:

http://www.cgf-ai.com/products.html William Van Der Sterren's web site (he's known for his terrain analysis)
http://red3d.com/cwr/steer/ Craig Reynold's "Steering Behaviors For Autonomous Characters", useful for anyone implementing steering
http://generation5.org/ The website is pretty much dead but it still contains tons of interesting articles
http://www-cs-students.stanford.edu/~amitp/gameprog.html Amit Patel's page on game programming, contains interesting information on path finding