Controlling a game with a script

L00PeR
6 years ago

0

You have downloaded a game which consists of betting, you don’t want to play, but you want to earn some money, create a script which controls the program so you can bet automatically
The program: https://pastebin.com/DZ04YNWu

Please can someone create a script which is able to control the program and pass to me the code?
I’d like to learn something about processes…

16replies
3voices
265views
1image
L00PeR
6 years ago | edited 6 years ago

0

@r4v463 Can you help me?

dloser
6 years ago

0

r4v463 Can you help me?[/quote]
What is this? Private chat?

[quote]Please can someone create a script which is able to control the program and pass to me the code?
I’d like to learn something about processes…
So we have to create the script and you will magically learn? Try learning by doing research and trying stuff out yourself.

In any case, please make a live version of this code. I would love to bet some money given this implementation…

L00PeR
6 years ago

0

Yesterday I looked for an hour and didn’t found anything…
Just controlling the keyboard but is not exactly what I want.
I’m using Popen, from subprocess do you recommend me any other library?
[quote=@dloser]In any case, please make a live version of this code. I would love to bet some money given this implementation…[/quote]
Was this ironic? :S

dloser
6 years ago

0

Perhaps tell us what you do want then.

And no, that wasn’t ironic.

L00PeR
6 years ago

0

Try controlling that script and then explain how did you did it.

And… What do you mean with a live version?

dloser
6 years ago

0

Control how? I can start the script and even terminate it as I wish. Is that enough control for you?

Live as in running somewhere with actual monetary transactions.

L00PeR
6 years ago

0

Make a script which can control the program so for example:
bet 5$ with a 50% win probability
if you lose, make the same but with 10$
then with 20$
then with 40$
and so on….
Something like a bot…

dloser
6 years ago

0

And why is subprocess not good enough for that?

L00PeR
6 years ago | edited 6 years ago

0

Well, I can’t control the program maybe you can…

this is my code:
```
from subprocess import Popen, PIPE
import time

def keypress():
p = Popen([‘python’, ‘wannaBeRich.py’], stdin=PIPE, stdout=PIPE)
p.stdin.write(‘n\n’)
i=0
while i<100:
p.stdin.write(‘1\n’)
i+=1

keypress()
```

My idea is to bet 1$ with a 1% probability of winning for a 100 times,
But doesn’t work…
Help me pls

L00PeR
6 years ago | edited 6 years ago

0

weird, Doesn’t appear the name of the program…
edit: well, imagine before the comma is written the name of the process

dloser
6 years ago

0

Can’t check right now, but it probably works. It just won’t do what you expect it to do.

Here are some tips:

Always try debugging your code. Add some print statements to see what’s happening. That way you can give more useful information to the people you ask help from instead of just dumping code in their laps. It might even allow you to solve the problem yourself!

Try reading from p.stdout. If you don’t the game will block.

L00PeR
6 years ago

0

Ok, I’ve been looking to p.stdout, but my code still doesn’t work.
Can you tell me where I’m wrong?
https://pastebin.com/7qvEbruP

dloser
6 years ago

0

The issue is that by default stdin and stdout are buffered. You can use the stdbuf tool to change that or add flush() after your writes. (Also, calling reset hides some info.)

L00PeR
6 years ago

0

Still doesn’t work…
Maybe you can help me a little bit more via PM…

Smyler [WHGhost]
6 years ago

1

I agree with dloser, you should make a live version, I would be rich so easily!
Image

You can pass the -u option to python to disable output buffering, it has alredy been a good solution when I had a similar problem.

L00PeR
6 years ago

0

Lol, hahaha.
I love when people go bug-hunting on a program which has been created in 3 min… xD
Gonna fix it
Good work @WHGhost :D

You must be logged in to reply to this discussion. Login
1 of 17

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss