SRL Archive - SRL Suggestions

Quiz.scar


NCDS

2011-01-19 20:52:59

Patch:

Index: quiz.scar
===================================================================
--- quiz.scar (revision 692)
+++ quiz.scar (working copy)
@@ -34,7 +34,9 @@
function InQuizRandom : Boolean;
begin
if (InBlack) then
- Result := (PercentBlackMM > 95);
+ Result := (PercentBlackMM > 95) and
+ InRange(CountColorTolerance(13882589, MSx1, MSy1, MSx2, MSy2, 13), 2700, 4200) and
+ (Length(GetMiniMapDotsIn('npc', MMx1, MMy1, MMx2, MMy2)) = 1);
end;
When running…

writeln(IntToStr(CountColorTolerance(13882589, MSx1, MSy1, MSx2, MSy2, 13)));
every output was between 3000 and 4000, but I added the extra to each end just to be safe.

Has been tested many times with this:

begin
SetupSRL;
ActivateClient;
if InQuizRandom then
begin
Writeln('in quiz');
SolveQuiz;
end;
if InCerterRandom then
Writeln('in certer');
end.
The certer stuff is in there to make sure there are no false positives as I'm working on that too. This has also been tested in the certer random a few times to check for the same thing. All attempts successful.

Output:

Compiled succesfully in 609 ms.
SRL Compiled in 15 msec
in quiz
Trout Fish Small, with a score of 9
Tuna Fish Big, with a score of 9
BattleAxe Small, with a score of 9
Use: Edible, Count: 2
Use: Weapon, Count: 1
We need to pick BattleAxe Small, and it's use is Weapon and located at slot 3
Tuna Fish Small, with a score of 9
Trout Fish Big, with a score of 9
Ring Small, with a score of 9
Use: Edible, Count: 2
Use: Jewelry, Count: 1
We need to pick Ring Small, and it's use is Jewelry and located at slot 3
Helmet Small, with a score of 9
Tuna Fish Big, with a score of 7
Trout Fish Small, with a score of 7
Use: Weapon, Count: 1
Use: Edible, Count: 2
We need to pick Helmet Small, and it's use is Weapon and located at slot 1
Sword Small, with a score of 7
Tuna Fish Big, with a score of 7
Trout Fish Small, with a score of 7
Use: Weapon, Count: 1
Use: Edible, Count: 2
We need to pick Sword Small, and it's use is Weapon and located at slot 1
Successfully executed.

Certer fix should be coming soon as well.

Nava2

2011-01-20 00:46:35

Only thing, would you mind posting what the colour is?

Also, could you run some speed tests, let us know how fast it is on average.

Did you also test with multiple compass angles?

NCDS

2011-01-20 20:41:42

From: Nava2
Only thing, would you mind posting what the colour is?

The color is the white from the spotlights around your char.

From: Nava2

Also, could you run some speed tests, let us know how fast it is on average.

The account is no longer in the random, but I've got ~12 more to check so hopefully one of them will be and I'll do this.

From: Nava2

Did you also test with multiple compass angles?

Yes, but never all the way down. Again, I'll test it that way if I have another account in the random. Could always just include a SetAngle(True); if really necessary I guess, but let me check what I have first.


Edit: Out of 65 accounts, only 1 was in quiz :closedeyes:

If anyone has an account in quiz please let me know and I will test Nava's suggestions. Until then, I'm on to Certer and Arnav.

Nava2

2011-01-20 21:15:47

From: NCDS
The color is the white from the spotlights around your char.


Please make that a constant with some description/doc.

From: NCDS

The account is no longer in the random, but I've got ~12 more to check so hopefully one of them will be and I'll do this.


OK, please report back, because this looks slightly slow.. See my later suggestions for speed increases. Remember, with functions like this, they must be fast to make sure they are not slowing down scripts unintentionally.

From: NCDS

Yes, but never all the way down. Again, I'll test it that way if I have another account in the random. Could always just include a SetAngle(True); if really necessary I guess, but let me check what I have first.

NO.

We must have our checks not modify the current state of the character. SRL should behave behind the scenes. When a script writer calls FindNormalRandoms, they do not want to worry about the compass angle having adjustment issues.


From: NCDS
Until then, I'm on to Certer and Arnav.

Careful you do not get too over your head.

To increase speed, perhaps Freeze() the client upon entering the function, then Unfreeze() it upon leaving the function. It removes the time taken for grabbing the client data each time. Considering all of these are necessary for the result to be true, we have to check all of them.

E: Because of Boolean `Short-circuit' evaluation, you should switch the last two parts of the result. GetDots is faster than CountColors I think.. if its not I apologize and take this as a friendly reminder of short-circuit evaluation with booleans. :) Its good to see you contributing btw ;)

NCDS

2011-01-20 21:42:12

From: Nava2
Please make that a constant with some description/doc.


InQuizSpotlight := 13882589; // White Spotlight color around your char
?

From: Nava2

OK, please report back, because this looks slightly slow.. See my later suggestions for speed increases. Remember, with functions like this, they must be fast to make sure they are not slowing down scripts unintentionally.

I will time it as soon as I get an opportunity.

From: Nava2

NO.

We must have our checks not modify the current state of the character. SRL should behave behind the scenes. When a script writer calls FindNormalRandoms, they do not want to worry about the compass angle having adjustment issues.

A few randoms do this. Frog and Abyss are 2 that come to mind immediately. Regardless, when I get another account in the random I'll be sure to make it unnecessary.

From: Nava2

Careful you do not get too over your head.

I like having set things to work on when I sit down to do something ;)

From: Nava2

To increase speed, perhaps Freeze() the client upon entering the function, then Unfreeze() it upon leaving the function. It removes the time taken for grabbing the client data each time. Considering all of these are necessary for the result to be true, we have to check all of them.

I will look into doing this when I test the time it takes.

From: Nava2

E: Because of Boolean `Short-circuit' evaluation, you should switch the last two parts of the result. GetDots is faster than CountColors I think.. if its not I apologize and take this as a friendly reminder of short-circuit evaluation with booleans. :) Its good to see you contributing btw ;)

I can't see CountColors being slower as it should only include FindColorsTolerance and the Result would be the Length, whereas GetMiniMapDotsIn has a case then FindColorsSpiralTolerance and a few conditionals. Now that I think about it, it would probably be quicker to just CountColor for the npc dot on the MM. I can test with that too if you think it might be beneficial. I generally keep timing with short-circuit evaluation in mind anyhow. ;)

Thanks for doing this btw Nava, I really appreciate it. :)

Edit: Arnav has SetAngle(True); as well. Is the goal to avoid that in SRL 5 I'm assuming? If so, I'll keep that in mind while fixing/rewriting the solvers.

Nava2

2011-01-20 23:14:38

From: NCDS

InQuizSpotlight := 13882589; // White Spotlight color around your char
?


srl_rand_QuizSpotlight = 13882589

Would be better.

From: NCDS
A few randoms do this. Frog and Abyss are 2 that come to mind immediately. Regardless, when I get another account in the random I'll be sure to make it unnecessary.


EEEK! I had no idea that they did.. If I had known I would have said something much sooner. Please, if you have time, feel free to change this so its not dependant on changing the compas angle.

From: NCDS
I like having set things to work on when I sit down to do something ;)

.. never a bad thing!

From: NCDS
I will look into doing this when I test the time it takes.

Can't really remember what this was in reference to.. >.<

E: I see now.. and I still have nothing to say !

From: NCDS
I can't see CountColors being slower as it should only include FindColorsTolerance and the Result would be the Length, whereas GetMiniMapDotsIn has a case then FindColorsSpiralTolerance and a few conditionals. Now that I think about it, it would probably be quicker to just CountColor for the npc dot on the MM. I can test with that too if you think it might be beneficial. I generally keep timing with short-circuit evaluation in mind anyhow. ;)


Great! I only brought it up so you could improve regardless if it was necessary in this instance. It is good to know more, eh? Because knowledge is power!

Check out the Freeze() and Unfreeze() functions though.. it makes a significant difference in the speed when you are doing multiple checks on something that should stay consistent. (no need to re-remind).

From: NCDS
Thanks for doing this btw Nava, I really appreciate it. :)

Happy to. Only thing is, I feel like I'm being rude.. but know I am happy with the work, I just want to see you improve. Thus, I'm being much more harsh on you than I might on others!

From: NCDS
Edit: Arnav has SetAngle(True); as well. Is the goal to avoid that in SRL 5 I'm assuming? If so, I'll keep that in mind while fixing/rewriting the solvers.

It was always the intention.. I thought at least. Perhaps this needs to be brought up elsewhere. When Zeph worked on the original system he had it have minimal effects, I always thought that was the intent.. Huh.

NCDS

2011-01-21 04:42:29

From: Nava2
srl_rand_QuizSpotlight = 13882589

Would be better.

Yeah, the '?' was because I wasn't sure what type of naming scheme you wanted to use. Although..

rand_Quiz_Spotlight = 13882589
may be a little more fitting as it should be obvious it's in SRL? Your the Dev though, and I have no objections to either one. :)

From: Nava2

EEEK! I had no idea that they did.. If I had known I would have said something much sooner. Please, if you have time, feel free to change this so its not dependant on changing the compas angle.

I think it's necessary for a couple thing's, but I've got plenty of accounts in randoms (all except quiz :() so I'll see what I can do to work around that.

From: Nava2

Happy to. Only thing is, I feel like I'm being rude.. but know I am happy with the work, I just want to see you improve. Thus, I'm being much more harsh on you than I might on others!

This is mentoring, no? and I can't thank you enough for doing it. :)

Nava2

2011-01-21 13:52:28

From: NCDS
Yeah, the '?' was because I wasn't sure what type of naming scheme you wanted to use. Although..

rand_Quiz_Spotlight = 13882589
may be a little more fitting as it should be obvious it's in SRL? Your the Dev though, and I have no objections to either one. :)


I agree with you on this one, but we have `srl_' prepended to all of our constants. Should probably stick with that.. also, uppercase consts ;).

From: NCDS
I think it's necessary for a couple thing's, but I've got plenty of accounts in randoms (all except quiz :() so I'll see what I can do to work around that.


Great! Unfortunately, I do not have time to do it right now. :(

From: NCDS
This is mentoring, no? and I can't thank you enough for doing it. :)


Call it what you want, I get excuses to be harsh! :stirthepot: <3

lordsaturn

2011-01-22 14:22:34

Here's a critique: contribute something original and/or innovative, not just fixing bugs.

NCDS

2011-01-22 15:11:07

From: lordsaturn
Here's a critique: contribute something original and/or innovative, not just fixing bugs.


I don't control what new material Jagex updates RS with, and I also see no point in re-writing code that already works.

If you have any thought or suggestions, I'm very open to them. Otherwise, I'll continue to wait for an update.