why does ai and player NOT have shared index?

why does ai and player NOT have shared index?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

why does ai and player NOT have shared index?

Post by smoth »

there is an ai and player table in lua. This means that if I want to find out the id of an AI it has a different starting index than a player. It even shares the id of the player owning it.

WHY?

this really complicates things. Why can't we have a table that counts ais within players... yes I know they are NOT but there is no real term I can think of beyond entities. I don't get why we cannot just have a player table with controller = [ai or human etc] to denote if it is an ai or not?

It is a really pain doing any thing that has both players and ais to consider, from scoreboards to xp systems it all becomes an irritating task because of the way the tables are structured. there is HUGE bloat involved at every step.

So why?
User avatar
PepeAmpere
Posts: 591
Joined: 03 Jun 2010, 01:28

Re: why does ai and player NOT have shared index?

Post by PepeAmpere »

I thought Spring.GetTeamList lists you all playing entities and you check via Spring.GetPlayerInfo if it is AI.

I think team is the "complete" unit in means of command power and battle statistics, that is taken in consideration as playing entity. Not member of "players" table.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: why does ai and player NOT have shared index?

Post by zwzsg »

A single team can be controlled by many players and AI.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

so TEAMID should determine the key element?
User avatar
PepeAmpere
Posts: 591
Joined: 03 Jun 2010, 01:28

Re: why does ai and player NOT have shared index?

Post by PepeAmpere »

zwzsg wrote:A single team can be controlled by many players and AI.
I know, but it doesnt affect my statement, that key unit meassure for statistics and controling the game is the team entity.

As Smoth pointed, doesnt matter how team is constucted, if its real person, AI, fake real person AI or just composite brain of 560 Chinesse students and one iPad AI bot. Alone or together it generate some "commands set", which makes it one complete command unit, no matter which mechanic is behind its acting, and it has one set of resources and team-based unit tables, which makes it complete from view of some statisticts.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

correct, this setup creates some serious BS when it comes to storing stats. I wish there was a UNIQUE index for EACH player/ai entity where I can track THAT player/ai's statistics. As it it stands now it is quite a lot of work to track down individuals. If this is not changing, fine, I will make my own table for it... but I am not sure if it'll be viable in the way of widgets etc. I spend most of my time in gadget land.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: why does ai and player NOT have shared index?

Post by Silentwings »

I've not dealt much with AIs so am not familiar with the problems you're describing here, but if needed you should be able to send the stats to widget land (presumably when game ends) with _G.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: why does ai and player NOT have shared index?

Post by knorke »

Do you want to differentiate that player A clicked the factory to build a tank and then player B used the tank to destroy enemy. So player A gets better "eco" stats and player B gets better "battle" stats?

If not then the only "bloat" from player/AIs/commsharing is when displaying the stats, can just save it indexed by teamID.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

well there are issues retrieving the information..

so like for my ai players

Code: Select all

	for k,v in pairs(Spring.GetTeamList()) do
		local playerlist = Spring.GetPlayerList(v)
		local Ailist = Spring.GetAIInfo(v)
		if #playerlist ~= 0 then
			Spring.Echo("Player List team id: ".. v )
			recursiveTableReader(playerlist," ")
			for _, playerId in pairs(playerlist) do
				Spring.Echo(Spring.GetPlayerInfo(playerId))
			end
		elseif Ailist ~= nil then
			Spring.Echo("Ai info team id: ".. v)
		else
			Spring.Echo("gaia player team id: ".. v)
		end
	-- recursiveTableReader(Spring.GetPlayerInfo()," ")
	-- recursiveTableReader(Spring.GetPlayerList()," ")
	-- Only for synced
	end
I only really get like a number from getAIInfo when it its fed a teamid it just returns a number or nil.

I don't get it, when I dug into the table there was nothing there? is there any is issue with the getaiinfo function or is it improperly documented in synced read?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: why does ai and player NOT have shared index?

Post by knorke »

recursiveTableReader(Spring.GetPlayerInfo()," ")
These functions return no table but multiple variables.
local Ailist = Spring.GetAIInfo(v)
GetAIInfo does not return a list (of AIs or whatever)
Instead it gives name, version etc of one AI (see wiki)

Basically it is the AI-version of Spring.GetPlayerInfo
I guess there are different functions for AIs and players because getting "version" of a player does not make sense etc.

Here is how I used GetAIInfo for the playerlist of this:
http://springrts.com/phpbb/viewtopic.ph ... 37#p505437
Note how bots get "(AI)" in front of their name.
("invalid" was name used in singleplayer, not error)

Code: Select all

function teamIDToPlayername (teamID)
	local _, uplayer, _, isAiTeam = Spring.GetTeamInfo(teamID)
	local playername = "unknown playername"
	if (isAiTeam == true) then
		local skirmishAIID, name, hostingPlayerID, shortName, version = Spring.GetAIInfo(teamID)
		playername = "(AI)" .. name
	end
	if (isAiTeam == false) then playername = Spring.GetPlayerInfo(uplayer) or 'GetPlayerInfo fail' end
	return playername
end
So can do for example

Code: Select all

for _,teamID in ipairs(Spring.GetTeamList()) do
 Spring.Echo (teamIDToPlayername (teamID))
end
and it gives:

[f=0002740] [2up]knorke
[f=0002740] (AI)Aldi-0-Horst AI
[f=0002740] (AI)EDEKA-1-NullAI
[f=0002740] (AI)Otten-2-Horst AI

Replace playername = "(AI)" .. name
with
playername = "(AI)" .. name .. "--"..shortName.."--"..version.. " hosted by " .. Spring.GetPlayerInfo(hostingPlayerID)
and it gives
[f=0002740] [2up]knorke
[f=0002740] (AI)Aldi--Horst AI--<not-versioned>
[f=0002740] (AI)EDEKA--NullAI--0.1
[f=0002740] (AI)Otten--Horst AI--<not-versioned>
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: why does ai and player NOT have shared index?

Post by hoijui »

it is a design flaw of spring, stemming from way back then.
i wanted to change it, but for some reason(s) never did. most likely, it was my laziness, springs generally bad design, and the fact that lots of stuff (games, lua) would have had to be changed, and new bugs introduced.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

is it really that bad an idea to fix it hoi? how hard would the correction, post fix really be? It is only going to magnify the mistake.

However, if knorke is showing this correctly the get teaminfo is what I need? should I see "team" and the "entity" variable I am looking for knorke? as in each player and ai has their own team as per the lobby?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: why does ai and player NOT have shared index?

Post by Jools »

It also adds to the complexity when we in Spring have adopted technocratic definitions of the terms "player" and "team" that can be at odds with ordinary English usage.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

it does confuse things. I just want to get some verification because so far it is all guess work :|
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: why does ai and player NOT have shared index?

Post by gajop »

I'd say that if you are only going to record game statistics you can safely assume that teams have one player or AI and you should treat it as such.

The only time you should differentiate between players/AIs and teams is if you want to display their names and their machine utilization (usually CPU and latency).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: why does ai and player NOT have shared index?

Post by knorke »

smoth wrote:so far it is all guess work :|
acuelly is pro script! :shock:
smoth wrote:as in each player and ai has their own team as per the lobby?
As per the lobby comshare seems to be dying. For example in weblobby (zk lobby too?) it only shows allyID but not teamID. So you can not set up the teams in lobby.
Even if one player does it with a lobby that shows teamIDs (say springlobby) the teamIDs are automatically "fixed" so that no players comshare. No idea if that is an autohost thing, configurable or if some lobby does it. I tried springlobby+weblobby on xta host (springie afaik) and was unable to start a comshare game.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: why does ai and player NOT have shared index?

Post by smoth »

so commshare is broken by the engine? where does the teamid reassignment happen?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: why does ai and player NOT have shared index?

Post by knorke »

so commshare is broken by the engine?
no, by lobbies.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: why does ai and player NOT have shared index?

Post by hoijui »

it is the autohost, not a lobby. obviously, (the lobby of) player X does not have rights to disallow comshare of players A and B. for autohosts, it is a setting, which i think you can vote for (to enable/disable comshare, default is disabled, i think). it is not broken in the engine.

@smoth
i was the AI dev for a long time, and i told you how it is, and you are talking about guesswork... :P
i am not an active dev anymore, and i can not tell you how much work it really would be, but as i said.. the real problem is not that it would be a huge change in the engine, but that it could break basically everything outside of the engine that deals with players.
i am not an active dev anymore.. i have no intention to look at the code again, let alone to try to orchestrate such a change.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: why does ai and player NOT have shared index?

Post by knorke »

it is the autohost, not a lobby. obviously, (the lobby of) player X does not have rights to disallow comshare of players A and B.
Well in theory lobby can disallow comshare, by changing its own teamID. Like playerA tries to comshare with playerB, playerB's lobby notices that and fixes the teamID.
(which is what happens) But yes autohost doing it seems more likely.
Also either way the feature is unusuable by some lobbies because without seeing teamID one can not set up teams.
Post Reply

Return to “Game Development”