-
Finding Lowest Value
Well the head's blagged after a further 9 hours of development. Trying to think of a way to find the lowest alterable A value of 8 objects... Usually I would be able to sit there n think for 20 minutes and come up with a solution, but I just can't seem to find one. Don't fancy using Arrays as the whole engine is condition based on every slight change, so array just not good enough. Thought of database, but don't want to bog the engine down.
8 Independent Actives (not same object) > Alterable Value A of each holds a value.
Need to find lowest out of the 8, anybody wanna throw something at me?
-
Re: Finding Lowest Value
-
Re: Finding Lowest Value
OK, this is off the top of my head and I do NOT have MMF on this machine.
idea 1:
Pick on of the objects and use 7 of its Alternate Values to store the Alt_A values of the other 7 Actives. (use some common event to keep this updated) [example R thru Y]
Create a group (not active)
Set Alt_Z = Alt_A
Using a series of events check to see if Alt_R is less than AltZ, if true set Alt_Z = Alt_R.
Repeat for each alternate value. When complete you will have cycled thru R to Y and Alt_Z will be the lowest value. Close the group.
This is most likely NOT the cleanest coding but for different objects it should work.
idea 2:
Put the 8 Actives in the same qualifier.
When needed, spread a vaule to the qualifier Alt_Z (or any unused) value. Then with a loop check for the Qualifier Alt_Z value to be equal to the loop index AND the Alt_A value to be lower then say a global value. If true then set the global value (or some other holding location) to the Alt_A value.
If you dont get a definitive answer soon let me know and I will try to work up an example.
-
Re: Finding Lowest Value
okay, dragon's post seems a good manual way of doing it, same with DT's, but I did happen to come across the INI++ comment on drag's post which i had never used before either, seems interestingly able to find the lowest values without much work... although to me, using plugins and extensions are good, efficient and effective, to me it's not educational, i'd rather take the long, maybe untidy way round of doing the math's myself, so will scrap the ini++ object and try one of the manual ways, just for self pride haha!
Will do it in the morning and give an update, need bed now before I end up waking up to a keyboard imprint again!
-
Re: Finding Lowest Value
Or for a less manual solution, check the Select Object, which I originally made for the sole purpose of finding the object with the highest/lowest alterable value...
It essentially works the same as DT's 2nd method, looping all the objects and recording what the lowest value is as it goes.
-
Re: Finding Lowest Value
-
Re: Finding Lowest Value
So much for you going to bed :P
-
Re: Finding Lowest Value
lol, once I get stuck in hard to get away, I managed to get to bed in the end though! Gonna implement and test the methods now!
-
Re: Finding Lowest Value
Rainchecked. Select object seems to do the job perfect. After thinking with a clear mind, I actually WOULD rather take this route than the extensive equation sorting conditions, i've already learnt enough in my time!
Cheers Dyna, will ensure you are listed in Credits.
-
Re: Finding Lowest Value
-
Re: Finding Lowest Value
Do you ever use the forum chat Dyna - for a few simple questions? I've managed to utilise the extension, but i'm having difficulty extracting the exact object...
Danny
-
Re: Finding Lowest Value
I'll sign into it tonight, say in 5 hours?
-
Re: Finding Lowest Value
Or now, as there's a web-based client.
-
Re: Finding Lowest Value
Frig! Ok, done some serious and vigerous testing and debugging here, but still got an issue Dyn!
I have set each active to have an global string for the name and a global value when the lowest is detected, this way through debugging the game when it's the AI's turn it displays the correct company with the lowest score, displays the name and value, which to me is correct. Now it minuses the correct amount from cash available and also buys the relevant shares, however, it also purchases 10 from every other company too (at the start they all have equal amounts of shares) so maybe a bug?
It displays the correct chosen active from the qualifier, but the actions on the event (which are limited only to the qualifier) are also affecting all other actives that do not qualify, or maybe they do qualify (hence the purchase of all of them instead of just the one) - mmf bug, or collision with your object in the condition, in other words it's ignoring the condition?!
Also to note, it only purchases once, on the next round which is on a loop (not a function loop) just a procedural loop, it doesn't purchase... any idea's?
-
Re: Finding Lowest Value
Send me the file, I'll have a look.