I have no earthly idea how to do this so I have come to the dreadfully helpful forums.
OK say I have this proc... Start()
ok in that proc how would you make it do this:
make a new list and anyone in your view is in that list.
then the person with the highest Agility(a variable) in the list gets the variable Turn to equal 1.
Is that confusing? Or can you help......
ID:173303
Jan 23 2004, 5:47 pm
|
|
In response to Garthor
|
|
I almost understood that, its good to know that you know what im talking about but could you put that in code, I got confused the most on the "Loop until lowbound and highbound are the same." part.
This is what I have so far. var/list/L=new() L += src for(var/mob/M in oview(src)) var/lowbound = 1 var/highbound = L.len+1 |
In response to Cloudiroth
|
|
Okay, think of it like one of those guessing games.
You think of a number between 1 and 100, and the computer has to guess what it is. You tell it whether the number is too low, or too high. The goal is to eliminate the most answers with each guess. So, obviously, you guess the number that's in the middle. 50.5, rounded to 50. It's lower. Now, the only answers are 1 to 49. The number in the middle is 25 ((1 + 49) / 2). It's higher. Now the number is between 26 (25 + 1) and 49. So, the computer guesses 37. Lower again. The range is now 26 - 36. The guess is 31. Lower. 26-30. Guess is 28. Lower. 26-28. Guess is 27. Higher. 28-28. We have a winner. In the guessing game, you continue guessing until the lower bound of the possible numbers reaches the higher bound, at which point you've found the number. Alternatively, it could land on the number by chance, guessing it sooner. So, it's while(lowbound != highbound) |
In response to Garthor
|
|
I get it but I've tried to put to code what you said but I can't due to lack of knowledge of DM. Please can you put in coding what you put in words. I still don't get the other half. (I get it but dont know how it would look in coding.) And thanks for your help.
|
Cloudiroth wrote:
make a new list and anyone in your view is in that list. Oh dear. You're already starting off on the wrong foot. This is not the way to do a turn order list. A better approach is to either remove from the list as you go along, then recreate it when it's empty; or to create and sort the list, then use another var as an index (1, 2, 3, etc.) counting through it. Lummox JR |
Add src to L, as a starting point.
for(var/mob/M in oview(src))
var/lowbound = 1
var/highbound = L.len+1
Loop until lowbound and highbound are the same.
Get the mob at position round((lowbound + highbound) / 2) in L.
Check that mob's agility variable.
If M's agility is higher,
Set highbound to M's position in L.
If it's lower,
Set lowbound to that.
Otherwise,
Set lowbound AND highbound to that (loop will exit).
Copy the portion of L between 1 and lowbound-1
Copy the portion of L between lowbound and 0 (end of list)
Put the first portion, M, and the last portion together in that order.
Get the first mob in the list, set its Turn to 1.