I posted my code along with the assignment issue here: http://www.daniweb.com/forums/thread121468.html

I apologize I overlooked the Game Dev section.

In short, the assignment is:

Implement a Goal Oriented AI system. The system should include C++ objects that implement Goals, Actions and Tools. Use the programming example for Chapter 3 as a model and framework.

Implement the following scenario:

Goal 1 - Obtain food.
Goal 2 - Obtain coins.
Goal 3 – Obtain metal detector.
Goal 4 – Obtain rifle.

Action 1 – Search for coins. Requires metal detector.
Action 2 – Hunt rabbit. Requires rifle.
Action 3 – Pick up metal detector.
Action 4 – Pick up rifle.

Tool 1 – Metal detector.
Tool 2 – Rifle.

I am looking for a simpler way to approach the assignment. I figure each goal could be split into a function, then each action could go with the appropriate function, but how do I use the tools to reach each goal?

Also, some goals require you to search for the nearest item, how can I do that if I do not have a pathfinding algorithm to use to find the items?

The book I am using for the class is "Game Development Essentials: Game Artificial Intelligence" by John B ahlquist Jr. and it does not state any information about how to plot items on a map. Anyone know anything about this?

I am not looking for someone to tweak my code as I think I will just start from sratch. However, any help to the questions above is much appreciated.

Thanks,
Danny

Stick with 'standard' goal-oriented action planning techniques; the method you're starting to write ( based on your other thread ) won't scale well to finding a general solution to a general problem.

Do you even need to consider locality of objects ( i.e. actually moving between them ) or just provide the action sequence necessary in order to fulfil the top-level goal? By that I mean, a valid response from one goal planner could be:

kill rabbit := pick up rifle -> shoot rabbit

and from another, different planner, it could be:

kill rabbit := move 1,0 -> move 0,1 -> pick up rifle -> move 0,-1 -> rotate 90 -> fire rifle.

in the first case, the planner spits out abstract commands and expects some other layer to solve the task itself; in the second case, the planner does everything including actuate movement itself.

I guess, the question is, how 'useful', or how complete do you want the output to be?

To make it more complete, you need a more complete specification of the pre-requisite/post-requisite/action set, and you need a somewhat complex symbol-based planner. ( See STRIPS for example, papers for the STRIPs solver implementation are easy to find, and it's not that difficult to implement ).

For a less complete solution, you can almost do without a specialized planner atall ( you can represent the problem as a directed/undirected graph, and use a tree-search/graph-search to get the shortest path between start node and goal node, by equivalence, this represents the optimum action path ).

So far, with what I have, a two dimensional array displays a playing field and my player along with coins, rifle, etc. displayed using using numbers. Problem is, when trying to hunt for a rabbit with the HuntForRabbit() function, the program displays a map for every run through the loop but it does not update any of the values. Can someone hint me in the right direction of updating the values so that the player moves to the object (number to number)? Also, I would like to know how to update the map in place rather then displaying a new map each time the program makes a pass through the loops in the HuntForRabbit() function. I hope this makes sense. Thanks in advance.

//Final Project - Option 1

#include <iostream>
#include <ctime>


using std::cin;
using std::cout;
using std::endl;

void DrawMap();
void HuntForRabbit(int &, int &, int &, int &);



int mapArray[25][25] = {0};


int main()
{
		
	//key
	cout << "------------------------------------------\nKey\n------------------------------------------\n1.Rabbit = 2\n2.Coin = 3\n3.Rifle = 4\n4.Metal Decector = 5\n5.Player = 9\n------------------------------------------" << endl << endl << endl;
	//map
	cout << "Level 1: " << endl;
	
	for (int x = 0; x < 25; x ++)
	{
		mapArray[0][x] = 1;
		mapArray[24][x] = 1;
	} //end for
	for (int x = 1; x < 24; x ++)
	{
		mapArray[x][0] = 1;
		mapArray[x][24] = 1;
	} //end for

	
	//starting point of charecter
	srand(static_cast<int>(time(0)));
	int charecter = 9;
	int charecterX = 1 + rand() % (23 - 1 + 1);
	int charecterY = 1 + rand() % (23 - 1 + 1);
	mapArray[charecterX][charecterY] = charecter;
	
	//inset rabbit
	int rabbit = 2;
	int rabbitX = 1 + rand() % (23 - 1 + 1);
	int rabbitY = 1 + rand() % (23 - 1 + 1);
	mapArray[rabbitX][rabbitY] = rabbit;
	//inset coins
	int coin = 3;
	int coinX = 1 + rand() % (23 - 1 + 1);
	int coinY = 1 + rand() % (23 - 1 + 1);
	mapArray[coinX][coinY] = coin;
	//insert rifle
	int rifle = 4;
	int rifleX = 1 + rand() % (23 - 1 + 1);
	int rifleY = 1 + rand() % (23 - 1 + 1);
	mapArray[rifleX][rifleY] = rifle ;
	//insert metal detector
	int metaldet = 5;
	int metaldetX = 1 + rand() % (23 - 1 + 1);
	int metaldetY = 1 + rand() % (23 - 1 + 1);
	mapArray[metaldetX][metaldetY] = metaldet ;

	
	
	//draw map
	DrawMap();

	//menu
	char choice = ' ';
	cout << endl << endl << endl;
	cout << "Please choose from the following options:\n------------------------------------------\nA - Hunt for wabbit.\nB - Hunt for coins.\nC - Look for rifle.\nD - Look for metal detector.\n------------------------------------------" << endl;
	cin >> choice;
	choice = toupper(choice);
	cout << "------------------------------------------" << endl;
	
	switch (choice)
	{
	case 'A':
		cout << "You selected: Hunt for wabbit." << endl;
		HuntForRabbit(charecterX, charecterY, rabbitX, rabbitY);
		break;
	case 'B':
		cout << "You selected: Hunt for coins." << endl;
		break;
	case 'C':
		cout << "You selected: Look for rifle." << endl;
		break;
	case 'D':
		cout << "You selected: Look for metal detector." << endl;
		break;
	default:
		cout << "You selected: Invalid menu option" << endl;
	} //end switch
	
	cout << "------------------------------------------" << endl;

	


} //end of main function
// ****** function definitions *******
void DrawMap()
{
	//draw map
	for (int r = 0; r < 25; r ++)
	{
		for (int c = 0; c < 25; c++)
		{
			cout << mapArray[r][c];
		}
			cout << endl;
	} //end for
} //end DrawMap
void HuntForRabbit(int &charecterX, int &charecterY, int &rabbitX, int &rabbitY)
{
	do 
	{
		if (charecterX > rabbitX)
		{
			charecterX--;
		}
		if (charecterX < rabbitX)
		{
			charecterX++;
		}
		if (charecterY > rabbitY)
		{
			charecterY--;
		}
		if (charecterY < rabbitY)
		{
			charecterY++;
		}
		DrawMap();
	}
	while (mapArray[charecterX][charecterY] != mapArray[rabbitX][rabbitY]);

} //end of HuntForRabbit function

since you reposted your code I deleted the post on the c++ board.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.