Everything posted by Scripts
-
Fruity NMZ
For some reason the bot will just stop reOverloading after like an hour, am I doing something wrong? EDIT: Had breaks enabled, that was probably it. I will run again and see if that fixed it.
-
Anagram C++ Help
I am to write a program that will take 2 strings, put them into a function called "build_histogram" and build a int array that keeps count of how many times each letter appears in each string, then compare the arrays and if they are equal, then they are anagrams. The instructions state we are to ignore all symbols(ex. !, whitespaces, _, etc.) and it is not to be case sensitive. This is my code now...it counts the number of characters correctly in each string, the only issue now is the "if else" statement at the bottom still doesn't recognize that the arrays are the same, also it's having a hard time when symbols like '!' are in the strings. #include <iostream> #include <string> #include <cctype> using namespace std; void build_histogram(int letters[], string s) { for(int i = 0; i < s.length(); i++) { char currLetter = s[i]; currLetter = tolower(currLetter); int index = currLetter - 97; letters[index]++; } } int main() { string s1, s2; int histogram1[26] = {0}; int histogram2[26] = {0}; cout << "Enter two strings." << endl; getline(cin, s1); getline(cin, s2); build_histogram(histogram1, s1); build_histogram(histogram2, s2); if (histogram1 != histogram2) { cout << "They are not anagrams." << endl; } else { cout << "They are anagrams!" << endl; } return 0; }
-
Need help with C++ Random Number Generation
It wasn't wrong, he just did it a random ass way.....I finally got it figured out #include <iostream> #include <cstdlib> using namespace std; int newFunction(int count, double probability) { double random; int total = 0; for(int i = 1; i <= count; i++) { random = rand()/(double)(RAND_MAX + 1) + 1; if (random < probability) { cout << random << endl; total++; } } return total; } int main() { cout << "Enter integer for seed: " << endl; int seed; cin >> seed; srand(seed); int c; double p; cout << "Enter the count of numbers to be generated: " << endl; cin >> c; cout << "Enter the probability: " << endl; cin >> p; cout << "Number of generated random numbers less than probability entered is " << newFunction(c, p) << endl; return 0; } I had to change the random = rand()/(double)(RAND_MAX); to random = rand()/(double)(RAND_MAX + 1) + 1;
- Need help with C++ Random Number Generation
-
Need help with C++ Random Number Generation
So my wonderful CS teacher has decided he's going to make our class revolve around ease for himself(instead of trying to make his students better at programming).... BUT ANYWAYS....He gives us little info on how the program is to be written, and if we don't write it EXACTLY like he would, we don't get credit. I think I have written a working program(that does what he asks), but the hidden test cases keep failing so I could really use some help. INSTRUCTIONS Write a function that takes an integer “count” and a double “probability" Generate “count” random numbers between 0.0 and 1.0 Print the number of generated random numbers that is less than “probability” Call this new function from main() MY CODE #include <iostream> #include <cstdlib> using namespace std; int newFunction(int count, double probability) { double random; int total = 0; for(int i = 0; i < count; i++) { random = (double) rand() / RAND_MAX; if (random < probability) { cout << random << endl; total++; } } return total; } int main() { cout << "Enter integer for seed: " << endl; int seed; cin >> seed; srand(seed); int c; double p; cout << "Enter the count of numbers to be generated: " << endl; cin >> c; cout << "Enter the probability: " << endl; cin >> p; cout << "Number of generated random numbers less than probability entered is " << newFunction(c, p) << endl; return 0; } PROGRAM INPUT 1 //seed 3 //number of random numbers (count) 0.5 //value for probability MY OUTPUT Enter integer for seed: 1 Enter the count of numbers to be generated: 3 Enter the probability: 0.5 0.394383 Number of generated random numbers less than probability entered is 1 HIS OUTPUT Enter integer for seed: 1 Enter the count of numbers to be generated: 3 Enter the probability: 0.5 0.159812 0.216901 Number of generated random numbers less than probability entered is 2 He gave us this as a skeleton for the code: #include <iostream> #include <cstdlib> using namespace std; int newFunction(int count, double probability); int main() { cout << "Enter integer for seed: " << endl; int seed; cin >> seed; srand(seed); int c; double p; cout << "Enter the count of numbers to be generated: "; cin >> c; cout << "Enter the probability: "; cin >> p; cout << "Number of generated random numbers less than probability entered is " << newFunction(c, p) << endl; return 0; } I don't have a clue as to what I'm doing wrong. He uses an online textbook where he inserts his "key code" then when we run our code it compares the outputs and determines if they are the same. We are using the same compiler, and I am almost positive we are to use rand(). Please, I really need help...Thank you
-
One off Bot? Bob - the surviving bot
Has to be
-
Khal Tutorial Island
That's the same issue I'm having
-
Khal Tutorial Island
Can't get this to work ;/ with my bot manager
-
Scripts' Power Miner
Wrote this tonight in about 3 hours...how does it look so far? Also, would like to know how to add some anti-ban type behavior. import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "AIOMiner", author = "Scripts", version = 0.1, info = "", logo = "") public class main extends Script { private long startTime; @[member=Override] public void onStart() { startTime = System.currentTimeMillis(); log("Welcome to Scripts' AIOMiner."); log("If you have any issues or suggestions, please contact me via forums."); } public final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } private enum State { MINE, DROP, WAIT }; private State getState() { RS2Object tinRock = getRockWithOre(Rock.TIN); if (inventory.isFull()) return State.DROP; if (tinRock != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) return State.MINE; return State.WAIT; } @[member=Override] public void onExit() { log("Thanks for using Scripts' AIOMiner."); log("If you had any issues or suggestions, please contact me via forums."); } @[member=Override] public int onLoop() throws InterruptedException { switch (getState()) { case MINE: RS2Object tinRock = getRockWithOre(Rock.TIN); if (tinRock != null) { tinRock.interact("Mine"); sleep(random(2000, 3000)); mouse.moveVerySlightly(); } break; case DROP: if (inventory.isFull()) { vDrop(); break; } case WAIT: sleep(random(500,700)); break; } return random(200,300); } @[member=Override] public void onPaint(Graphics2D g) { final long runTime = System.currentTimeMillis() - startTime; Point mP = getMouse().getPosition(); //mouse X g.drawLine(mP.x - 5, mP.y + 5, mP.x + 5, mP.y - 5); g.drawLine(mP.x + 5, mP.y + 5, mP.x - 5, mP.y - 5); g.setColor(Color.white); g.setFont(g.getFont().deriveFont(18.0f)); g.drawString("Run Time:" + formatTime(runTime), 10, 335);//runntime } public enum Rock { CLAY(6705), COPPER(4645), TIN(53), IRON(2576), SILVER(74), COAL(10508), GOLD(8885), MITHRIL(-22239), ADAMANTITE(21662), RUNITE(-31437); final short COLOR; Rock(final int COLOR) { this.COLOR = (short) COLOR; } } public RS2Object getRockWithOre(Rock rock){ return getObjects().closest((RS2Object obj) -> { short[] colors = obj.getDefinition().getModifiedModelColors(); if(colors != null){ for(short c : colors){ if(c == rock.COLOR) return true; } } return false; }); } public static final int[] MOUSEKEY_DROP = new int[]{ 0,4,8,12,16,20,1,5,9,13,17,21,2,6,10,14,18,22,3,7,11,15,19,23}; public void vDrop() { for (int i : MOUSEKEY_DROP) { getInventory().interact(i, "Drop"); } inventory.dropAll(); } }
-
Hello!
Hey guys, been around the RS botting community for a looooooong time! Decided I would join OSBot since a certain other botting community requires VIP to write/run local scripts *cough*.....I have decided I'm going to teach myself how to write simple RS scripts and slowly but surely improve them! Hope to be making scripts for all of you very soon ;)