Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random movement but no action #5

Open
gauravyadav26 opened this issue Feb 11, 2024 · 22 comments
Open

Random movement but no action #5

gauravyadav26 opened this issue Feb 11, 2024 · 22 comments

Comments

@gauravyadav26
Copy link

After marking top and bottom cursor starts to move and console starts logging and it keep on happening but nothing happens in the game.

@HCA97
Copy link
Owner

HCA97 commented Feb 12, 2024

Hi @gauravyadav26,

What do you mean when you say nothing happens? Does the screen rotate after a while? What messages do you see in the logs? This could be a timing issue or a problem with the detection algorithm.

If it's a timing issue, you can check out this thread: (#4). Unfortunately, timing problems can be a bit complicated because of differences in internet and hardware speeds.

If the detection algorithm isn't working well, you'll need to adjust the following RGB values:

Additionally, you can check out this thread for some tips and tricks #2 (comment)

@gauravyadav26
Copy link
Author

gauravyadav26 commented Feb 13, 2024

It keeps saying nothing there and sometimes says Dino found 15(some number). But nothing happens in the game — just cursor movement. It sometimes says changing view, but still nothing happens.

I will try color correction.

@HCA97
Copy link
Owner

HCA97 commented Feb 14, 2024

Hi,

If the cursor moves but nothing happens, even when changing the view, it seems like a timing issue.

Additionally, you might have some detection issues as well. Since it's Lunar New Year, they might have updated the visuals of the supply drops, coin chests, and dinosaurs.

@gauravyadav26
Copy link
Author

gauravyadav26 commented Feb 14, 2024

I have tried to increase the time. Now when changing the view it throws this error. Is map color also a factor as its blue now.

Traceback (most recent call last): File "C:\Users\gaura\Desktop\jw_bot-main\jw_bot-main\main.py", line 55, in <module> bot.change_view() File "C:\Users\gaura\Desktop\jw_bot-main\jw_bot-main\jw_bot.py", line 565, in change_view pos = self.locate_x_button(background) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\gaura\Desktop\jw_bot-main\jw_bot-main\jw_bot.py", line 225, in locate_x_button button_color = self.x_button_color ^^^^^^^^^^^^^^^^^^^ AttributeError: 'Bot' object has no attribute 'x_button_color'

@HCA97
Copy link
Owner

HCA97 commented Feb 15, 2024

Hi,

I think you commented out the following line

self.x_button_color = (117, 10, 10)

@gauravyadav26
Copy link
Author

May I know what is this line for
self.gmap_loc_color = (200, 0, 0, 255, 70, 60)

@HCA97
Copy link
Owner

HCA97 commented Feb 17, 2024

Hi, it is (r_min, g_min, b_min, r_max, g_max, b_max):

mask = (background[:,:,0] >= self.gmap_loc_color[0]) * \

@gauravyadav26
Copy link
Author

gauravyadav26 commented Feb 18, 2024

I meant what gmap_loc_color is actually doing.

Figs folder has just 1 pic should it have more?

@HCA97
Copy link
Owner

HCA97 commented Feb 18, 2024

Hi,

Oh, I misunderstood you. gmap_loc_color refers to the color of the Google Map location, specifically the red pin:

Google Map Location

Yes, initially, I attempted to use multiple figures to detect different loading screens. But, at the end, I used simpler checking methods. I only check for the loading screen featuring the shooting Dino.

@gauravyadav26
Copy link
Author

Thank you for the help. I tried everything but it does not do anything for me. I'm not able to make it perform any action at all.

@HCA97
Copy link
Owner

HCA97 commented Feb 19, 2024

Hmm, that's interesting. Perhaps something changed since the last time I used it. Unfortunately, I don't have access to a Windows computer right now. I'll check it when I have access, which should be possible next week.

@gauravyadav26
Copy link
Author

Did you get a chance to have a look?

@HCA97
Copy link
Owner

HCA97 commented Feb 27, 2024

Hi,

Yes. In my computer it works, at least it can change view, click thins.

There was some accuracy issue with supply drops due to wrong RGB values. And I realized game becomes super laggy. Can't say for sure if it's because my laptop is getting old, something's up with Bluestacks, or if the game itself getting slower.

Anyway, I fixed the supply drop coloring and extended some sleep durations. Maybe this will help. You can check out what I changed in this pull request (#6).

If this doesnt work, I'd suggest increasing all the time.sleep values, maybe adding a second. If that still doesn't work, I'm not sure what else might be causing the issue in your case.

@gauravyadav26
Copy link
Author

Did all of the above but still nothing. Could it also be some dependency issue?

@HCA97
Copy link
Owner

HCA97 commented Feb 27, 2024

If it was dependecny issue you should get error about some package is missing. But it is possible.

Is there a reason you mention the dependency issue?

My environment is:

  • Python 3.9
  • Bluestack 4.250
  • Result of pip freeze:
    contourpy==1.2.0
    cycler==0.12.1
    fonttools==4.49.0
    imageio==2.34.0
    importlib-resources==6.1.2
    keyboard==0.13.5
    kiwisolver==1.4.5
    lazy-loader==0.3
    matplotlib==3.8.3
    MouseInfo==0.1.3
    networkx==3.2.1
    numpy==1.26.4
    packaging==23.2
    Pillow==9.5.0
    PyAutoGUI==0.9.54
    PyGetWindow==0.0.9
    PyMsgBox==1.0.9
    pyparsing==3.1.1
    pyperclip==1.8.2
    PyRect==0.2.0
    PyScreeze==0.1.30
    pytesseract==0.3.10
    python-dateutil==2.8.2
    pytweening==1.2.0
    scikit-image==0.22.0
    scipy==1.12.0
    six==1.16.0
    tifffile==2024.2.12
    zipp==3.17.0
    
  • tesseract version:
    tesseract v5.3.1.20230401
     leptonica-1.83.1
      libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 2.1.4) : libpng 1.6.39 : libtiff 4.5.0 : zlib 1.2.13 : libwebp 1.3.0 : libopenjp2 2.5.0
     Found AVX2
     Found AVX
     Found FMA
     Found SSE4.1
     Found libarchive 3.6.2 zlib/1.2.13 liblzma/5.2.9 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.2
     Found libcurl/8.0.1 Schannel zlib/1.2.13 brotli/1.0.9 zstd/1.5.4 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.3) libssh2/1.10.0
    

@gauravyadav26
Copy link
Author

I mentioned dependencies as it does not even change the view, which I thought it should.

My environment is:

  • Python 3.11
  • Bluestack 5.12

Can this cause issues?

@HCA97
Copy link
Owner

HCA97 commented Feb 27, 2024

Hi,

I tried using Bluestack 5.20, and it still works on my computer. I'm not sure if Python versions will make a difference, but you can try downgrading it to see if it helps.

By the way, to change the view, the bot uses the scroll button. Make sure you can change the view by scrolling. You can find the code for this here: link to code snippet.

Additionally, could you try debugging it using test_action.py to get a sense of what bot sees? You can try performing actions like collecting supply drops or shooting a dinosaur. You can find the debugging script here: link to debugging script.

Keep in mind that when shooting a dinosaur, you have to launch the drone first for the bot. It should look something like this:
image

@gauravyadav26
Copy link
Author

Thanks for the help got it working. Any thoughts on how to improve its shooting?

@HCA97
Copy link
Owner

HCA97 commented Mar 2, 2024

Glad it's working now. How did you manage to fix the issue?

As for improving shooting, it might not be easy. We might need more efficient code to run the tracking more smoothly, possibly using multiprocessing, or a better algorithm, perhaps using reinforcement learning. However, if you're interested, you can experiment with hyperparameters:

  • D: distance to center circle
  • S: slow down speed for the Dino to avoid overshooting
  • h1, h2, h3: lower the battery increase the D (h1), lower the battery look more ahead (h2), and lower the battery slow down much slower (h3). Note that 0 < h3 <= S.
  • ms: how fast the mouse moves
  • v_max: maximum velocity, useful for calculating the trajectory of the Dino

The algorithm used is the Purse, Flee, Evade algorithm. I recommend watching the explanation to understand the parameters better: YouTube link

@gauravyadav26
Copy link
Author

It was a rights issue (my blue stacks run with administrative privileges so I needed to run the cmd as administrator. Stupid thing).

I will try my hands on the shooting and will update you if I make any progress.

@darshanraok
Copy link

darshanraok commented Dec 26, 2024

@HCA97 can you implement this [bot] directly for Android devices, root permissions can also be utilized

@HCA97
Copy link
Owner

HCA97 commented Jan 6, 2025

@darshanraok Sorry for the delayed response; I just saw your message.

Regarding your request, I am not experienced with Android devices or app development, so I’m not entirely sure where to start :) As far as I know, you cannot run Python code directly on Android devices, so you might need to rewrite it in another language, maybe in Java, that is compatible with Android. Additionally, the libraries I used for clicking, taking screenshots, and image processing may not work on Android.

Sorry, I’m not sure I can provide much help with running the bot on Android devices directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants