Shard 0.4/dev
Moderators: hoijui, Moderators
Re: Shard
Looks like the changes in ai.lua have broken my overrides as well (namely moving the includes from AI:Init() to require block, so now ai object is not initialized when my scripts run). That's easy to fix however (and maybe with the new resource object and unit-list-as-lua-table thing my hacks won't be needed anymore).
Re: Shard
note that ai.lua can be overridden as well now thanks to that change, you can take the lua files form the previous Shard and put them in your folder and huzzah you have the previous Shard but with extra API additions while you port your code forward. Just remember to modify the function in ai.lua that loads custom game overrides accordingly.
Re: Shard
If I just place ai.lua from Shard 0.21 into my mod_name folder, overrides still crash AI (so looks like 0.25 ai.lua is still used). So I modified the 0.25 ai.lua to be more like the 0.21 (by moving the includes into AI:Init(), in theory that should not break it) and now the game starts.
However now I'm getting spring crashes at about game frame 4600 - 4800 with infolog pointing to Shard\0.25\SkirmishAI.dll at the top of stack (so the crash is probably in there). I'm trying to find out if those are caused by my overrides and modifications.
Edit: looks like attempt to get the resource object causes the crash. Trying to figure if I'm just doing it wrong...
Edit2: found it. This code causes error (I modified it a bit so it doesn't crash the dll now, error stays in lua):
"attempt to index global 'tmpRes' (a userdata value)"
So whatever GetResource() returns doesn't quite seem to be a table.
However now I'm getting spring crashes at about game frame 4600 - 4800 with infolog pointing to Shard\0.25\SkirmishAI.dll at the top of stack (so the crash is probably in there). I'm trying to find out if those are caused by my overrides and modifications.
Edit: looks like attempt to get the resource object causes the crash. Trying to figure if I'm just doing it wrong...
Edit2: found it. This code causes error (I modified it a bit so it doesn't crash the dll now, error stays in lua):
"attempt to index global 'tmpRes' (a userdata value)"
Code: Select all
i = game:GetResourceCount()
game:SendToConsole("GetResourceCount: "..i)
for j = 1, i do
tmpRes = game:GetResource(j)
game:SendToConsole(tmpRes.name)
end
Re: Shard
GetResource returns a userdata type object of type SResource.
Also keep in mind you are using lua array assumptions of indices starting at 1. Whereas these API calls reference a C++ structure, starting at index 0.
I should have a GetResources in the next version containing each resource in a table
Also keep in mind you are using lua array assumptions of indices starting at 1. Whereas these API calls reference a C++ structure, starting at index 0.
I should have a GetResources in the next version containing each resource in a table
Re: Shard
So it's 0-based. Might be worth it to mention that in the api.lua or some other doc somewhere.
So, if the resource object is not a table, how do I use it then? Most of your other objects are documented as containing only functions in api.lua, so I can call those functions, but resource object (and also Position object) only contain properties? And an attempt to get those properties with the dot notation (as well as with the array notation, like tmpRes["name"]) fails.
So, if the resource object is not a table, how do I use it then? Most of your other objects are documented as containing only functions in api.lua, so I can call those functions, but resource object (and also Position object) only contain properties? And an attempt to get those properties with the dot notation (as well as with the array notation, like tmpRes["name"]) fails.
Re: Shard
It should be enough to do something along the lines of:
But I'd ideally want to be able to do:
Note that I haven't tested that code, and I can make no guarantees. You can use the first bit of code to modify api.lua to add a GetResources that behaves the way the second piece of code does, since the game variable, is a table wrapping around game_engine, and game_engine is the object that all the C++ functions/methods are attached to.
As a side note, since when Shard is released in source, it'll be LGPL, BUT, since the lua code is already released, which constitutes a considerable proportion of Shards source code, that lua code will be licensed under LGPL also.
Also note that I consider the two separate projects, the Shard AI, and the Shard C++ binary. It is only the binary that is currently a problem in the developers forum.
Code: Select all
local rcount = game:GetResourceCount()
for i = 0,rcount do
res = game:GetResource(i)
if name ~= "" then
game:SendToConsole(res.name)
end
end
Code: Select all
local resources = games:GetResources()
for name,resource in pairs(resources) do
game:SendToConsole(name)
end
As a side note, since when Shard is released in source, it'll be LGPL, BUT, since the lua code is already released, which constitutes a considerable proportion of Shards source code, that lua code will be licensed under LGPL also.
Also note that I consider the two separate projects, the Shard AI, and the Shard C++ binary. It is only the binary that is currently a problem in the developers forum.
Re: Shard
I tried your first example, and (just like with my own code) this is what I get:
attempt to index global 'res' (a userdata value)
Line number in the error string points to this line:
(also, I think this: should instead be this: , but it doesn't work either way)
So, in short. Any attempt of accessing any properties of a resource object (like res.name, res.income, etc.) causes error. Looks like something is missing on the C++ side.
attempt to index global 'res' (a userdata value)
Line number in the error string points to this line:
Code: Select all
game:SendToConsole(res.name)
Code: Select all
if name ~= "" then
Code: Select all
if res.name ~= "" then
So, in short. Any attempt of accessing any properties of a resource object (like res.name, res.income, etc.) causes error. Looks like something is missing on the C++ side.
Re: Shard
blah it mustn't like member data variables that arent wrapped up in public accessor methods. For now all I can think of trying is accessing the other variables that are numeric, or adding :c_str() to the end, since name is of type std::string internally.
Re: Shard
Just tried this AI. It sent a lot of L1 units in, then both AIs I was playing sent their commanders over and my defences took them out and it was game over. See the replay if you're interested.
- Attachments
-
- 20100608_135252_Tangerine_0.81.2.rar
- (133.36 KiB) Downloaded 21 times
Re: Shard
I primarily focus on Shard as an AI framework, and although I provide and develop a basic AI that can be modified via behaviour and task queues, there are a lot of possibilities which I either don't have the time to go into, or are not appropriate for me since it would require personal knowledge.
Thus there is nothing stopping someone using Shards framework to create an AI under a new name with extra modules behaviours and code to decide what happens instead of what I have written, so long as they make it clear that Shard was used as it's basis and they follow the license. Any such AI should be released after bI have open sourced shard, for which Im still waiting on the results to know it is safe to release. This should be no later than the 12th of July
The case hoof commanders is one that uniquely affects TA based games, and I simply have not implemented code to protect commanders, as far as Shard is concerned it treats them just like any other unit.
I would suggest adding a new behaviour that tells a commander to retreat to the nearest structure in the event that it is fired upon and a certain number of units are found within a certain radius with weapons. Refer to the evolutionRTS overrides which has a behaviour that makes engineers build turrets when under fire
Thus there is nothing stopping someone using Shards framework to create an AI under a new name with extra modules behaviours and code to decide what happens instead of what I have written, so long as they make it clear that Shard was used as it's basis and they follow the license. Any such AI should be released after bI have open sourced shard, for which Im still waiting on the results to know it is safe to release. This should be no later than the 12th of July
The case hoof commanders is one that uniquely affects TA based games, and I simply have not implemented code to protect commanders, as far as Shard is concerned it treats them just like any other unit.
I would suggest adding a new behaviour that tells a commander to retreat to the nearest structure in the event that it is fired upon and a certain number of units are found within a certain radius with weapons. Refer to the evolutionRTS overrides which has a behaviour that makes engineers build turrets when under fire
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Shard
Hey AF, could you add a little didly that would allow us to limit how many buildings of a certain type shard is willing to make?
Like for example, me being able to limit shieldgens to 2, etc
Like for example, me being able to limit shieldgens to 2, etc
Re: Shard
That's already possible with the current setup, I do it in my config a lot.
You can count existing units of a given type in taskques and return an empty string if you don't want to make any more (AI will complain about not being able to find unitdef for "", but will continue to work). Returning any non-existing unit name also works (but not nil, this will cause lua error).
You can count existing units of a given type in taskques and return an empty string if you don't want to make any more (AI will complain about not being able to find unitdef for "", but will continue to work). Returning any non-existing unit name also works (but not nil, this will cause lua error).
Re: Shard
Actually a task queue should be able to signal a premature ending using a nil value, I'll have to look into that
The best way of doing it would be so that instead of putting the name of the shieldgen in the task queue, you instead put in the name of a function, in the same way that has beenndone to figure out wether to build solars or wind generators in the TA task queues. Then refer to your own overrides for how to store data, this should show you how to store a counter.
Then you have to do a check, check to see how many units of that type are in existence on your team and if there are less than 2, return the shieldgen name, else return something else or an empty string. I intended for it to be a nil but since that's not working I can look into that and summon up a private build for you both
The best way of doing it would be so that instead of putting the name of the shieldgen in the task queue, you instead put in the name of a function, in the same way that has beenndone to figure out wether to build solars or wind generators in the TA task queues. Then refer to your own overrides for how to store data, this should show you how to store a counter.
Then you have to do a check, check to see how many units of that type are in existence on your team and if there are less than 2, return the shieldgen name, else return something else or an empty string. I intended for it to be a nil but since that's not working I can look into that and summon up a private build for you both
Re: Shard
only the content of the Shard folder, like here:
http://github.com/Error323/E323AI
i guess this means.. we will not get any of the development history from before the day of release? (eg, you do not have it as a git repo now)
http://github.com/Error323/E323AI
i guess this means.. we will not get any of the development history from before the day of release? (eg, you do not have it as a git repo now)
Re: Shard
So I tried Shard 0.25, watching 2 Shard in KP 4.0 on Data Cache:
- I still have the issue of Shard forgetting to give order to builders: idle builders while there are free datavent.
- One AI let a Pointer unfold and fire while still inside the Kernel, thus blocking it, preventing new unit from being built. How to prevent that?
- I still don't know how to issue custom order (dispatch). See this PM for details.
- You are still shipping Shard with an outdated KP config:
- Change config name from KP.n to KP
- Use my attackers.lua & taskqueues.lua, which are more complete. See this PM for details.