Some problems in dev AI Java

Some problems in dev AI Java

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Some problems in dev AI Java

Post by Zyre »

Hello, I'm new here, I am Brazilian, a student of computer science, I'm developing an AI in java for my course conclusion work, but i'm facing some problems regarding the options of the Java interface, for example, when trying to access the functions of the class through a MoveData UnitDef simply closes the game, I can only access this information if an instance of Unit already exists, for example the commander who already starts with the game through the transferred Unit UnitFinished I access MoveData, I'm doing something wrong or is it anyway?
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Some problems in dev AI Java

Post by abma »

is there an error message in infolog.txt about it?

afaik units have to be in Line of Sight if you want to access unitdef data.

maybe http://springrts.com/wiki/AI:Developmen ... definition helps?
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

nops, what i try to do is:
OOAICallback.getUnitDefs().get(x).getMoveData().getMoveType();

is to do a table of units, a build table...
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Some problems in dev AI Java

Post by hoijui »

man.. we have asked for infolog.txt two times now (he first asked me in PM), and you still did not manage to give it?
be a bit more attentive when asking for help, k?
that is part of the basic respect one should give when requesting (free) help.
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

sorry guys, i was no intention of desrespecting anyone, i was in no possession of the infolog at the time, i have work and studie duties too like yours and i thought I had made ÔÇïÔÇïa mistake in the code, anyway, now i can show the infolog.txt
http://pastebin.com/EB39K9Qw
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

I came to the conclusion that I can only access information from MoveData after the units were instantiating / created in the game, but what I wanted was to catalog all the information from all units at the beginning of the game, a table unit as well as many AI `s already do, however MoveData has definitions that would be important to be accessed freely, as the type of movement (to know what kind of unity is, even a function "isSubmarine" and I can't use it) I believe this information is not accessible because they are regarded as cheats (in infolog.txt has a line that tells something similar) or because they are directly linked to instantiate class "Unit ", I'm wrong or completely wrong?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Some problems in dev AI Java

Post by hoijui »

hmm.. can you probably give the AI project? or something i can paste into NullJavaOOAI that generates the same error.
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

the simple command of getting the OOAICallback of the class Factory and:int i = 0;
i = OOAICallback.getUnitDefs().get(0).getMoveData().getMoveType();
this will crash the game
(Obs: getMoveType return int.. in the Javadoc.. )
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Some problems in dev AI Java

Post by hoijui »

Code: Select all

			List<UnitDef> unitDefs = callback.getUnitDefs();
			for (UnitDef unitDef : unitDefs) {
				MoveData moveData = unitDef.getMoveData();
				if (moveData != null) {
					int moveType = moveData.getMoveType();
					System.out.println("move-type of unit[" + unitDef.getName() + "]: " + moveType);
				}
			}
This works perfectly for me in spring master.
Old versions will not be patched anymore anyway. Make sure you do not get a NullPointerException, and if it is really an engine/AI Interface problem, it is solved already (proved by this code example).
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

here the problem have persistence, i am using Spring 0.82.7.1, not the master version, maybe could be this...? =/ i will try ohter things.. thanks anyway
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Some problems in dev AI Java

Post by hoijui »

yes, i am pretty sure that can make a difference.
as i can not roll out fixes for an already released version, and as there will not be an other bugfix release for this version (very very likely not, at least), it makes no sense to investigate this further. if you know a workaround, even if it is ugly, use it, and document it properly in your code, so you can remove it once there is a new spring release.
Zyre
Posts: 20
Joined: 18 May 2011, 21:56

Re: Some problems in dev AI Java

Post by Zyre »

yes, thanks =D
Post Reply

Return to “AI”