PDA

View Full Version : States, types or perhaps action IDs?



Bazcrown
03-01-2014, 03:26 AM
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
03-01-2014, 04:41 AM
Sure, take a look at this tutorial:
FSM style Mainloop (http://villavu.com/forum/showthread.php?t=58300)

Bazcrown
03-02-2014, 03:15 AM
Yes! Thank you very much

rj
03-02-2014, 06:12 AM
Yes! Thank you very much

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

Flight
03-02-2014, 07:35 AM
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
03-02-2014, 06:01 PM
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
03-03-2014, 12:46 AM
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
03-03-2014, 12:55 AM
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

http://i.imgur.com/BaKMlHE.png

Flight
03-03-2014, 02:22 AM
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.