Jump to content


Photo

Alien Ai Implementation And Integration


  • Please log in to reply
74 replies to this topic

#1 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 14 June 2005 - 08:33 AM

After a nice chat with rincewind, we have come with following idea about the overmind ai ,craft movement etc:

We will have four different code module:
1) Alien AI (the overmind) (lua)
2) Player Detection Layer (PDL) (propably c++)
3) Player AI (propably lua)
4) UI Interface (propably c++)

Alien AI (the Overmind)
Overmind behaves with few counters. There will be counters like "I need food", "I need new alien base" etc. When a counter reaches a critical state (or by a random event), it will trigger a task. There can be multiple task running at the same time.

A task can be Terror mission, New alien base etc.
Here is an example about a terror mission:
1: Spawn a scout into an area (This creates a craft mission, more about this later)
2: If failed (craft was shot down etc) goto 1. If failed too many times, abort task
3: Spawn bigger ship to finally lock the target
4: If failed, goto 1. If failed too many times, abort task
5: Spawn the main terror ship onto the target
6: If failed, goto 1. If failed too many times, abort task
7: Task completed, go and have a drink.

Alien bases will have their own "little overmind" so that they can emit tasks by themselfs back to the overmind ai (when base commander needs a good beef and a Pan Galactic Gargle Blaster, and the storages are out, it will spawn a supply task ;)

Craft mission
Alien AI will spawn an alien ship into the planetscape, sets some variables, like ship type, race, target, mission behaviour etc.

Mission Behaviour
This code does the actual flight of the craft (straight into the target zone | do a zig-zag to cover as much area as possible, slow down when near target area etc)

Player Detection Layer (PDL)
This is a code (propably c++) which handles the craft detection, radars etc.
Periodically it will be called and it will try to detect alien crafts which are in the planetscape and under radar coverage.
When it detects, it does the following:

1: Create a GlobeIcon
2: Pass the detected alien Craft object into the GlobeIcon. The Craft object implements a PositionSource interface so that when the Craft moves, it will automaticly update the GlobeIcon via a callback. The GlobeIcon automaticly does the needed registration with UI module so that the GlobeIcon is visible in planetscape
3: Pass a pointer of the GlobeIcon back to the Craft (when craft is invisible, this pointer will have NULL) so that it can be later destroyed when craft goes out from radar coverage.

On every frame, the PDL is also called to check if a Craft has moved outside radar coverage. When this happends, it destroys the GlobeIcon instance.

Player AI
This handles the player craft mission behaviour. This will have only a simple "try to catch the target and destroy it" behaviour, but in Post V1 this could also have some other behaviours, like a patrol behaviour when a craft can patrol a selected area which is not naturally coverred by base radars.

UI Interface
This handles GlobeIcons and other similar stuff which are presented in the planetscape (alien bases, terror site icons etc)

GlobeIcon
This is an object which represents an icon in the globe. It can, for example, follow an object which implements the PositionSource interface.



- Garo =)

#2 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 14 June 2005 - 09:34 AM

My very first UML graph ever! Please point me for UML usage errors =)

Posted Image

- Garo

Edited by Garo, 14 June 2005 - 09:38 AM.


#3 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 14 June 2005 - 10:43 AM

I would first model the classes relationship and objects resposabilities instead of concentrate first on the behaivioral model. Your scheme in the first post explain the rationale and how it should work, but do not use an straight mapping, to do the modelling.

Try to create a basic object layout and how they relates and assign the cooresponding responsability to them... then it will become far cleaner. (I may send you a couple of 400 pages articles about Object Responsabilities :devillaugh: if you want).

This is actual review from Kikanaide (my recruit who was required to read it before starting to work on Xenocide ;) ), so it is for real :) : "So, I finally finished the first book. I had to take it in short increments once I got into it...I discovered that if I wanted to understand it I had to actively think through it and I could only do that for a couple sections in a day. It made me realize just how not-OO the simulation program I work on is."

Those that wants it, just let me know.

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#4 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 14 June 2005 - 12:24 PM

And for the public demand, here we have some (but not all) of the AI classes. These will be (mostly) C++

Posted Image

- Garo

#5 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 14 June 2005 - 01:16 PM

Now write down the responsabilities given to all those objects. Easier to say than done, but it pay off in the long run.

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#6 mikker

mikker

    Artwork Department

  • Xenocide Artwork Department
  • 2,211 posts

Posted 14 June 2005 - 04:01 PM

A task can be Terror mission, New alien base etc.
Here is an example about a terror mission:
1: Spawn a scout into an area (This creates a craft mission, more about this later)
2: If failed (craft was shot down etc) goto 1. If failed too many times, abort task
3: Spawn bigger ship to finally lock the target
4: If failed, goto 1. If failed too many times, abort task
5: Spawn the main terror ship onto the target
6: If failed, goto 1. If failed too many times, abort task
7: Task completed, go and have a drink.

Hmmm.... wouldn't this make the overmind appear stubborn? I mean, one scout after another.... The player might even be able to set up 'traps', by moving in the craft into the repeated area. What about the scout, if failed mission, choice another destination, and not went to the same place over and over? Those areas might give off same ammount of goodies, and with the posibility of there NOT being a craft to conquer it this time arround. Will also make it appear to the player that there is a diversity in the Overminds actions.

Some people say that dreams are a portal to the subconscious. If that is so, I am a very disturbed person.

the truth about scientology

#7 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 14 June 2005 - 11:46 PM

Hmmm.... wouldn't this make the overmind appear stubborn? I mean, one scout after another.... The player might even be able to set up 'traps', by moving in the craft into the repeated area. What about the scout, if failed mission, choice another destination, and not went to the same place over and over? Those areas might give off same ammount of goodies, and with the posibility of there NOT being a craft to conquer it this time arround. Will also make it appear to the player that there is a diversity in the Overminds actions.

<{POST_SNAPBACK}>


This was only a very simple example. The task will be scripted with lua, so we can create very complex task scripts as we need to. We can, for example, use functions which gets suitable target areas, use random starting points for the craft, adjust the flight path according to incoming player interceptors, launch dummy scout ships to cover the real mission craft and so on.

The task script runs in a different lua thread. This means, that the task is a linear lua function.
Here is a raw pseudocode example. There are yet no real helper function implementations, but it could look something like this:

function terrorMission()
  -- Init counters
  count = 0
  taskRestartCount = 0;

  -- Start of the task
  start:

  -- Abort whole task if it has been restarted too many times
  taskRestartCount++;
  if (taskRestartCount > 3) {
    return false; -- Task failed
  }
  do {
    -- Get a random target area and send a small scout there
    target = targetZoneFactory:getRandomTargetZone();
    craftType = StaticData.CraftTypeFactory:getItem("SMALL_SCOUT");
    missionType = -- to be done
    mission = spawnMission(target, craftType, missionType);
    mission:wait(); -- Wait until the mission is completed

    count++;
    if (count > 3)
      return false; -- abort task, task failed

    sleepHours(2, 5); -- Sleep random time (anything between two and five hours) before continuing the task
  } while (!mission:success());

  -- Send a medium scout which will land near the target area
  craftType = StaticData.CraftTypeFactory:getItem("MEDIUM_SCOUT")
  missionType = missionFactory:getLandingMission();
  mission = spawnMission(target, craftType, missionType);
  mission:wait();

  if (mission:failed()) {
    goto start; -- Mission failed, restart the whole task
  }

  sleepHours(1, 3); -- Sleep before sendin the final terror ship. At least one hour, but not more than three hours

  -- Final mission: send a terror ship to the target.
  target = targetFactory:getNearbyCity(target); -- Get nearest big city of the target
  craftType = StaticData.CraftTypeFactory:getItem("TERROR_SHIP")
  missionType = missionFactory:getTerrorMission();
  mission = spawnMission(target, craftType, missionType);
  mission:.wait();

  return mission.success(); -- Return if the task was a success or not
end

This is just an example, but it will hopefully show some idea how we can implement complex tasks with enough random events or smart avoiding of traps (like using different target location) to gain better success ratio :)

- Garo

edit: I'll update this script as I have implemented the actual code, so this script will be an example how the real code will work =)

Edited by Garo, 17 June 2005 - 02:41 PM.


#8 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 15 June 2005 - 01:03 AM

Class responsibilities:

Simulation <Singleton>
This class handles the simulation. It will call several lua script functions once every frame or so and with some timer parameters, the scripts can know how much time has elapsed after last run.
The simulation will also have callback timer functions (also accessible from lua), so that we can easily schedule a function (both c++ and lua) to be executed in certain time.

Simulation will also hold one instance of TaskManager and MissionManager. It wiill call both of these classes perodically.

TaskManager
This class creates new tasks and destroys completed or aborted tasks. It will not pass task result data back to overmind scripts (it's Task instance responsibility) It will also call every task once a while when Simulation decides so.

Task
This is a C++ class which reprsesents one Task. It creates the needed lua thread and starts the execution of the task lua function. It will be perodically called by TaskManager so that the task script can procees. Task will hold helper functions to aid the lua task script and it will pass task result data back to overmind ai script.

MissionManager
MissionManager will hold all Missions which are currently running. It will be called by Simulation, so that the independent Missions can run their lua scripts (like MissionBehaviour). A new Mission is sent to the MissionManager upon it's creation (for example, by the Task helper functions). Once a mission is done, the Mission notifies MissionManager so that it can remove and cleanup the Mission.

Mission
Mission is a single craft mission which happends in Planetscape. Mission carries a Craft object, which is a representation of a Craft (Alien or Player craft). Mission will have callback functions (propably lua scripts) which will be called upon certain Mission events (like craft reached target zone, craft landed, craft destroyed, craft under attack, craft was unable to reach target zone, craft out of fuel etc etc) Mission will report it's status back to it's creator using callback when the mission is completed or failed. After this, the Mission will tell MissionManager that it's done and MissionManager destroys the Mission.

Craft
This is a craft =) There will be PlayerCraft and AlienCraft classes delivered from this, but Craft has all the needed methods. Craft knows it's shipType, it's race and it's MissionBehaviour among other things. Craft can be asked to fly() (or something) and it calls selected MissionBehaviour to move the craft. Craft also implements PositionSource interface, so that it can be assigned to other objects which can then track the craft (for example, a GlobeIcon will track the craft so that the GlobeIcon will move in the Planetscape when the vraft moves)

MissionBehaviour
This is a class which contains a set of functions which will fly the craft. There will be several different MissionBehaviours. Player crafts will usually simply use "follow-target-and-destroy" -behaviour, but alien crafts can use many others, like "scout selected target area with a zig-zag pattern", "fly over target area very fast", "fly very fast towards target area, once near, slow down the craft and do a fly-by and then accelerate and escape back into orbit" (this can be used to verify a base attack target, for example), "seek this area for good targets", "patrol this area and attack all incoming units", "guard this craft and attack all incoming units"....


More later, any suggestions? =)

- Garo

#9 mikker

mikker

    Artwork Department

  • Xenocide Artwork Department
  • 2,211 posts

Posted 15 June 2005 - 03:58 AM

Okay. Seems like this Lua thing is pretty flexible. Nice thing :)

Some people say that dreams are a portal to the subconscious. If that is so, I am a very disturbed person.

the truth about scientology

#10 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 16 June 2005 - 11:27 AM

Small progress report:

After a nearly four hour chat with guyver6, we have designed quite clearly the class structure and their relations.

I also have first TaskManager and Task instances working! I can add tasks (they are lua scripts) to the task manager, and it runs them when I ask it to (I call taskManager:run()). Once the task is completed (the task script returns), the task manager clears the task :)

EDIT: I grabbed the old Simulation framework from the archives, patched it a bit and attached it back to frameListener (it has enable_simulation setting, disabled by default), created methods to modify setting values from lua and created a simple lua function which toggles Setting<Bool> value true/false. The result: I can start and stop the simulation from a DebugButton and see from the console how the TaskManager executes the tasks :) :beer: and :goodnight:

- Garo

Edited by Garo, 16 June 2005 - 01:19 PM.


#11 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 21 June 2005 - 01:06 PM

Another progress report:

I'm now able to create a Mission from console which has a Craft inside it. The core is actually quite simple =)

   craftParams = CraftParams();
    craftParams.craftType = StaticData.CraftTypeFactory:getItem("CRAFT_MEDIUM_SCOUT");
    missionParams = MissionParams();
    missionParams.startingPosition = targetZoneFactory:getRandomTargetZone();
    missionParams.craft = Simulation:createAlienCraft(craftParams);
    mission = Simulation:createMission(missionParams);

    mission:wait(); -- wait until mission is executed or failed for some reason

The CraftParams ans MissionParams gives access to a number of adjustable properties (which are not implemented yet), like setting craft alien race. The only major thing what's missing from the code above, is selecting a MissionBehaviour, which will control the craft when it's flying (and how the craft will fly and behave in the air). Once this is done, we can launch crafts into the globe!

I'm now waiting for rincewinds GlobeIcon rendering patch, after that's done, I'll be soon able to see those ufos flying :)

- Garo

#12 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 29 June 2005 - 01:02 AM

Progress report =)

Got first version of MissionBehaviour ready, just a few more hours and I can actually get the alien craft moving in the Planetscape!

MissionBehaviour is a luabind class in lua, it does not have a C++ class. The actual behaviours will be delivered from this class via extending it and overwriting the base functions. Every MissionBehaviour will be in it's own .lua file, which name represents the class name. Here's the current code of MissionBehaviour:

class 'MissionBehaviour'

function MissionBehaviour:__init(craft)
    Console:echo("MissionBehaviour created");

    self.name = "Default MissionBehaviour";
    self.craft = craft;
end

function MissionBehaviour:test(arg)
    Console:echo("MissionBehaviour:test: " .. tostring(arg));
end

-- This is a placeholder update function which moves the craft as testing purphose.
-- Real movement will be done in some other function inside the delivered class.
function MissionBehaviour:update(timeStep)
    Console:echo("MissionBehaviour:update(update) called, " .. tostring(timeStep));

    position = self.craft:getPosition();
    Console:echo("current position is " .. tostring(position));

    endPoint = position:getEndpoint(0.1, 0.2);

    self.craft:setPosition(position);
end

And the tasks? The task is also a luabind class in it's own .lua file, named after the class name (like newalienbasetask.lua for NewAlienBaseTask. The executeMission will trigger the created Mission object to be executed inside MissionManager. There will be also a wait function inside Task, which can be used to wait until the started mission is completed. After that, the mission results can be obtained by the mission object.

Once the mission is started via executeMission, the Mission::update (a C++ function) will be called on each Simulation::update (called propably once each frame) and via that, the MissionBehaviour update is called so the MissionBehaviour can fly/move/whatever the craft.

class 'Task'

function Task:__init()
    Console:echo("Task created");
end

function Task:executeMission(mission)
    Console:echo("Task:executeMission: Starting mission");
    missionManager:enableMission(mission);
end

function Task:execute()
    missionBehaviour = MissionBehaviour();

    craftParams = CraftParams();
    craftParams.missionBehaviour = missionBehaviour;
    craftParams.craftType = StaticData.CraftTypeFactory:getItem("CRAFT_MEDIUM_SCOUT");
    craftParams.damage = 50; -- normaly damage is zero with new crafts
    missionParams = MissionParams();
    missionParams.startingPosition = targetZoneFactory:getRandomTargetZone();
    missionParams.craft = Simulation:createAlienCraft(craftParams);
    mission = Simulation:createMission(missionParams);
    Console:echo(tostring(mission));
  --  TaskBackend:yield();
    self.executeMission(mission);

end

taskWrapper = function()
    task = Task();
    task:execute();
    Console:echo("taskWrapper: done");
end

The taskWrapper function is needed for every Task class. for NewAlienBaseTask the function will be named as NewAlienBaseTaskWrapper. This function creates the Task class (inside the Task lua thread) and executes it. Once this function returns, the task is done and it's removed from TaskManager. New task can be created (currently via DebugButton callback, but later in Overmind lua code) like this:

params = TaskParams();
params.luaTaskFunction = "taskWrapper";
taskManager:spawnTask(params);

The spawnTask() will not block, it just creates the Task object and passes it to TaskManager for execution. It also returns immediately. The spawnTask will later return some Task object, which can be used to tracking the state of the task, but propably this will never be needed, because the Task are planned to be create-and-forget.

I'm hoping to get the patch from rincewind as soon as possible which corrects the GlobeIcon rendering, so I can better track how the craft is moving in the Planetscape. Currently, for some unknown reason for me (hopefully not unknown for rincewind ;), the GlobeIcon will be rendered "behind" the globe if it goes too near the poles :(

What do you think, any ideas, thoughts or questions if some feature will be implemented or not?

- Garo

#13 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 29 June 2005 - 01:19 AM

Hi,

this definitly looks promising, I can't wait to see crafts flying. Once I get my computer unpacked (I just moved to Paris downtown, yeah), I will get the commit ready for the bugfix.

Just a little note, in your MissionBehaviour script:

self.craft:setPosition(position);

should read:

self.craft:setPosition(endPoint);

right?

Rincewind
Posted Image

I love boost!!! The next best thing since the invention of C++.

#14 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 29 June 2005 - 01:33 AM

self.craft:setPosition(position);
should read:
self.craft:setPosition(endPoint);

<{POST_SNAPBACK}>


Hmm. true. That line of code has actually never been executed yet, but nice that you spotted that up :)

So you have already Internet connection at you new place? great :)

- Garo

Edited by Garo, 29 June 2005 - 01:35 AM.


#15 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 29 June 2005 - 02:23 AM

self.craft:setPosition(position);
should read:
self.craft:setPosition(endPoint);

<{POST_SNAPBACK}>


Hmm. true. That line of code has actually never been executed yet, but nice that you spotted that up :)

So you have already Internet connection at you new place? great :)

- Garo

<{POST_SNAPBACK}>

Nope, this is from work...

Rincewind
Posted Image

I love boost!!! The next best thing since the invention of C++.

#16 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 30 June 2005 - 02:03 PM

Oh yeah! Wanna see a flying ufo? :beer:

http://www.juhonkoti...lying-ufo.patch

Instructions:

1) Apply the patch
2) Open console and type "script task.lua"
3) Close console and click "toggle simulation"

- Garo

#17 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 01 July 2005 - 03:21 AM

rincewind told me that the patch was missing macros.h, so here it is: http://www.juhonkoti...nocide/macros.h

I'm going to the country side later today for the weekend, so see you all back in sunday evening/monday =)

- Garo

#18 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 01 July 2005 - 03:36 AM

rincewind told me that the patch was missing macros.h, so here it is: http://www.juhonkoti...nocide/macros.h

I'm going to the country side later today for the weekend, so see you all back in sunday evening/monday =)

- Garo

<{POST_SNAPBACK}>


Thanks for the missing file.

Have fun for the weekend.

Rincewind
Posted Image

I love boost!!! The next best thing since the invention of C++.

#19 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 05 July 2005 - 01:52 PM

Quick progress report:

Got a small and simple scout mission ready, the only thing missing is destroying the mission once MissionBehaviour decides that it has reached it's target. Maybe tomorrow... =)

- Garo

#20 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 05 July 2005 - 08:07 PM

Excelent work Garo =b

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#21 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 06 July 2005 - 01:13 PM

Having small problems now. Does anybody know any good way to track where a SharedPtr is currently in use? That's because I have hidden an Entity SharedPtr reference somewhere and I can't find it now when I need to destroy it :(

- Garo

#22 guyver6

guyver6

    Captain

  • Xenocide Programming Department
  • 599 posts

Posted 07 July 2005 - 02:12 AM

Take a look here. I've put that today.

Greetings,
Guyver
Posted Image
Sourceforge: guyver6
LinkedIn: Andrzej Haczewski
"A good business idea, they say, can be explained in one sentence. Similarly, each program entity should have one clear purpose."

Join #xenocide at irc.freenode.net.

#23 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 08 July 2005 - 10:59 AM

One image, multiple....

http://www.juhonkoti...5_195651279.png

Stay tuned =)

- Garo

#24 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 08 July 2005 - 03:38 PM

Here is the patch: http://www.juhonkoti...behaviour.patch

- Garo

#25 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 11 July 2005 - 08:41 AM

Should work now nicely.

Remind how to test it: type "script task.lua" in console, toggle simulation on with the first button and finally add an alien craft or two with the 3rd button :)

rincewind: There's some problems with the Geoposition calculation code, the craft stucks sometimes into the poles :(

- Garo

#26 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 11 July 2005 - 09:00 AM

Should work now nicely.

Remind how to test it: type "script task.lua" in console, toggle simulation on with the first button and finally add an alien craft or two with the 3rd button :)

rincewind: There's some problems with the Geoposition calculation code, the craft stucks sometimes into the poles :(

- Garo

<{POST_SNAPBACK}>

I know, there are a lot of issues at the poles. I'll look into them though.

Rincewind
Posted Image

I love boost!!! The next best thing since the invention of C++.

#27 Kikanaide

Kikanaide

    Creative Text Department

  • Xenocide Creative-Text Departmen
  • 215 posts

Posted 11 July 2005 - 09:41 AM

As of last night (revision 590 I think) the macros.h file was still missing from the SVN...could we get that in there? I can download it by hand but since the SVN won't compile without it...Speaking of which, I'm having some other troubles with the SVN version...rincewind, would you like a list?
Kikanaide - "What does it mean? Don't ask."

#28 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 11 July 2005 - 10:34 AM

As of last night (revision 590 I think) the macros.h file was still missing from the SVN...could we get that in there?

<{POST_SNAPBACK}>


guyver6 added it a minute ago, thanks =)

- Garo

#29 guyver6

guyver6

    Captain

  • Xenocide Programming Department
  • 599 posts

Posted 11 July 2005 - 10:34 AM

Damn, I'm blind. Haven't noticed that for such long period. Gotta check out with my optic :D

Anyway, it's commited.

Guyver
Posted Image
Sourceforge: guyver6
LinkedIn: Andrzej Haczewski
"A good business idea, they say, can be explained in one sentence. Similarly, each program entity should have one clear purpose."

Join #xenocide at irc.freenode.net.

#30 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 20 August 2005 - 12:13 PM

New Issue added regarding this task:

http://bugs.projectx....php?bug_id=155

Greetings
Red Knight

Edited by red knight, 20 August 2005 - 12:13 PM.

Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#31 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 21 August 2005 - 01:25 AM

Just committed a big update on the ai/craft flight and task handling code. Hopefully I didn't miss any files and the svn still compiles.. anyone can verify? =)

To test this:
"script task.lua" in console
scroll the planetview over antarctica
spawn new task -button
toggle simulation -button

A craft should appear and it starts to fly towards south pole. Once it reaches a certain point, it goes bersek and destroys himself :Brickwall:
This is a bug in geoposition calculations, or in my task handling calculations inside .lua scripts.

- Garo

#32 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 21 August 2005 - 02:35 AM

xenoui doesn't want to get built:
xenocore.lib(scriptsystem.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl Xenocide::Common::Stack::initLua(void)" (?initLua@Stack@Common@Xenocide@@SAXXZ) referenced in function "public: __thiscall Xenocide::Common::ScriptSystem::ScriptSystem(void)" (??0ScriptSystem@Common@Xenocide@@QAE@XZ)
..\..\..\xenocide\bin\Debug\xenoui/xenoui.dll : fatal error LNK1120: 1 unresolved externals

(I hope I don't have to rebuild whole solution. One can go for a smoke and drink a cup of tea while it compiles at its leasure).

Clean rebuild says same thing... I guess one cpp is missing...

Edited by UnFleshed One, 21 August 2005 - 06:04 AM.

Darkness is under the candle.

#33 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 21 August 2005 - 11:30 AM

Garo, can you write down that in the docs site?

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#34 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 21 August 2005 - 12:09 PM

Has anyone confirmed that the svn is broken?

I recompiled everything here, and every file (including the stack.*) should be in svn. In other words, I can't reproduce the compilation error :(

- Garo

#35 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 21 August 2005 - 12:26 PM

I can confirm it is not broken. Except for XenoTest, anyone can fix that. ;)

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#36 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 21 August 2005 - 01:41 PM

Garo, can you write down that in the docs site?


http://docs.projectx...ngTaskFramework

That should do the trick.

Once you have spawned it, you can see that it soon starts to circulate in a small circle over the pole. This should NOT happend (it's a bug), but I haven't yet figured out why it does that. I'm actually hoping that rincewind could take a look on it, because I'm not sure if it's my code, or if it's rincewinds Geoposition calculation.

Anyway, there's a internal hardcoded trigger, which destroys the task
soon after it's spawned, but you should clearly see how it starts to circulate over the same place before the self-destruct goes off (This is just for debugging this bug).

- Garo

#37 red knight

red knight

    Xenocide Project Leader

  • Xenocide Inactive
  • 3,310 posts

Posted 21 August 2005 - 01:53 PM

Ok, closed the documentation issue.

Greetings
Red Knight
Sourceforge Nick: flois - Federico Andres Lois
Visit my blog at: flois.blogspot.com

Posted Image

Pookie cover me, I am going in.

#38 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 21 August 2005 - 02:33 PM

Oops, I guess it was me... Revision 651 compiles and runs...
Darkness is under the candle.

#39 bpuk

bpuk

    Sergeant

  • Forum Members
  • PipPipPip
  • 50 posts

Posted 22 August 2005 - 04:54 AM

I can confirm it is not broken. Except for XenoTest, anyone can fix that. ;)

Greetings
Red Knight

<{POST_SNAPBACK}>


Build OK here as well, although I do get a number of warnings during compilation (all lua/luabind related)

However - since last svn checkout I can't get into baseview. No system changes other than svn co

exception occours as per screenshot (sorry for the colour, thats just the gif :))

Any ideas?

Ta
Ben

Attached Files


.... . .- -.. ..-. --- .-. - .... . .... .. .-.. .-.. ...
- .... . -.-- .-. . -.-. --- -- .. -. --. ..-. .-. --- -- - .... . .... .. .-.. .-.. ...
.... . .- -.. .- .-- .- -.-- ..-. .-. --- -- - .... . .... .. .-.. .-.. ...

#40 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 22 August 2005 - 09:35 PM

Have you updated the dependencies via package updater?

- Garo

#41 bpuk

bpuk

    Sergeant

  • Forum Members
  • PipPipPip
  • 50 posts

Posted 23 August 2005 - 02:18 AM

Have you updated the dependencies via package updater?

- Garo

<{POST_SNAPBACK}>


Yep, I'm doing a complete clean, re download and extract now, just in case a lib has got corrupted. As far as I can see theres not been any new packages since the 25th though?
Built, compiled and ran perfectly in 649, crashes in 651 (baseview only)

EDIT: After redoing dependancies, still doing it. Next thing is to try a revert - can't see why it would make a difference though.

EDIT 2: 649 runs OK, 650 and 651 fail - now looking to see whats changed :)

Ta
Ben

Edited by bpuk, 23 August 2005 - 04:28 AM.

.... . .- -.. ..-. --- .-. - .... . .... .. .-.. .-.. ...
- .... . -.-- .-. . -.-. --- -- .. -. --. ..-. .-. --- -- - .... . .... .. .-.. .-.. ...
.... . .- -.. .- .-- .- -.-- ..-. .-. --- -- - .... . .... .. .-.. .-.. ...

#42 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 15 September 2005 - 03:49 PM

Garo, did you do something on interceptions yet? (One craft chasing another).

I mean I'm going to do it (well, to try anyway :)), just don't want to redo something done or started already.
Darkness is under the candle.

#43 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 18 September 2005 - 02:20 AM

Garo, did you do something on interceptions yet? (One craft chasing another).

I mean I'm going to do it (well, to try anyway :)), just don't want to redo something done or started already.

<{POST_SNAPBACK}>


Nope, I haven't. There's still the big problem with the Geoposition/movement code, which makes the craft go crazy near the poles. We should try to fix that before we continue.

I'd like if you could take a look on it. Read my postings on this thread how to see the bug.

- Garo

#44 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 18 September 2005 - 02:45 AM

Yeah, I've seen it. What are those lines, by the way?
Darkness is under the candle.

#45 Beetle

Beetle

    Programming Department

  • Xenocide Inactive
  • 350 posts

Posted 18 September 2005 - 04:19 AM

For me they look like a speed and direction of moving craft :) but not sure i didn't check that in code :)
Posted Image

#46 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 19 September 2005 - 01:41 AM

It is direction of movement and direction to target. So if you see two lines, you know what that means :).

Anyway. What does all that code do?
(flyover3.lua)
if (delta < 0.005 and delta > -0.005) then
    self.direction = dir;
    Console:echo("direction = dir");
    else
        if (delta > 0) then
            self.direction = self.direction - delta;
        else
            self.direction = self.direction - delta; 
    end
end      

If you put instead simple "self.direction = dir;", craft will deviate a little on the pole and go further as planned.

Edit: deviation is happening because when craft is on the pole (inside some minimal circle actually), azimuth have no meaning :). So getAzimuth() returns direction to the opposite pole. And there is plenty ways to go from one pole to another :). But as soon as craft leaves pole, it corrects its course.

Edited by UnFleshed One, 19 September 2005 - 01:52 AM.

Darkness is under the candle.

#47 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 24 September 2005 - 04:47 AM

Those lua scripts are a mess :D
Unstrict nature of lua makes it even worse. How can one write anything without declaring variables, at least their names if not types? This environment is screaming for bugs to come and claim it. Typos tend to sneak in (for there is absolutely no means to stop 'em) and make you go crazy over visibly perfect script wich is refusing to run for no reason. :ph34r:

Go make an artist or a sound guy write a script for AI in those conditions. :construction:

Well, I guess I am spoiled :).

Anyway, I won't be integrating it into existing scripts, for they look to me like testing for simulation framework, not like subroutines for later use by overmind. Or am I wrong?
Darkness is under the candle.

#48 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 29 September 2005 - 12:38 AM

Those lua scripts are a mess :D
...
Anyway, I won't be integrating it into existing scripts, for they look to me like testing for simulation framework, not like subroutines for later use by overmind. Or am I wrong?

<{POST_SNAPBACK}>


True. I have had to solve many problems with the lua integration at the same time when I wrote those scripts. They are a mess and they really need a rewrite with some planning. I've discovered dozens of small nasty caveceats where one can drop because lua doesn't quite work as most of us would expect. Also the class framework isn't a native feature, but a gludge which has been added later by a 3rd party.

The unstrict nature is a big problem. It can be avoided with very strict coding guidelines, but there's still a lot of room for human errors.

But there's a lot of good features within lua, for example the coroutines, so that we can create small programs which executes in their own timeline.

I'm not saying we should abandone lua, but we should open the discussion how lua should be used and maybe keep an option to switch lua off for some better script engine (stackless python, maybe?)

btw. Sorry, I have been away the past six weeks, mostly due to my school. I feel sorry for that and I'm trying to get myself again going with xenocide =)

#49 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 29 September 2005 - 12:53 AM

Well, I actually turned around recently and read some manuals on LUA... It isn't bad, it is different :). (I alway tend to have very bad first impresions :)). I think if we plan everything carefully, make up a codestyle and use those them metatables to enforce it here and there, it can be managable. And after a while it can be simple (it takes more than reading manuals for me to get to feel the language :))
Darkness is under the candle.

#50 dteviot

dteviot

    Programming Department

  • [Xenocide Senior Members]
  • 1,479 posts

Posted 11 October 2006 - 06:39 PM

I'm posting up Grahor's notes on this.

Alien Overmind strategy and tactics; AI implementations and necessary requirements.

Greetings.

I have some preliminary thoughts on Alien AI, so I've decided to write them here, to summarise, so to say, what is necessary for future implementations of AI.

I have a big problem with games, in which AI is little more than a bunch of scripts, who throws meat at player based only on player's actions and triggers. That is, no matter how bad (or how good) you are playing, you will never «fall behind» AI player or get any advantage; you hit AI – trigger throws more meat at you, you hit AI hard – it results only in ability of AI to throw more meat at you. AI never «feels» losses, his advance is never thrashed, player never feels that he is winning, that AI is retreating... I hope you understand what I mean.

On the other hand, gameplay have to advance, no matter what manner of play player uses. Therefore, some sort of triggers and cheating on the part of AI is necessary... But as small as possible.

Thus, I thought a bit (couple of evenings, as a matter of fact :) ) about Alien AI and the gameplay from his point of view.

Strategy.

Part one: Goals.

First of all, there is Alien Overmind. Location – Mars. It has its own goals. Main goal – to conquer Earth. That conquest is separated into stages.

First stage – reconnaissance. Brain on Mars knows nothing about Earth (well, “nothing” in the sense of information, necessary for conquest.) For example, Alien Overmind have no idea about political and cultural division of the planet into regions.

Thus, Earth is divided (from Alien Overmind's point of view) into equal sectors, each sector has value of “military knowledge”, or “explored”, or something (I'm not very good in English). This value rise a lot when “scouting mission” in that sector is successfully executed, rise a little when UFO moves through sector (depending on an UFO – supply transport moving through sector rises exploration value far less, than scout moving through same sector.) Both scouting missions and high exploration value have chance to uncover available targets, like “terror sites”, “X-corp bases”, “good place for UFO base” and so on (I'm not sure about all possible variations.)

Exploration value deteriorates with time; with successful X-corp mission in sector; with lose of base in sector. Also, deterioration depends on “alien infiltration” - the more aliens have infiltrated governments of the sector, the less deterioration happens.

Sectors also have “alien infiltration” value – kind of “twisted mirror” value of “reputation” for player (the thing which defines, how much a region pays to player.) That is, the more regions, located in sector, like player, the less “alien infiltration” value is; the more they hate player, the more “alien infiltration” value is. Successful UFO missions rise “alien infiltration”, especially terror missions and built bases. X-corp's defeats will also rise it. Successful missions and simply presence of UFO crafts will lower it, although at a different rate.

Finally, each sector keeps whole information on X-corp attacks in this sector, either in form of exact info “scout UFO #144 was destroyed in sector while doing mission X at time Y” or in form of “level of danger”, both variations have their positive and negative sides. If a sector is considered “dangerous”, Alien Overmind will not initiate missions inside it (and possibly in surrounding sectors) and will guide UFOs in flight around dangerous sectors, only sending from time to time a scout on exploration mission or heavy UFO on attack mission.

First stage, preliminary exploration, will be conducted across the whole globe by small UFOs, thus giving player time to get accustomed to the Game. It will be over when a necessary information density will be achieved, plus some additional conditions triggered by player.

Second stage – conquest itself. Conquest means forcing governments, through Terror missions, Bases, and other successful missions to abandon X-corp and to join Aliens – thus, from AI's point of view, it consists of making as much number of sectors as possible to achieve the highest level of “alien infiltration”. Obvious strategy for this is to execute missions in “safe” sectors with highest “alien infiltration” ratings, while distracting and harassing human player with strikes by fighting UFOs.

Thus, area around human bases will be mostly undisturbed by UFO missions, while UFOs will concentrate on safe sectors, forcing player to watch for “alien activity” maps and to send patrols in threatened regions. Also, a number of successful interceptions of UFOs may (and will) force Alien Overmind to abandon dangerous region and move operations into less threatened sectors, which is, in my opinion, pretty lifelike behaviour.

In later game, when both player and AI player will be more or less developed, AI will start missions like sending a battleship (or more than one) into zones of high danger, exploring sector in search of X-corp base and attacking it.

Part two: Means.

Alien Overmind have 3 resources.

First: “construction” or “industry”, which is spend (a little) on missions, and undefined yet value on armament and (a lot) on building new ships, either completely new or replacement of old ships. Also building new bases (needs massive amount.) Without ships Alien Overmind can't initiate new missions. The more bases on Earth it have, the more of this resource it gets every day, the more it can store. Also, some missions influence this resource – for example, interceptions of Supply Missions destroy large chunks of that resource, thus inflicting serious hit against AI's plans.

Second: “hangars”, so to say, or “command limit”, or whatever. Alien Overmind can have only limited number of ships of each class at every moment, and the more bases on Earth it has, the more ships it can wield; the more ships it have, the more often (and more reckless) it in their use. Thus, if the player will allow alien bases to grow on Earth completely unchecked, his defences will be saturated by wave after wave of battleship attacks; while if the player will carefully “guard and protect” Earth, Alien Overmind will have far, far less resources to attack with. Thus, very important thing – reward for “good” playing and punishing for “bad” will be achieved, as also providing motivation for hunting bases and ships mid-to-endgame.

Third: “biological material”. Biological material is spend to produce more soldiers. It is acquired through Alien Abduction mission (the most), Terror mission, bases, and may be some other ways. Interceptions of Abduction missions, Supply missions, killing of alien soldiers, destroying of bases – lowers the resource. The more of this resource AI has, the more aliens are in its crafts, bases, terror sites; the less it has, the smaller number of crews in ships, number of guards in bases...

Of course, there are highest and lowest values for all the resources, ships and numbers; it is impossible to completely render AI helpless by denying him resources; but it is possible to get close to that.

Also, resources may be modified by triggers.

Depending on what resources Alien Overmind needs, it plans Gathering missions; if it have enough resources for now, it sends Conquering missions; if there are too many dangerous sectors, it sends Attack missions.

Tactics.

Every UFO follows the pattern:
* Built on Mars.
* Crew added.
* Put in hangar until needed.
* Sent to a Mission by AI Overmind.
* Flight from Mars (invisible for player; don't think there is a need to simulate it, just add a bit of time between command from Overmind to start the mission and appearance of UFO above Earth)
* Entry into atmosphere and braking; always in direct line, slowing down from space speeds to atmospheric speeds; relatively high chance of discovery by independent (non-X-corp-based) observers. What do you think about auxiliary detecting and tracking from non-X-corp government facilities? I mean, it is not unreasonable to think, that some governments will do whatever they can to help X-corp.
* Atmospheric flight from entry point to mission sector, possibly evading dangerous sectors, including evasive maneuring (curves, zigzag, whatever) to hamper extrapolation of ending point (and starting one, if mission starts in Earth-based UFO base).
* Arrival to mission sector, executing mission (different patterns, depending on missions)
* Leaving the atmosphere, relatively short acceleration directly up (fastest way, as I understand), it would be nice to show somehow graphically, I think. Depending on attitude, interception still possible for some types of X-corp crafts.
* Disappearance from radar/neudar, returning to Mars.
* Storing the ship with same crew into hangar; repair if damaged; goto 3.

It would add nice flavour, I think, to add a bit of personality to ship. For example, it's not hard to log UFO's missions and important things that happened; and, for example, adding in mission briefing “It's the same ship that got our Interceptor 5 two weeks ago” or in debriefing “Scientists decoded its flight log; this ship participated in Terror Mission in Paris a week ago” is easy to implement and, in my opinion, is a nice touch.

Missions follows the pattern: first, a good place for mission have to be scouted; then, depending on mission;

Abduction Mission: Abduction craft moves close to “good site for abduction”, slowly moves in scouting pattern, finds perfect site, lands.

Terror Mission:
* (AFTER discovering terror site) a big scout or small fighter slowly scouts terror site itself;
* If intercepted then go to 1; if sector is too dangerous abort mission; find new possible terror site in safe sector;
* Then Terror craft moves directly to Terror site and lands without slowing down – area already scouted. If intercepted – abort mission; if spare Terror craft exist, start new mission in safe sector; otherwise build new Terror crafts/gather resources for them.
* Meanwhile, one or two small fighters plus (possibly) first scout patrol nearby sectors, trying to intercept/distract X-corp transport/fighters.
Base building mission: 2 scouts scout area, then at least 3 (or 4) transport missions have to land unopposed and spend some time on the ground without attack; if 2 intercepted, base building stops temporarily, AI waits until danger level of sector subsides.

And so on.

Requirements, at least, preliminary:

Map. Water and Earth. AI have to know, if there is only water in some sector, or if it have also some land, and where one stops and other starts.

Regions. AI have to know, which regions correspond with which coordinates, or at least which sectors.

Coordinates of cities. There have to be at least 20 pre-defined “terror sites” with well-known names – AI have to know their coordinates, in which sector they are, which regions they influence. Better 50 cities.

Habitable and non-habitable terrains. AI have to know, if he can start and Abduction here, or if there is only snow, ice or desert in this sector. (Possible interesting touch – Abduction from Arctic or Antarctic polar scientific base. Coordinates of famous bases needed, though. :) )

What do you think about it? Have anyone worked on Alien AI already? What looks wrong for you? What looks good? :)


Saving the world from the scum of the universe is hard work. Especially when you have to create the scum to begin with.