ID:174850   Jul 14 2003, 5:36 pm /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.
 Jul 14 2003, 5:41 pm 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=0for (var/mob/ant/A in colonylist) totalhunger += A.hungerif (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 ```
 Jul 14 2003, 5:51 pm 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.
 Jul 14 2003, 5:54 pm 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 ;)
 Jul 14 2003, 8:08 pm 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... =)
 Jul 15 2003, 8:36 am 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.