def computeValueFromQValues(self, state): actions = self.getLegalActions(state) if not actions: return 0.0 maxValue = -float("inf") for action in actions: maxValue = max( maxValue, self.getQValue(util.getKey(state[0] + state[1]), action)) return maxValue
def main(argv): pw = argv[0] inputfile = argv[1] # print "password: "******"Input image: " + inputfile key = getKey(pw) # print "Key: " + key.hex data = getImageData(inputfile) bytes = decrypt(data, key) print bytes
def main(argv): pw = argv[0] txtfile = argv[1] inputImage = argv[2] outputImage = argv[3] key = getKey(pw) text = getText(txtfile) print "Input img: " + inputImage print "Output img: " + outputImage print "Text: " + text print "pass: "******"Key: " + key.hex loadImage(inputImage,outputImage,text,key)
def computeActionFromQValues(self, state): # Get the legal actions actions = self.getLegalActions(state) if not actions: return None # Get all possible moves from this state possibleMoves = defaultdict(float) for action in actions: possibleMoves[action] = self.getQValue( util.getKey(state[0] + state[1]), action) # Get the maximum value from the moves dictionary maxValue = possibleMoves[max(possibleMoves)] finalMoves = [] for move, value in possibleMoves.iteritems(): if value == maxValue: finalMoves.append(move) # Arbitrarily pick a maximum move at random return random.choice(finalMoves)
def update(self, state, action, successor, reward): key = util.getKey(state[0] + state[1]) sample = reward + self.gamma * self.getValue(successor) self.values[(key, action)] = ( (1 - self.alpha) * self.getQValue(key, action)) + (self.alpha * sample)
# Python program to get a google map # image of specified location using # Google Static Maps API # importing required modules import requests import util # Enter your api key here api_key = util.getKey() # center defines the center of the map, # equidistant from all edges of the map. center = "Brooklyn+Bridge,New+York" # url variable store url url = "https://maps.googleapis.com/maps/api/staticmap?center=%s" url += "&zoom=13&size=600x300&maptype=roadmap&markers=color:blue" url += "%s" + "7Clabel:S" url += "%s" + "7C40.702147,-74.015794&markers=color:green" url += "%s" + "7Clabel:G" url += "%s" + "7C40.711614,-74.012318&markers=color:red" url += "%s" + "7Clabel:C" url += "%s" + "7C40.718217,-73.998284&key=%s" url = url % (center, "%", "%", "%", "%", "%", "%", api_key) # get method of requests module # return response object r = requests.get(url) # wb mode is stand for write binary mode
import googlemaps from datetime import datetime import util key = util.getKey() gmaps = googlemaps.Client(key=key) # Geocoding an address geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA') # Look up an address with reverse geocoding reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452)) # Request directions via public transit now = datetime.now() directions_result = gmaps.directions("Sydney Town Hall", "Parramatta, NSW", mode="transit", departure_time=now) with open('route_api.txt', 'w') as fd: fd.writelines()