adding a loop function which decreases by a value

halfvoid

Member
Hi. I have zero experience in editing ASH script but wanted to know if someone could help me alter this MMG code to use a different betting scheme. I'd prefer to learn the function or how to implement it rather than just have someone throw it in as i'd like to get into scripting.

I bet in increments of 1k, 2k, 6k, 18k, 54k, 162k, 486k, 1458k and have them set into the bottom of the script.

I start off with 5 bets of 1k, then for however many lose, i bet that many of the next increment, until all have been won, then i start over again at 1k.

i.e.
bet 1k 1k 1k 1k 1k
lose 3
bet 2k 2k 2k
lose 1
bet 6k
lose 1
bet 18k
win
(repeat)bet 1k 1k 1k 1k 1k (and so on...)

As it works now. It will run through this betting scheme but with only one bet running.

Any help will be greatly appreciated.

Link to original thread for script here
 

Attachments

  • hvMMGbet.ash
    2.8 KB · Views: 38
Last edited:

mredge73

Member
I have never used or looked at the original but I will comment on yours.
Looks like there is something missing on this script, The way I read it it bets one of everything and then quits.

1: your function bet_five_times only bets once. So I would changed it to bet_once to keep from confusing you (and me)

2:you should probably increase your wait time int place_bet, it will give a lot of server hits if it has to check every 5 seconds if someone took your bet. I would at least wait a minute: wait(60);

3:the boolean place_bet returns true if you win, false if you lose.

4: use for loops, you can do your first loop like this:
Code:
int wins1=0;
int lose1=0;
for i from 1 upto 5
{
     if (place_bet(1000, usehagnksmeat)) 
          wins1 = wins1 + 1;  
     else
          lose1 =lose1 +1;
}

5: your second like this:
Code:
int wins2=0;
int lose2=0;
for i from 1 upto lose1
{
     if (place_bet(2000, usehagnksmeat)) 
          wins2 = wins2 + 1;  
     else
          lose2 =lose2 +1;
}

6: you can build this loop into a function so you don't have to keep writing it:
Code:
int Bet(int howmany, int howmuch)
{
int wins=0;
int lose=0;
for i from 1 upto howmany
{
     if (place_bet(howmuch, usehagnksmeat)) 
          wins = wins + 1;  
     else
          lose =lose +1;
}
return lose; //or win if you want your wins returned
}

//to use
int lose=5;
lose=Bet(lose,1000);
lose=Bet(lose,2000);
lose=Bet(lose,6000);
//and so on

I haven't tested this, but this function should do what you ask. If you get it working post it and let us know.
 
Last edited:

halfvoid

Member
Okay. With what you showed me i can get it to run through the 5 bets one time. How do i use that void main thing to set the number of times i want to run the 5 bets? can't figure out which function actually does the betting.
 

Attachments

  • hvMMGbet2.ash
    2.1 KB · Views: 35

mredge73

Member
take a closer look at the for loop in Bet.
Not sure if you want to learn this yourself or you want me to do it for you.

The way a that particular for loop works is this:

for intname from start upto finish
{DoSomething(intname);}

The For loop declares an integer variable called intname and sets it equal to start, this can be used by DoSomething(intname) by passing it as a parameter.
This variable is incremented with each iteration by "upto" until it equals "finish"

so:
Code:
void main()
{
int howmany=5; //enter how many times you want to run the loop
for i from 1 to howmany
{
DoSomething();
}
//end
}
 

halfvoid

Member
oh oh. am i wrong in thinking that void main is what makes the popup appear when the script is run in KOLmafia?
 

mredge73

Member
void main does not make a popup appear unless you have missing parameters in void main.

for example:
void main() =no popup

void main(int Something) = popup, please enter an integer for Something

if you wanted the popup you would just make howmany a parameter:
Code:
void main(int howmany)
{
     for i from 1 to howmany
     {
          DoSomething();
     }

}

can't figure out which function actually does the betting.
The function that does the betting is Zarqon's function place_bet(), you see the visit_url() that is where your request is actually placed into KOL. These are a little tricky and take some knowledge of HTML so start on learning the basics. If you are new at programming and interested in learning a little pick up a cheap beginners guide for whatever language you want to learn, they are all very similar when you get to the higher end languages. This scripting is fun because it forces you to learn a little about java, javascript, html, and php. To tell you the truth, I don't even know what language we are working with when coding ASH. My experience is in latter logic, C, C++, microchip pic and this is very close to C.
 
Last edited:
Top