Making programs work together.

C

ChuckDubya

I'm looking to make what's basically a macro for a computer game. But
I want this "macro" to take information from the game itself, so it's
not really a macro.

How do I access the data from my game to use in a program?
 
B

Bengt Richter

I'm looking to make what's basically a macro for a computer game. But
I want this "macro" to take information from the game itself, so it's
not really a macro.

How do I access the data from my game to use in a program?
How do I access the data behind your question?

Regards,
Bengt Richter
 
C

ChuckDubya

Example: I'm driving a car in a game and I hit an oil slick so instead
of me having to lift off the throttle button on the keyboard, I want to
make a program to disengage the throttle as long as I'm on that oil
slick. Does that clear anything up?
 
P

Peter Otten

Example: I'm driving a car in a game and I hit an oil slick so instead
of me having to lift off the throttle button on the keyboard, I want to
make a program to disengage the throttle as long as I'm on that oil
slick. Does that clear anything up?

Yes. Here's how to do it:

import random
import time

class Car:
def throttle(self, on):
if on:
print "full throttle"
else:
print "on that oil slick again"


class ThatOilSlick:
def __contains__(self, item):
return random.random() < .7

class Game:
def __init__(self):
self.car = Car()
self.thatOilSlick = ThatOilSlick()
def play(self):
while True:
self.car.throttle(self.car in self.thatOilSlick)
time.sleep(.2)

if __name__ == "__main__":
Game().play()

:)

Look here for further information:
www.catb.org/~esr/faqs/smart-questions.html

Peter
 
D

Dennis Lee Bieber

Example: I'm driving a car in a game and I hit an oil slick so instead
of me having to lift off the throttle button on the keyboard, I want to
make a program to disengage the throttle as long as I'm on that oil
slick. Does that clear anything up?

The main question is: do you have access to the game INTERNAL
DATA... IE, how do you know you hit an oil slick -- what data is
available from the game that tells you it is an oil slick?

If all you have to go by is a visual image showing your car skidding
sideways, you have entered the realm of visual recognition AI -- and
most experiments in that realm still need cleanly defined road markings,
they don't handle shiny dark spots covering the road.
--
 
M

Magnus Lycka

I'm looking to make what's basically a macro for a computer game. But
I want this "macro" to take information from the game itself, so it's
not really a macro.

That's exactly a macro as the term is used in e.g. MS Office macros
written in VBA etc. Do you have access to the source code for the game?
 
J

John Machin

Example: I'm driving a car in a game and I hit an oil slick so instead
of me having to lift off the throttle button on the keyboard, I want to
make a program to disengage the throttle as long as I'm on that oil
slick. Does that clear anything up?

Yes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top