Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: spyfox on Fri 21/12/2007 10:56:50

Title: robot fight
Post by: spyfox on Fri 21/12/2007 10:56:50
i want to make a game like "java robots" and "c robots"
the idee:
2 programs (robots) fight into an arena
the robots are 2 txt files and the game detect the txt files
into the txtfiles you put something like:

int destination_x
int destination_y

scan(enemy)
shoot(enemy_x,enemy_y)
move(destination_x,destination_y)
if (robot_damaged){
destination_x+36
destenation_y+55
}

(this is a very simple example: it can't shoot the enemy,the enemy moves also and this robot can't hit)

you must avaible to scan 2 times and measure the course of the enemy.
functions:
function shoot
function scan
function move

i dont know howto begin
Title: Re: robot fight
Post by: Ashen on Fri 21/12/2007 11:43:02
If you haven't already, a good place to begin would be getting to know the File functions and properties (http://www.adventuregamestudio.co.uk/manual/File%20functions%20and%20properties.htm). If you're going to be reading/writing to text files, you're going to need them.

You can't import code from a text file directly into AGS and have it run like AGS code. However you can read a line back from the file, check if it contains a specific word (lke 'shoot', 'scan', etc) and run the approriate code from, that. I've done something similar in the AGSConsole module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=32787.0), you'd just need to change the functions (GetAtIndex, StrAtIndex, GetCommand) to get their input from a file instead of a TextBox. This'd mean you could develop your own syntax for programming the robots in the file, instead of sticking to an AGS-like format as in your example. RickJ's IniFile module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22599.0) (if it's currently working ... depends on what AGS version you're using, I think) might help here, by giving you an existing structure to work in.


What's the point of using the text files, anyway? I guess external files would allow players to customise their robots, but I think you'd be able to do that within the game as well. E.g. by having a GUI to select what order to run commands, tweak parameters, etc. You should be able to 'export' the 'bots to a text file to play on other PCs, but that file wouldn't need to be human-readable or writable, making the whole thing a little easier, IMO.
Title: Re: robot fight
Post by: spyfox on Fri 21/12/2007 12:21:50
yes, good idea.
i think i go working with gui and import/export txt files.
and i want to have  an arena with obstacles. how can i scan th obstacles ?
Title: Re: robot fight
Post by: Gilbert on Fri 21/12/2007 12:45:01
I'm not quite sure whether this thread fits here, but I think the following sentence means that you would have better chance of having more answers if this is in the Beginners' Tech. forum, so I'll move it.

Quote from: spyfox on Fri 21/12/2007 10:56:50
i dont know howto begin