Manuteaa / dbd_autoSkillCheck

A tool (PyTorch) to automatically detect and hit great skill checks in Dead by Daylight
10 stars 1 forks source link

Installation Guide #2

Open Kromilan opened 6 months ago

Kromilan commented 6 months ago

Hello, this project looks very interesting. By the way you worded it, it seems like it was designed for a study project, but not for general use by the public. Is that something you want to change in the future, by adding an installation and a usage guide?

Manuteaa commented 6 months ago

Hello! I'm happy to hear it caught your interest. Yes, the project was designed for study purpose, but I can provide you with the trained model and a guide on how to use it, so you can experiment with it yourself.

Kromilan commented 6 months ago

Oh wow, I really didn't expect an answer so soon. I would be delighted about that. thank you so much :D

Manuteaa commented 6 months ago

I just released the test script with the instructions. Can you give it a try and tell me how it went ? Thanks !

Kromilan commented 6 months ago

Thank you a lot for the effort. I tried this out and the results were interesting. First, I edited the sleep(1000) in run.py to spleep(1) because for some reason for me it was in seconds and not milliseconds. I also added a print("space") before PressKey(SPACE). That way I could confirm if it actually recognised the hits or not more easily. I tested it in a bot-game and on a website for training skill checks. on the website it works flawlessly and in game, it runs print("space") at the exactly right moment. It works on hard skill checks (the ones where only the small white region (great skill check) exits but not the smaller transparent region). I could also find out that it does not work with shaking skill checks like those caused by the Doctor Killer. Overall, I would call this project really functional. good work :D

Out of curiosity: did you also check it in game? because easy anti cheat seems to prevent keyboard inputs from code. The bot game revealed that it does see the skill check and wants to press space at the right time, but it the game doesn't register it. Dead by Daylight uses Easy Anticheat, I would not be surprised if that's the reason. I'm just curious how you managed to work around that when you tested it.

Eitherway, it's interesting to see it function so well. Thank you a lot :)

Manuteaa commented 6 months ago

About the anti cheat system, I am surprised that the game did not register the space bar inputs. I had no problem during my in-game testings. I don't know if it can be detected as a cheat, as macro commands could also be. Also, the sleep() function avoids multiple space bar pressing (which is obviously very suspect for an anti-cheat system). If you are interested in exploring this, don't hesitate to let me know, and maybe fix the problem of the space bar !

I also had many other plans for dbd for study purpose (and not cheating !), such as survivors and flying birds detection (to help the killer find the survivors disturbing the birds), with the visual detection being displayed on top of the monitor screen (with bounding boxes for example). The only challenge would be to collect the data and categorize it manually.

FacundoMartinezCampos commented 5 months ago

Hello!, is this undetected?

Manuteaa commented 5 months ago

Hi ! never had any problem, but I did not use it for quite a long time

FacundoMartinezCampos commented 5 months ago

thanks!, i tested it and works fine, the only thing i encountered is that the majority of the checks are not great checks, could this be my resolution or the ui scalling?

Kot4590 commented 5 months ago

Hello, brilliant creator of this script. I was very interested in this code, but, unfortunately, I am not a programmer myself. Have used this script for 6 days or more Anti-cheat does not react to it in any way. But I have questions, if I get answers to them I will be very happy.

  1. Can I somehow improve the bot's result using Png Which ones does he keep? And how to do this? (Sorry for my arrogance, but the topic of AI itself is very interesting to me)
  2. The script in my case never hits the Excellent mark, only good, is there any way to fix this? So that, for example, the chances are 50/50.
  3. What programs should be used to train this script? I would really like to repeat the learning process myself, as this topic is interesting. Thank you very much for the script you made.
Manuteaa commented 5 months ago

Hi everyone !

The issue of triggering good skill checks instead of great ones comes from your network latency, as mentioned in the conclusion of the README file.

To address this, one potential solution involves training the model to predict when the cursor will reach the great skill check area, and so the script can hit the space bar even before the cursor reaches the zone. I can re-train the model, but it would require annotated data. If you're interested in assisting with data collection (by recording your gameplay and sorting the images into specific folders), please contact me ! Else I don't think I will have the time to collect the data.

gayloo commented 4 months ago

or you could just do this:

# Hit !! if pred == 2: print("Delay...") sleep(0.1) # Adjust this to what you deem fit PressKey(SPACE) ReleaseKey(SPACE) print("Hit !!") sleep(0.6)

gayloo commented 4 months ago

Quick edit: it seems like that, while it is trying to press space at the correct time, most of time it doesnt work

50 48 49

gayloo commented 4 months ago

quick note: do not do this

Manuteaa commented 4 months ago

In fact the script does hit the space bar at the correct time (when the cursor is in the small area), but with the game latency it is only registered by the game a few ms later, leading to good skill check and not great skill check.

@gayloo on the contrary you should not delay the hit, but advance it, if it was possible !

Elizbetha commented 3 months ago

can you type your discord or telegram. wanna improve this with you. i have the data @Manuteaa

Manuteaa commented 3 months ago

can you type your discord or telegram. wanna improve this with you. i have the data @Manuteaa

you can contact me on discord manutea_

JRC54 commented 2 months ago

Hey I tested this and it always hit the good skill check, did you guys manage to improve the program?

gayloo commented 2 months ago

Hey I tested this and it always hit the good skill check, did you guys manage to improve the program?

your are either nearby the server location or you has a really good computer or somethang idk.

Mspy1 commented 1 month ago

Anyone had a luck making this work? I tried to tinker with it, however i was not able to advance the space presses as it is dependent on "pred" function scoring 2 and it is latency dependent. Manuteaa probably needs to add a pre-press function which is dependent on typed ping value.

Manuteaa commented 1 month ago

Hi, the way to make it work (with GREAT skill checks) would be to retrain the model (the AI part).

The script should press the space bar a little bit before the cursor reaches the great skill check area. When ? It depends on your latency, you are right. Today, the model only detects if the cursor is in the great skill check area or not, so the script cannot anticipate anything. When the model says "it's in the great skill check area !" (scoring 2), the script hits the space bar, but it's too late because of the latency...

To train the model I need new data (screenshots of the game and associated information about where is the cursor). For each screenshot, i need the information if there is a skill check occurring or not, and if there is, how far (time in ms or number or frames would be ok) the cursor is from the great skill check area.

A way to "easily" prepare this dataset:

If you can collect the data for me I can retrain the model, otherwise I do not have the time to collect this data anymore... Thanks if you want to contribute and make it work ;)

hemlock12 commented 3 days ago
* Here the long part : sort the screenshots in these folders: in folder -1 if there is no skill check occurring in the screenshot ; folder 0 if there is a skill check and the cursor is in the great area ; folder 1 for the previous frame i.e. the cursor is not is the great skill check area but 1 frame before ; folder 2 for the previous frame i.e. the cursor is 2 frames before being in the great skill check area ; ... ; folder 30 if the cursor is 30 frames before the great skill check area.

Do different skill check types need to be sorted (normal/wiggle/struggle)? Or do I even need to include wiggle/struggle? Also, regarding specific perks (Deadline, Hyperfocus); items (Brand New Part, Syringe), do I need to capture screenshots with those perks equipped separately if I want them to work?

Manuteaa commented 3 days ago

You're right, I just edited my previous comment.

You only need to save images with size 224x224 , corresponding to the square at the center of your screen (center-crop of size 224x224). You can use my script dbd/save_frames.py, or use your own, it doesn't matter.

You can include wiggle and struggle skill checks yes, but in different folders indeed, because the cursor can go clock-wise and anti-clockwise with these skill checks, and with a single image processing we can not know its current rotation. So we can work on :

For specific skill checks (doctor, hyperfocus, etc.), you can include in the data, the trained model will be better in these situations if we have the data. It will not work for doctor skill checks outside the center of the image however

Pazdikan commented 3 days ago

I'm going to try that, but I've got some questions just to be sure and not waste a lot of time lol

So in -1 i should put the most random gameplay elements, i suppose auras from perks, skyboxes, map elements etc. don't hurt?

Now how do I sort the skill checks? If 0 is great, then all i gotta do is take 29 previous screenshots and sort it inside 1-30 folders? Like: 0 - the cursor is on great (full white) 1 - one frame before cursor is on great 2 - two frames before cursor is on great ... etc?

Thank you for the answer and still maintaining this 😊

Manuteaa commented 3 days ago

Thanks :)

Pazdikan commented 3 days ago

Okay, I think i got it 😁

Could you take a look if i did this one skill check correctly? test data.zip

JRC54 commented 3 days ago

Okay, I think i got it 😁

Could you take a look if i did this one skill check correctly? test data.zip

Hello! Can you share the solution if you manage to make it work? Thank you very much!

Manuteaa commented 3 days ago

Okay, I think i got it 😁

Could you take a look if i did this one skill check correctly? test data.zip

Wow very nice !! Yeah, like that ! Like we said before, don't mix with double rotation skill checks (struggle/wiggle), and the more diversity of images you have, the better it is (with survivors in it, the killer, etc.), but that's the idea.

One more thing, what are your fps ? Are you sure you have stable 60fps ? I see the cursor is already far from the white area at folder 5 (~80ms), much quicker than I expected.

Pazdikan commented 3 days ago

I’ve used the edited version of your script which I was supposed to delete, and it had a sleep of 0.3, that’s why it was weird. Don’t even ask what I was trying to accomplish haha

After using the unedited version I can see the difference, so I think it’s „fixed”. However I’m still going to ask again, but when I get a little bit more screenshots 😁

And two last questions, by „Collect many screenshots (at least 5000)” you hopefully mean 5000 screenshots total, not in each folder? 😵‍💫

Also, screenshots of different skill checks (affected by perks like making the great area smaller or bigger) should be put inside the „normal” folder along with other „basic” skillchecks without perks?

Again, thank you for the answers!

Manuteaa commented 3 days ago

Thanks for your help !

With the correct fps, can you send me a screenshot from folder 30 please ? I would like to see how far the cursor is from the white area.

Pazdikan commented 2 days ago

Got it. I’ll send you all 0-30 folders today after work or tomorrow, just so you can confirm it’s fixed

I’m glad I can help 😁

hemlock12 commented 2 days ago

Hey! I've created a dataset of 17k images, including approximately 350 images of skill checks (healing, repairing) and around 5k of general gameplay. I've noticed that sometimes the success zone is located early, so there are fewer later screenshots ('25'-'30'). For general gameplay, I selected 10% of the screenshots, evenly distributed throughout the round, and deleted those with a similarity above 85%. I've done my best to ensure a high level of diversity. It was captured at a stable 60 FPS, 1920x1080 resolution, medium quality, and without anti-aliasing. https://drive.google.com/file/d/1nZkOt8Fci8DXthxNpsfUU3uQEup6cC3x/view?usp=sharing

Pazdikan commented 2 days ago

Thanks for doing god’s work 🗿

If it’s not enough for the model to work properly, I will take my screenshots as well.

Manuteaa commented 2 days ago

Hey! I've created a dataset of 17k images, including approximately 350 images of skill checks (healing, repairing) and around 5k of general gameplay. I've noticed that sometimes the success zone is located early, so there are fewer later screenshots ('25'-'30'). For general gameplay, I selected 10% of the screenshots, evenly distributed throughout the round, and deleted those with a similarity above 85%. I've done my best to ensure a high level of diversity. It was captured at a stable 60 FPS, 1920x1080 resolution, medium quality, and without anti-aliasing. https://drive.google.com/file/d/1nZkOt8Fci8DXthxNpsfUU3uQEup6cC3x/view?usp=sharing

Wow that's a very good job, thanks !

I'm going to check your data, I think there are some quick minor tweaks to do. Then I can train the model, see if it is enough or not, I share the alpha model with you to help us collecting more data if needed. I come back to you soon !

By seing your images, I don't think we need folders 5 to 30. It seems folders 0 to 3 are enough to anticipate the great skill checks (but thanks for your hard work, it can still be useful !). I though the difference in the position of the cursor between two consecutive folders would be slighter.

Manuteaa commented 8 hours ago

Hey guys I just pushed a new version of the model. It should be able to anticipate a bit more the great skill checks (only for gen repair and healing). At the moment it fails wiggle/struggle skill checks because I don't have any training data yet.

Can you test it and tell me if it works ? When it fails, does it press the hit button a bit too early or a bit too late ? From my quick testing, there is still some good skill checks instead of great ones, but it will be better with more data and more data sorting precision.. So I have more work for you if we want to go to the next step ;)

What do I need now ?

Pazdikan commented 7 hours ago

Early feedback: The model hits all great skill checks so far. However sometimes it presses space in a random position. I believe it sees a bright color and it's mistaken. Definitely needs more shots without any skill check. I'll try to run a second DBD account on one of my laptops so I can host a custom game and collect more screenshots also for wiggling.

I'll keep you updated.

Pazdikan commented 7 hours ago

However sometimes it presses space in a random position. I believe it sees a bright color and it's mistaken.

Just to clarify, this happened 2 times out of like 50 skill checks. Probably due to colorfulness of my skin, that was in the center of the skill check. I wasn't taking screenshots, but I think the script pressed spaced when it reached the white text on my back. I'll try to take as much "weird" and "hard to guess\train" photos like these (if the second account works).

image

hemlock12 commented 6 hours ago

I can see that this version is better than the previous one, but it still often lands in the 'good' skill check zones. I tested it with a ping of 40-60 ms and with the debug option 'save_images = True' enabled. I observed that the actual hit zones were mostly at the end of the great skill check zone, sometimes in the middle, but never at the beginning. Even when it tries to hit as early as possible (as seen in image s1,2), it can still miss.

In cases where the 'cursor overlaps both the Great and Fail area pixels', or is even 1 frame before that, I've noticed that all great skill checks happen in this manner. However, I have not seen an image of great skill check (as in captured by the script, which excludes the latency) when it aimed for the middle or end of the 'great' zone, likely due to the latency between capturing the image and the actual hit. There was also a failed skill check that failed as soon as it appeared (as shown in image 3). I believe this happened because the end of the success zone was very close to the start of the skill check.

Additionally, while it may be expected, I should mention that at frame rates above 60, all skill checks are hit too late. As for false positives, I've only observed them in the menu, particularly when reading white text on a black background. However, I haven't thoroughly investigated this and don't have enough data to draw any firm conclusions.

I want to continue gathering training data, and I would like to know how much data is recommended. I also need clarification regarding sorting struggle/wiggle skill checks. You've provided an example image of a struggle skill check and placed it in 'folder 1' (with generic skillchecks) so I'm unsure if I should include data for struggling in a separate folder or not. For wiggling, I understand that it requires a separate folder, but do I need to differentiate between clockwise and counterclockwise as well?

Lastly, for general skill checks, regarding folder 4 'Red cursor far from Great area,' should I include specific frames before the skill check, or any frames that are more than 1 frame (which must be in folder 3) before the Great area ? 1 2 3

Pazdikan commented 5 hours ago

Additionally, while it may be expected, I should mention that at frame rates above 60, all skill checks are hit too late.

Interesting, I’m playing at stable 120hz and the skill checks are all great (literally I haven’t got a good skill check once). unless they hit too early due to issues I’ve described above

hemlock12 commented 5 hours ago

Sorry, I messed up earlier. I was actually testing it in a location where my FPS wasn't stable at 120 (it fluctuated by 5-10 FPS). On a stable FPS, like 90, everything works fine. My bad for the confusion! But all of my other tests were for 60 FPS, so those results remain accurate

Manuteaa commented 5 hours ago

Interesting feedbacks thanks.

Like @Pazdikan I mainly hit the great skill checks with the current model and run script. However, you should try to edit the file run.py l.79 and replace anticipate = (pred == 2) with anticipate = (pred == 2 or pred==3) then retry. The script should hit the space bar a little bit earlier. Tell us if it's better or not, maybe it will hit too early. In any case, in folder "3" should contain images where the cursor is not yet overlapping the white area, but is close enough to hit the space bar with a ping similar to yours... Not easy to measure !

Thanks for feedback about text and very late skill checks, we would need more annotated data like these to fix it.

Same folders for single rotation skill checks is fine (repair, heal, struggle), separate folder for double rotation (wiggle) please. For double rotation you can follow the same sorting strategy. Forget about number of frames, and about current direction of rotation. Only sort by looking where the cursor is from the white area :

I have edited the REAME file edit: because we don't rely on number of frames anymore, you can increase your fps>60 during your data collection