SRL Archive - SRL Development and Help

States, types or perhaps action IDs?


Bazcrown

2014-02-28 22:26:51

Hey guys, I'm working on a couple of personal scripts for RS3. My main project is to achieve increased artificial intelligence in a high-alching bot. The issues I'm having are that with color picking, bitmaps and DTMs there's really only a finite amount of flawlessness offered. I'm use SMART w/ openGL instead of the browser so I guess I'm just hoping that there's a better way to detect/check if the user is in what state. <– Also a question.
Bazzy

Flight

2014-02-28 23:41:43

Sure, take a look at this tutorial:
FSM style Mainloop

Bazcrown

2014-03-01 22:15:41

Yes! Thank you very much

rj

2014-03-02 01:12:14

From: Bazcrown
Yes! Thank you very much


FSM is great for short scripts but be aware, for longer script it may null out and fail

Flight

2014-03-02 02:35:37

From: Officer Barbrady
FSM is great for short scripts but be aware, for longer script it may null out and fail


Monkfishies 2.0, which I'm using as my random-trigger script, uses a FSM-style loop and it runs through 5 cycles, I've never had any problems so far. Could you explain in what instance a a longer, complicated script might "null out" as a result of using FSM?

rj

2014-03-02 13:01:23

From: Flight
Monkfishies 2.0, which I'm using as my random-trigger script, uses a FSM-style loop and it runs through 5 cycles, I've never had any problems so far. Could you explain in what instance a a longer, complicated script might "null out" as a result of using FSM?


If a boolean ins't checked properly (such as like.. checking if at a mine is left out)

Flight

2014-03-02 19:46:57

From: Officer Barbrady
If a boolean ins't checked properly (such as like.. checking if at a mine is left out)


Sorry I guess I don't follow what you mean. Could you provide an example script with a FSM loop that would 'null out'? Perhaps I could point out what the problem is.

rj

2014-03-02 19:55:41

From: Flight
Sorry I guess I don't follow what you mean. Could you provide an example script with a FSM loop that would 'null out'? Perhaps I could point out what the problem is.


It's not the FSM itself, it's in longer scripts where it could get more and more confusing


Flight

2014-03-02 21:22:11

The warning he was giving there is that using a FSM style loop could just become difficult/complicated, but there's no issues from using this style of loop/architecture. Luckily we have Lape which makes such methods, like determining the script's current cycle, much easier. Here's an example:

PS:

Function getState(): State;
begin
if not isLoggedIn() then
Exit;

if Me.inCombat() then
result := BANKWALK;

if result <> 0 then
Exit;

if insideBank() then
begin
if (isInvFull() or (not hasEquipment)) then
result := BANKING;
if result <> 0 then
Exit;
result := SPOTWALK;
end;
end;

Lape:

Function getState(): State;
begin
if not isLoggedIn() then
Exit;

if Me.inCombat() then
Exit(BANKWALK);

if insideBank() then
begin
if (isInvFull() or (not hasEquipment)) then
Exit(BANKING);
result := SPOTWALK;
end;
end;

With Lape we could exit and pass along the result of a function at the same time, so there won't ever be more than one result.