HCA97 / jw_bot

Jurassic World Alive Bot for Collecting Resources
MIT License
3 stars 0 forks source link

How to use #2

Closed TSChampion closed 1 year ago

TSChampion commented 1 year ago

I followed your instruction, stuck at the install requirement.txt because I don't know where to store the requirement.txt could you please give more details?

HCA97 commented 1 year ago

Hi,

You don't have to save the requirements.txt file anywhere. You only need to install the packages mentioned in the requirements.txt file. This can be done by using the command pip install -r requirements.txt. Before you do that, ensure that Python is installed and added to your PATH variables.

If you encounter issues while installing any of the packages, you can find the installation files at this link. Simply search for the package you need and install the appropriate wheel file based on your Python version and chip type (32-bit or 64-bit).

Additionally, when you install Tesseract don't forget to set the path appropriately:

https://github.com/HCA97/jw_bot/blob/bdcc9eea3503d8e6ef1b501d6902f0dcd3f8bfab/jw_bot.py#L14

Note The last time I played Jurrasic World Alive was 1 year ago before they ruined each class. I am not sure if the detection part still works since it is based on color.

TSChampion commented 1 year ago

here is the error when I ran the main.py, seem is missing a picture, is this OK to run? Press Ctrl-C to quit. Traceback (most recent call last): File "C:\Users\kent1\AppData\Local\Programs\Python\Python311\main.py", line 17, in bot = Bot() ^^^^^ File "C:\Users\kent1\AppData\Local\Programs\Python\Python311\jw_bot.py", line 107, in init self.moved_too_far_pic = Image.open(r'figs/moved_too_far.PNG') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\kent1\AppData\Local\Programs\Python\Python311\Lib\site-packages\PIL\Image.py", line 3218, in open fp = builtins.open(filename, "rb") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'figs/moved_too_far.PNG'

TSChampion commented 1 year ago

seem many changes since you quit playing this, I tried but it only collect one supply chest then stop if you have time, please help to update the bot thank you! unlucky for me that there is no bot for this games right now, but yours

HCA97 commented 1 year ago

Hi,

I've managed to run my code successfully with only minor modifications. The UI seems to have stayed relatively unchanged since I stopped playing.

I encountered issues due to some packages being deprecated. To address this, I've created a file named requirements_detailed.txt. If you encounter errors related to third-party packages (such as numpy, PIL, etc.), you can reinstall the packages using requirements_detailed.txt, as it contains the exact versions matching my local setup. Additionally, I'm using Python 3.9, but I believe it should work on other versions of Python 3.x.

Tips and Tricks

How to select Blue Stack

  1. Select the top left corner and press A (red)
  2. Select the bottom right corner and press A (blue)

image

Selection Code:

https://github.com/HCA97/jw_bot/blob/02958f02086f94590389c9fc5ac7c4e176fabce3/main.py#L21

Running BlueStacks in Non-Full Screen Mode

When running the BlueStacks app, avoid using full-screen mode. I've hardcoded button locations, so using full-screen mode will cause a mismatch in these locations.

Correct Example

Example Image

Incorrect Example

Example Image

Zooming Out for Optimal Results

Correct Example

Example Image

Incorrect Example

Example Image

Using test_action.py for Assistance

A file named test_action.py serves as a visual aid for hardcoded locations (run it like the bot). When executed, a matplotlib plot will appear, displaying important locations:

Map

Map

Moved Too Far

Example Image

Supply Drop

Example Image

Dino

Example Image

Adjusting time.sleep

Depending on your computer and internet speed, the amount of lag can vary. You might need to change the sleep time after performing an action. Key locations to adjust are:

Best Country for Bot Usage

During my bot runs, I found Japan, Tokyo to have more dinosaurs compared to other parts of the world. This experience was shared by some friends as well. So, for optimal results, I suggest staying in Japan, Tokyo. (This should work in other parts of the world too)

Google Maps Location: Japan, Tokyo

Monitoring and Stopping the Bot

Sometimes the bot might act unexpectedly and click on unintended items. I recommend keeping an eye on it for the first few minutes after starting. If it behaves well during this time, it should continue smoothly. To stop the bot, simply press the q key on your keyboard.

Color-Based Detection

Much of the detection relies on color-based mechanisms. During events like Christmas, you might need to adjust the following parameters:

Note: While a more robust detection would be ideal, I haven't had the time to gather and annotate data for training a classifier.

Bot's Main Purpose: Daily Missions

This bot is primarily designed for collecting daily missions and obtaining better rewards from Alliance weekly chests. It's okay at hunting dinosaurs, but I think its best features is collecting coins.

Limited Number of JW Alive Bots

The scarcity of JW Alive bots is likely due to diminishing returns. This means that the more supply drops you collect, the fewer resources you obtain—this applies to coin chests as well.

Conclusion

I hope you find this information helpful. Setting up might be a bit tricky at first, but once you've done it, the JW bot will let you focus on the fun part of the game, which is arena and raids :)

I've shared this code with friends, and they had similar experiences. While the initial setup took some time, they no longer needed to worry about resource collection (except for legendary/epic dinosaurs in weekends).

TSChampion commented 1 year ago

Incredible, It works fine with me, thank you very much, now I can have a good sleep every night :D

HCA97 commented 1 year ago

I am glad it works. If you encounter errors, let me know. If it is a quick fix (takes 1-2 days) I can try to fix it.

Note I don't think running the bot is the most optimal strategy. After a while, supply drops and coins chests will drop darts only, and most of the DNA you collect will be from common dinos.

TSChampion commented 1 year ago

when the script clicks on the dino, there are 3 actions the script makes:

  1. launch for fight (25%)
  2. Cancel (35%)
  3. Keep random click like on the map until it clicks on the cancel button to go back to the map (40%) I think it happens because of the internet speed, when one random click touches the dino, the following click appears so fast, that it can't detect whether it is a dino or not (this is what I think when I observe the bot). could you please show me where I can but some delay between random clicks. To solve this by myself 😮‍💨 , I use the "automatic mouse & keyboard software" to force click on the "Launch button" when the Random click on the Dino, This can help, but the bot didn't activate the "Time to shoot" action :D. if you don't have time, please show me how can I prioritize the "time to shoot" before other actions to let me force catch the dino myself, but if you have time, please help to fix that.
HCA97 commented 1 year ago

Hi,

So I do not 100% understand what you mean but it seems like your problem is:

When the bot detects a dinosaur and clicks on it, the time it waits after the click is too short. As a result, the bot mistakenly identifies it as not a dinosaur and attempts to click on the button (x). However, during this time, the dinosaur is still loading, leading to an incorrect button click, and subsequently, the bot becomes stuck on the dinosaur screen.

If this is indeed the issue you're referring to, you should adjust the sleep duration in the following sections of your code:

https://github.com/HCA97/jw_bot/blob/552902657dd8d3536420480daa1a2cbf35d3473a/jw_bot.py#L782

https://github.com/HCA97/jw_bot/blob/552902657dd8d3536420480daa1a2cbf35d3473a/jw_bot.py#L791

If this doesn't those two lines don't resolve your problem, you may want to look at the following functions:

Maybe increase the sleep duration by 0.5 seconds for each sleep interval.

I hope this helps :)

TSChampion commented 1 year ago

your "time to shoot" is incredible, If I want to change the script to search & catch Dino only, please advise me which part should I delete?

HCA97 commented 1 year ago

Thanks :)

If you're interested in seeing how it works, you can watch this YouTube video.

You have the flexibility to choose what you want to collect by commenting or uncommenting specific functions in main.py. The function names are self-explanatory, and you can find them here [Link to Code]:

  # get coins
  bot.collect_coin()

  # get supply drops
  bot.collect_supply_drop()                                 

  # get dinos
  bot.collect_dino()

Note: If you choose to collect dinos continuously, keep in mind that you'll run out of darts fast. If your goal is primarily to collect dinosaurs, I recommend you to, collect supply drops as well because they always drop darts.

TSChampion commented 1 year ago

I added "time.sleep(0.5)" below the "pos = []" of the "def detect_dino" help me attack 100% dino :D The app crashed after 1-2hrs playing JWA, do you have any solution to stop crashing, please advise to me

HCA97 commented 1 year ago

What do you mean by "JWA crashes"? the bot crashes or the game crashes? If it's the game that's crashing, unfortunately, we can't fix that. If the game crashes frequently, you might consider reporting the issue on the JWA forum. Just be sure not to mention that you were using a bot 🙂

By the way, when the crash happens, what exactly occurs? Do you get sent back to BlueStacks' main menu, or do you find yourself stuck on the game's loading screen? If you're stuck on the game's loading screen, there's a possibility that the bot can recover from it.

TSChampion commented 1 year ago

the app crashes on Bluestack & LD player, the bot is working fine. thank you very much.

HCA97 commented 1 year ago

then there is nothing I or you can do. You can send Bluestack a ticket and maybe they can help you.

HCA97 commented 1 year ago

Hi, I will close the issue but feel free to open it again