I'll try to check your code once I get home, but from your last post + the one with the "WhoIsAt" code, I guess you've come up with something that can be viable.
As for scanning the whole grid, I'd seriously recommand that you build a list with your robots, and store references to these robots into the grid, but when selecting which robot should act, simply go through the robots list... no need to process empty grid nodes even if it's just testing its content.
How can my robots "see" what is next to them?
Quote:
Original post by xEricx
...
...
no need to process empty grid nodes even if it's just testing its content.
...
...
This is part of my point.....it is what I mean by my code being so CLUMSY.
It is the Robots that I am interested in....not empty space...I should not have to go SQUARE by SQUARE by SQUARE...what a waste!!!
Nor should the Robots have to wait to be acted upon...but rather they should act for themselves.
Rather than going through each cell and seeing if there's a robot there, keep a list of all X/Y coordinates at which there is a robot. The robots needn't know the entire world map; they can just call some function to tell them what's in front of them, behind them, etc.
---------------------------------dofile('sig.lua')
What you are doing is extremely complex, firstly you dont have a completed simulation but want to move on to AI&Pathfinding (although i agree a basic A* Algorithm is the best place to start)
Now you want a human player to use the keyboard and be able to play the game first before moving on to the AI..
Now the AI that you want to do is damn complex, it involves LEARNING and mutally exlusive LEARNING in this case since robots dont share there knowledge.
You also want ppl to program their own ai and plug it into the code, and thats where the proble comes in with the CHEATING thing.
A solution is to have a script on-top of your code for example a state machine which the programmer can then set.
Event-->Condition-->Action
Example:
UnderFire-->Can move to safety & doesnt contradict other logic-->Move to safety
And then further the AI will handle exactly where this SAFETY is and how to get there and so on.
Now you want a human player to use the keyboard and be able to play the game first before moving on to the AI..
Now the AI that you want to do is damn complex, it involves LEARNING and mutally exlusive LEARNING in this case since robots dont share there knowledge.
You also want ppl to program their own ai and plug it into the code, and thats where the proble comes in with the CHEATING thing.
A solution is to have a script on-top of your code for example a state machine which the programmer can then set.
Event-->Condition-->Action
Example:
UnderFire-->Can move to safety & doesnt contradict other logic-->Move to safety
And then further the AI will handle exactly where this SAFETY is and how to get there and so on.
----------------------------http://djoubert.co.uk
Quote:
Original post by HyperHacker
Rather than going through each cell and seeing if there's a robot there, keep a list of all X/Y coordinates at which there is a robot. The robots needn't know the entire world map; they can just call some function to tell them what's in front of them, behind them, etc.
I am headed in this direction, I hope.
Quote:
Original post by dawidjoubert
What you are doing is extremely complex, firstly you dont have a completed simulation but want to move on to AI&Pathfinding (although i agree a basic A* Algorithm is the best place to start)
Now you want a human player to use the keyboard and be able to play the game first before moving on to the AI..
Now the AI that you want to do is damn complex, it involves LEARNING and mutally exlusive LEARNING in this case since robots dont share there knowledge.
You also want ppl to program their own ai and plug it into the code, and thats where the proble comes in with the CHEATING thing.
A solution is to have a script on-top of your code for example a state machine which the programmer can then set.
Event-->Condition-->Action
Example:
UnderFire-->Can move to safety & doesnt contradict other logic-->Move to safety
And then further the AI will handle exactly where this SAFETY is and how to get there and so on.
Yes...some sort of script would be fantastic (eventually).
Quote:
Original post by Anonymous Poster
I started doing programming like this 30 years ago.
Diections 0-7 0=North 1=NE 2=E etc... (4th quadrant coord system)
INT delta_x[8] = {0,1,1,1,0,-1,-1,-1};
INT delta_y[8] = {-1,-1,0,1,1,1,0,-1};
now you can compare and refer to directions as a positional relation and apply it to movement or a facing, etc...
object.move(INT dir) // move an object along a direction
{
object.x = object.x + delta_x[dir];
object.y = object.y + delta_y[dir];
}
to check if something is in the grid position adjacent to the object ::::
for (dir = 0; dirMAXGRID_X-1) goto OFF_GRID;
if (testxMAXGRID_Y-1) goto OFF_GRID;
if (testy<
Here is what I have so far.
I am not sure I understand the "OFF_GRID" stuff:
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace TestAI{ public enum Dir { N = 0,NE,E,SE,S,SW,W,NW } public class Robot : Object { public Square _current_square; public Square _min_square; public Square _max_square; int[] delta_row = new int[8] {-1,-1,0,1,1,1,0,-1}; int[] delta_col = new int[8] {0,1,1,1,0,-1,-1,-1}; public Robot(int initial_row, int initial_col, int min_row, int max_row, int min_col, int max_col) { _current_square = new Square(initial_row,initial_col); _min_square = new Square(min_row,min_col); _max_square = new Square(max_row,max_col); _status_icon = Image.FromFile(_ROBOT_IMAGE_PATH); _kind = "robot"; } private ArrayList _squares_visited = new ArrayList(); //CONSTANTS private const string _ROBOT_IMAGE_PATH = "images\\robot.bmp"; //CONSTANTS public string _name; public bool _has_moved = false; public int Row { get{return this._current_square._row;} set { if((value >= this._min_square._row) && (value <= this._max_square._row)) { this._current_square._row = value; } } } public int Col { get{return this._current_square._col;} set { if((value >= this._min_square._col) && (value <= this._max_square._col)) { this._current_square._col = value; } } } public void Move(int Dir) { this._current_square._row += delta_row[Dir]; this._current_square._col += delta_col[Dir]; _has_moved = true; } }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement