counter problems & ore farming optimization!

I'm running Windows XP SP2, Java 1.6.0_11, and KoLmafia v13.3.1.

Hi guys. I'm trying to write a ore farming script and am getting closer, but I have a few hang ups. I drew heavily from Nightmist's Barrel.ash for the creation of this script. It's located here.

Basically the script I have will get & equip mining gear and then proceed to click every wall in Itznotyerzitz Mine. Once all walls are gone it will "Find New Cavern", but then it stops.

There are two parts that are not working.

1)
Code:
if(Counter == 49 || Counter == 41 || Counter == 33 || Counter == 25 || Counter == 17)
	{
	wall(Counter);
	Counter = Counter - 3;
	}

This doesn't seem to be working. The script still tries to click on wall 48 and 39 and all the other #'s that don't correspond to actual walls.

2)
Code:
if(Counter == 8)
	{
//Find New Cavern (reset mine)
	visit_url("mining.php?mine=1&reset=1&pwd");
//Reset counter to 54
	wall(Counter);
	Counter = Counter + 46;
	//for testing
	print("Counter is currently set to " + counter + "!");
	}

This does effectively change the counter back to 54, however once this happens the script stops mining. I've been trying to figure out how to keep the script mining. Any help would be awesome.

Also after I get this going properly I plan on trying to optimize it a bit. Right now it mines every wall taking 36 adventures in all!! Not extremely effective. I have a few ideas like only mine the top three rows and working with clusters of ore, but any optimization ideas would be very helpful as well!
 
Last edited:

mredge73

Member
1
you got your while loop in the wrong place, it only hits that routine once when counter = 54
try the attachment for the number one fix


2
I did not fix this in the attachment, not sure what you want. How many times do you want it to run?
I don't understand exactly how you want it to work.

Replace the attach loop with this one to have it mine until you run out of adventures.
This will need additional work, it will not automatically handle beating up and such, and it is actually an infinite loop.
You need to create an exit condition in the loop, setting the counter > than 54 will allow the loop to terminate.


Code:
while(Counter <= 54 )
{
		
switch
{
case Counter == 49 || Counter == 41 || Counter == 33 || Counter == 25 || Counter == 17:
	wall(Counter);
	Counter = Counter - 3;
	break;
case Counter == 8:
	//Find New Cavern (reset mine)
	visit_url("mining.php?mine=1&reset=1&pwd");
	counter=54;
	//for testing
	print("Counter is currently set to " + counter + "!");
        break;
default:
	wall(Counter);
	Counter = Counter - 1;
        break;
}		
		
}
 

Attachments

  • farm mine1.ash
    2.2 KB · Views: 22
Last edited:
mredge73 thank you! :)

An infinite loop was exactly what I was looking for. The script will now mine for the specified amount of ore and then stop. I've got to work on the optimization now. It uses quite a few adventures. :eek:

I've never used or heard of the switch, case, and break commands. They are not in any of the ASH tutorials or references that I've read and I have no previous programing experience. Are there other ash tutorials that I missing out on?

Thanks again for your help.
 

mredge73

Member
the switch command is just an elegant way of putting a grouping a bunch of if()else() statements. It is also easier to read and write, a bunch of newer scripts use it, it is new compared to most of the other stuff.

case <boolean>: this is the same as an if, you can put any boolean condition in here and it will check it and execute what is below it only if the condition is true.

default: this is the default case, if no other case is fulfilled then the switch will do this.

break; exits the switch without checking any other conditions.
 

Veracity

Developer
Staff member
FWIW, rather than:

Code:
switch
{
case Counter == 49 || Counter == 41 || Counter == 33 || Counter == 25 || Counter == 17:
	...
	break;
}

... you might consider:

Code:
switch ( Counter )
{
case 49:
case 41:
case 33:
case 25:
case 17:
	...
	break;
}
 
Wow, nice! Thanks for the input guys. Sometimes I try to just take ideas and examples from other scripts, but most of them are so advanced that it doesn't help me any. Your help and input is very appreciated!
 
Top