ID:174850
 
/me cries because I'm posting on newb forum, lol

--Okay, I know I could code this if I really put work into it but, you guys know me! =D

I'm working on a game I call Antopia, originally known as Simant BYOND by The Brotherhood. Now, In the game is the stat"colony health" which means the overall hunger for one team.

Basic 1337 skillzerz telz meh (trying to be obnoxious)that I need to average the hunger. By doing the total number of ants on dat team's hunger divided by the number of ants on dat team....I need a working formula.
Well, everyone knows the averaging formula, right? In fact you mentioned it. So you've got your formula, but you don't know how to implement it. =)

Assuming you're using a list to store all the ants in the colony (which you should be)...
var/totalhunger=0
for (var/mob/ant/A in colonylist)
totalhunger += A.hunger

if (length(colonylist))
src << "Colony health: [totalhunger/length(colonylist)]"
else
src << "No ants in colony." //To avoid a division by zero error if the list has a length of zero
In response to Crispy
You see the only problem with that is too implement it would take rewiring of vars and setting them at different times.
In response to ManDroid13
Wait maybe I was wrong if I made some new vars I could easily add something like the sample you gave me, Crispy, come check Antopia out sometime ;)
In response to ManDroid13
Shouldn't be too hard to adapt that snippet. If you're not using a list to store the colony, you COULD loop through all ants in the world, checking to see if they're in the colony before adding them to the list. It'd be slower though, which is especially crucial considering it's going to be used in Stat().

I might drop in if it's up... never know... =)
In response to Crispy
Crispy wrote:
Well, everyone knows the averaging formula, right? In fact you mentioned it. So you've got your formula, but you don't know how to implement it. =)

Assuming you're using a list to store all the ants in the colony (which you should be)...
var/totalhunger=0
> for (var/mob/ant/A in colonylist)
> totalhunger += A.hunger
>
> if (length(colonylist))
> src << "Colony health: [totalhunger/length(colonylist)]"
> else
> src << "No ants in colony." //To avoid a division by zero error if the list has a length of zero


Yes, This snippet is easy to add now that I think of it one thing though... The engine of my game is written in a similar but different style of coding then I use. The original engine is less 'compiled' then I would of made it. It makes you do duplicates of everything. I know I can do it...But I'm gonna spend atleast 4 mins tryin to find a good place to put it.