Shard 0.4/dev - Page 5

Shard 0.4/dev

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

Moderators: hoijui, Moderators

Post Reply
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Re: Shard

Post by Neddie »

Pxtl wrote:Okay, the idea of the AI balancing itself against your econ? That's really, really cool. I totally agree that the "easy/medium/hard" thing is silly, so this kind of auto-adjusting AI concept is brilliant.
I'm surprised it didn't come into Spring AI earlier, I think I talked to Boirunner or possibly Felix The Cat about challenge scaling related to ingame factors a long time past.
1v0ry_k1ng wrote:personally I think an AI should be as good at the game as possible, the challenge is what makes it fun :regret:
The challenge of overcoming is important, but if you cannot overcome it ceases to be a challenge, and instead is revealed to be a bore. Then again, you must be playing an AI for a reason... :regret:
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

I'm surprised you don't know auto-leveling AI did come to Spring earlier.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Id always assumed if it had arrived ti would probably have been in some piece of kernel panic code
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

And you'd be right, except for the conditional.

Anyway, do we have AI modoptions yet? It's a little untidy to have two AIs, the unrestrained one and the autoleveling one, would be cool to be able to merge them, and even cooler if the looseness of the restraint could be tweaked by a slider. Then considering lobbies don't support yet player and team mod options so long after they've been implemented in the engine, I'm afraid I'm dreaming.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

We've had AI options for months, Hoijui added them, they're in AIOptions.lua for native AIs. Not sure the lobbies support them yet though
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui »

SL does support them, though it is a bit unintuitively (you have to double click on items in a list).
Last time i tries TASClient, they were not in .. but could be Satirik did it and i just forgot about it again.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

Cool. I just need to find the syntax to add options to LuaAI.lua now.
cranphin
Posts: 136
Joined: 13 Jun 2005, 16:37

.

Post by cranphin »

.
Last edited by cranphin on 21 Mar 2021, 14:12, edited 1 time in total.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Shard

Post by Pxtl »

hoijui wrote:SL does support them, though it is a bit unintuitively
Why am I not surprised?
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard

Post by yuritch »

How can I check how many of a specific unit type the player has currently? I'd like to use that to control how much factories the econ can support based on the number of extractors (and maybe a few other things).

Edit: found how to do that myself - game:GetFriendly() helps there. Unless there is some other way that doesn't need a lua-side loop through all the units?

Edit2: that's a really great AI! With some simple functions I can control things like ratio of facs to extractors, those were impossible with AAI. Now one thing I want that is lacking is the ability to return a nil or empty string instead of a unit name if I don't want to build that unit right now. Currently AI needs a valid unit name in all cases and there doesn't seem to be a way to just skip to the next item in the list (or at least I haven't found it), so if I don't want to build another factory, I have to return something other (like a mex).
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

As a warning, I intend to change the nature of GetFriendlies and similar types of API methods to instead return a table, as it works better, especially since at the moment your stuck with calling it once and polling for each unit, eurgh its messy

so rather than:

Code: Select all

local enemyCount = game:GetEnemies()
for i,enemyCount do
    local enemy = game:GetEnemy(i)
end
it would be:

Code: Select all

local enemies = game:GetEnemies()
local enemyCount = #enemies
for i,enemy in ipairs(enemies) do
    -- hurrah
end
I've been taking some well earned rest after the Uni crunch.

Also what your trying to do would require a loop of some kind anyway, its just a matter of where that loop goes. I'd like to put it in Shard but there's always the benefits of doing other things during the loop for efficiency gains.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard

Post by yuritch »

Efficiency optimizations can come at a later stage, when I'm sure my AI setup works the way I want. So far I made a function to count all friendly units which match a given name using a loop, and it works (though when there are 2 Shards in game, periodic slowdowns are noticeable).

As for nils or empty strings or whatever returned instead of a unit name: currently they seem to crash lua and the AI stops (or at least the unit the queue of which contains that stops). So I have something like that (only build another factory if there are more than 3 times as much extractors as there are factories):

Code: Select all

local function ground_factory()
	if countOwnUnits("mine")>(countOwnUnits("l_fact")*3) then
		return "l_fact"
	else
		return "mine"
	end
end
If I don't want to build the factory, I have to return some other valid unit name. I'd like to be able to return a nil or "" instead so the builder can just skip the item when it's not wanted. Currently I return the extractor which seems to be skipped if there are no unused metal spots anymore, but that doesn't seem like the best solution to me.
Last edited by yuritch on 26 Apr 2010, 17:20, edited 1 time in total.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Shard

Post by jK »

AF wrote:so rather than:

Code: Select all

local enemyCount = game:GetEnemies()
for i,enemyCount do
    local enemy = game:GetEnemy(i)
end
it would be:

Code: Select all

local enemies = game:GetEnemies()
local enemyCount = #enemies
for i,enemy in ipairs(enemies) do
    -- hurrah
end
performance-wise the best would be (except you are using LuaJIT):

Code: Select all

local enemies = game:GetEnemies()
for i=1,#enemies do
    local enemy = enemies[i]
end
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Yeah that's probably right, the most damning defect in the current API is if you insert a second loop inside, because unless you copy each entry and then loop over, your modifying the set of data your working on each time you call GetEnemies etc

It's more a sign of me implementing it one way because I needed it, realising how I could do it the way I originally wanted, but never getting around to it.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Kerr has unfortunately suffered a rather crippling hardware failure, and is unable to continue working to support CA =(

Luckily for whoever picks it up, he's already done the ground work setting up core, heres to a job well done, and I hope he gets back soon!
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard

Post by yuritch »

Is there a way to find out how much metal an extractor is producing? As far as I see the API functions do not provide this (or any other) info about how much resource individual units are making/consuming (except for avg wind value). While for some units I can just use constants, metal extraction depends on map (and can even be different on different metal spots on the same map), so it can only be calculated per-unit.

I need that info because now my AI config uses the number of extractors to decide if it can support more factories or not. Using actual metal income instead would be much better.
Attachments
SmallModConfig.7z
My current config
(2.89 KiB) Downloaded 37 times
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

I'm sorry I haven't been as prolific lately, Ive been working on a rebuild of the darkstars theme to fix up a few errors.

Right now I haven't added much of anything in the way of determining resources to the API, and it's something I will need to sort out, so at the moment, there isn't any, a kind of glaring flaw I know =(
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Some changes made so far

Bugs:
  • Fixed a bug causing the spring API call for UnitDamaged to be sent to Shard as a UnitIdle call. UnitDamaged calls should now work correctly, and phantom UnitIdle calls should no longer exist.
  • UnitDamaged calls were never passed along from the AI object to all units and behaviour objects
  • Removed numerous debug messages
  • AttackHandler now maintains attack group sizes above a minimum value to prevent attack group sizes degrading to that of a single unit or two
  • Minor fixes to task queue management and certain failure cases that were never accounted for
Optimizations:
  • Checks added to prevent processing after the game has finished
  • Attack targeting now only checks for targets every 6 frames not every single frame
  • LUA_PATH is now set up correctly. Instead of calling game:ExecuteFile(file) or ai:ExecuteGameFile(file), you can now use the standard Lua library functions/keywords:
    • require - note if this fails the AI will exit and take the engine with it after printing a stacktrace to infolog.txt
    • include
Features:
  • Added game:IsPaused()
  • UnitDamaged now has a second parameter indicating the attacker. If the attacker isn't available, nil will be passed and must be checked for
  • Added game:MinimumWindSpeed()
  • Added game:MaximumWindSpeed()
  • Added game:TidalStrength()
  • Added unit:IsCloaked()
User avatar
KaiserJ
Community Representative
Posts: 3113
Joined: 08 Sep 2008, 22:59

Re: Shard

Post by KaiserJ »

time spent developing EVOrts : thousands of hours

time spent developing shard : thousands of hours

time spent watching my drunken friend get beaten by shard over and over again after talking shit about how good he was going to be at a game he hadn't yet played and AI opponents in general : priceless
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Shard

Post by Forboding Angel »

lol! Need replays!
Post Reply

Return to “AI”