Exemplo n.º 1
0
    def declare_action(self, valid_actions, hole_card, round_state):
        if unplayable(hole_card):
            print('action: fold unplayable hand')
            print('amount: 0')
            return 'fold', 0

        # valid_actions format => [raise_action_info, call_action_info, fold_action_info]
        me = round_state['seats'][round_state['next_player']]
        opponent = round_state['seats'][1 - round_state['next_player']]
        aggro = calc.player_aggressiveness(round_state)[opponent['uuid']]
        tight = calc.player_tightness(round_state)[opponent['uuid']]
        money_opponent = calc.get_money_score(round_state)[opponent['uuid']]
        money_me = calc.get_money_score(round_state)[me['uuid']]
        winprob = calc.get_winprob(round_state, hole_card)

        #action, amount = call_action_info["action"], call_action_info["amount"]
        (degree, action) = run_fuzzy_system(tight, aggro, money_opponent,
                                            money_me, winprob)

        if action == 'fold' and valid_actions[1]['amount'] == 0:
            action = 'call instead'
            amount = 0
        amount = raise_amount(me['stack'], degree, action)

        # print('tight', tight)
        # print('aggro', aggro)
        # print('money_opponent', money_opponent)
        # print('money_me', money_me)
        # print('winprob', winprob)
        print('action: ', action)
        print('amount: ', amount)
        return action, amount  # action returned here is sent to the poker engine
Exemplo n.º 2
0
    def __init__(self, H, frontView="", bentArmsView="", backView=""):

        self.calc = Calculations(H)
        self.shoulder_width = 0
        self.right_shoulder_elbow = 0
        self.right_elbow_wrist = 0
        self.left_shoulder_elbow = 0
        self.left_elbow_wrist = 0
        self.right_shoulder_wrist = 0
        self.left_shoulder_wrist = 0
        self.shoulder_hip = 0
        self.right_hip_ankle = 0
        self.left_hip_ankle = 0
        self.right_hip_knee = 0
        self.left_hip_knee = 0
        self.hip_ankle_max = 0
        self.chest_point = (0, 0)
        self.model = openpose_model.general_pose_model("", mode="MPI")
        self.inchesPerPixel = 0
        self.points = None


        if frontView != "":
            self.__calculateMeasurementsFromFrontView(frontView)
            self.inchesPerPixel = self.calc.getInchesPerPixel()

        if bentArmsView != "":
            self.__calculateMeasurementsFromBentArmsView(bentArmsView)

        if backView != "":
            self.__calculateMeasurementsFromBackView(backView)
Exemplo n.º 3
0
 def button_clicked_operation(self, text):
     #self.output2.setText(self.output1_text + text)
     if ( self.edit_reset) :
         self.output2.setText(str ( self.output1_text ) + self.oper + str ( self.output2_text ) + " = " + str(self.wynik) + "   :"+text)
         self.oper=text
     elif (text =="="):
         match = re.match(f"{Expressions.DIGIT}{Expressions.OPERAND}{Expressions.DIGIT}", self.output1_text)
         match2 = re.match(f"{Expressions.COSINE}{Expressions.DIGIT}\)", self.output1_text)
         if match:
             x = match.group(1)
             y = match.group(4)
             oper = match.group(3)
             if (oper=='+'):
                 self.output2_text = str(Calculations.sum(x,y))
                 self.output2.setText(self.output2_text)
             elif (oper=='-'):
                 self.output2_text = str(Calculations.subtract(x,y))
                 self.output2.setText(self.output2_text)
             elif (oper=='*'):
                 self.output2_text = str(Calculations.multiply(x,y))
                 self.output2.setText(self.output2_text)
             elif (oper=='/'):
                 self.output2_text = str(Calculations.divide(x,y))
                 self.output2.setText(self.output2_text)
         elif match2:
             x= match2.group(1)
             self.output2_text = str(Calculations.cosinus(x))
             self.output2.setText(self.output2_text)
         else:
             print("error")
             self.output1_text = ""
Exemplo n.º 4
0
 def calculate(self):
     """
     Calculate a value
     :return: None
     """
     calc = Calculations()
     answer = calc.calc(self.command)
     if answer is not None:
         self.speak.respond(answer)
     else:
         self.speak.respond("Sorry, I could not calculate that")
Exemplo n.º 5
0
def main():
    data = readDataFromFile("plik.txt")
    TO = int(data[0])
    time = int(data[1])
    dT = int(data[2])
    ambientT =int(data[3])
    alfa = int(data[4])
    conductivity = int(data[5])
    specificHeat = int(data[6])
    density = int(data[7])
    H = float(data[8])
    W = float (data[9])
    nH = int(data[10])
    nW = int(data[11])

    globalD = GlobalData(nH, nW, H, W,TO,dT,ambientT,alfa,conductivity,specificHeat,density,time)

    grid = Grid(globalD)
    ue = UniversalElement()
    jacob=Jacobian(grid)
    matrixH=MatrixH(jacob)
    matrixC=MatrixC(jacob)
    matrixH_BC = MatrixH_BC(grid)
    p=VektorP(matrixH_BC)
    calculations=Calculations(matrixC,matrixH,matrixH_BC,p)
Exemplo n.º 6
0
 def createPlayerObjects(self,team_coll):
     player_coll = []
     calc=Calculations()
     for i in self.fifa_data["Nr"]:
         name = self.fifa_data["Name"][i]
         team_name = self.fifa_data["Club"][i]
         age = self.fifa_data["Age"][i]
         height = calc.convertHeightToCM(self.fifa_data["Height"][i])
         weight = calc.convertWeightToKG(self.fifa_data["Weight"][i])
         overall = self.fifa_data["Overall"][i]
         position = self.fifa_data["Position"][i]
         position = self.definePosition(position)
         player = Player.Player(name, team_name, age, height, weight, overall, position)
         player_coll.append(player)
         team_coll = self.addPlayerToTeam(team_coll, team_name, player)
     self.player_coll=player_coll
Exemplo n.º 7
0
    def spin_button_callback(self):


        self.calc_btn.setEnabled(False)
        try:
            hours=float(self.hours_line.text())
            lat=float(self.latitude_line.text())
            self.canvas.spin(int(Calculations().getAngle(lat,hours)), self.app)
        except AssertionError:
            QMessageBox.critical(self,"Error","Invalid Input")
        self.calc_btn.setEnabled(True)
Exemplo n.º 8
0
 def button3_click(
     self
 ):  #button of resetting second page of program, run Calculations methods for getting new results
     num_of_ticks = int(self.titleEdit3.text())
     start = float(self.titleEdit1.text())
     end = float(self.titleEdit2.text())
     calc = Calculations(num_of_ticks)
     hop = ((end - start) / num_of_ticks)
     x_v = []
     for i in range(num_of_ticks + 1):
         x_v.append(start + i * hop)
     values1 = calc.hop_error_plot(start, end, hop, 1)
     values2 = calc.hop_error_plot(start, end, hop, 2)
     values3 = calc.hop_error_plot(start, end, hop, 3)
     self.euler_hop_error.plot2(
         x_v, values1,
         'Dependence of max value error on\n number of ticks (Euler)')
     self.euler_adv_hop_error.plot2(
         x_v, values2,
         'Dependence of max value error on\n number of ticks (Euler_adv)')
     self.cutta_hop_error.plot2(
         x_v, values3,
         'Dependence of max value error on\n number of ticks (Runge-Cutta)')
Exemplo n.º 9
0
def main():
    MotorObject = Motor()
    CoordinatesObject = Coordinates()
    CalculationsObject = Calculations()
    SaveToSD_Object = SaveToSD()
    forceStopped = False

    waitForInput()
    time.sleep(2)

    for i in range(73):  # alleen voor debugging

        if GPIO.input(buttonPin) == GPIO.LOW:  # Force stop
            print("Force stopping!")
            forceStopped = True
            changeColor('red')
            break

        MotorObject.turnMotor(i)
        CoordinatesObject.calculate_coordinates(i)

    if not forceStopped:
        CalculationsObject.run()
        SaveToSD_Object.save()
Exemplo n.º 10
0
    def button1_click(
        self
    ):  #button of resetting first page of program, run Calculations methods for getting new results
        hop = self.titleEdit.text()
        calc = Calculations(hop)
        values = calc.get_y()
        x_points = calc.get_x()
        exact = values[0]
        euler = values[1]
        euler_adv = values[2]
        cutta = values[3]

        self.euler.plot(x_points, exact, euler, 'Euler + exact')
        self.euler_adv.plot(x_points, exact, euler_adv,
                            'Euler advanced + exact')
        self.cutta.plot(x_points, exact, cutta, 'Runge_cutta + exact')
        e_error = calc.x_error_plot(1)
        self.euler_error.plot1(x_points, e_error, 'Euler errors')
        e_A_error = calc.x_error_plot(2)
        self.euler_adv_error.plot1(x_points, e_A_error,
                                   'Euler advanced errors')
        cut_error = calc.x_error_plot(3)
        self.cutta_error.plot1(x_points, cut_error, 'Runge_cutta errors')
Exemplo n.º 11
0
class Measurements:

    def __init__(self, H, frontView="", bentArmsView="", backView=""):

        self.calc = Calculations(H)
        self.shoulder_width = 0
        self.right_shoulder_elbow = 0
        self.right_elbow_wrist = 0
        self.left_shoulder_elbow = 0
        self.left_elbow_wrist = 0
        self.right_shoulder_wrist = 0
        self.left_shoulder_wrist = 0
        self.shoulder_hip = 0
        self.right_hip_ankle = 0
        self.left_hip_ankle = 0
        self.right_hip_knee = 0
        self.left_hip_knee = 0
        self.hip_ankle_max = 0
        self.chest_point = (0, 0)
        self.model = openpose_model.general_pose_model("", mode="MPI")
        self.inchesPerPixel = 0
        self.points = None


        if frontView != "":
            self.__calculateMeasurementsFromFrontView(frontView)
            self.inchesPerPixel = self.calc.getInchesPerPixel()

        if bentArmsView != "":
            self.__calculateMeasurementsFromBentArmsView(bentArmsView)

        if backView != "":
            self.__calculateMeasurementsFromBackView(backView)

    def __calculateMeasurementsFromFrontView(self, path):
        res_points = self.model.predict(path)
        self.calc.calculateInchesPerPixel(res_points)
        self.shoulder_hip = self.calc.getDistanceInInches(min(res_points[2][1], res_points[5][1]),
                                                          min(res_points[8][1], res_points[11][1]))
        self.points = res_points
        #self.model.vis_pose(path, res_points)


    def __calculateMeasurementsFromBentArmsView(self, path):
        res_points = self.model.predict(path)
        self.calc.calculateInchesPerPixel(res_points)
        self.right_shoulder_elbow = self.calc.getDistanceInInches(res_points[2], res_points[3])
        self.right_elbow_wrist = self.calc.getDistanceInInches(res_points[3], res_points[4])
        self.right_shoulder_wrist = self.calc.getDistanceInInches(res_points[2], res_points[4])
        self.left_shoulder_elbow = self.calc.getDistanceInInches(res_points[5], res_points[6])
        self.left_elbow_wrist = self.calc.getDistanceInInches(res_points[6], res_points[7])
        self.left_shoulder_wrist = self.calc.getDistanceInInches(res_points[5], res_points[7])
        self.right_hip_ankle = self.calc.getDistanceInInches(res_points[8], res_points[10])
        self.left_hip_ankle = self.calc.getDistanceInInches(res_points[11], res_points[13])
        self.right_hip_knee = self.calc.getDistanceInInches(res_points[8], res_points[9])
        self.left_hip_knee = self.calc.getDistanceInInches(res_points[11], res_points[12])
        self.chest_point = res_points[14]

        self.hip_ankle_max = self.calc.getDistanceInInches((res_points[8][1]+res_points[11][1])/2,
                                                           max(res_points[10][1], res_points[13][1]))
        #self.model.vis_pose(path, res_points)


    def __calculateMeasurementsFromBackView(self, path):
        res_points = self.model.predict(path)
        self.calc.calculateInchesPerPixel(res_points)
        self.shoulder_width = self.calc.getDistanceInInches(res_points[2], res_points[5])
import QuantLib as ql
import matplotlib.pyplot as plt
from flask import Flask, redirect, url_for, render_template, request
from OptionForm import OptionForm
import os
import csv
from flask_datepicker import datepicker
from flask_bootstrap import Bootstrap
from Calculations import Calculations
from flask_table import Table, Col

app = Flask(__name__)
bootstrap = Bootstrap(app)
SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY
options = Calculations()
premium = 0
delta = 0
com_premium = 0
com_delta = 0
optionlist = []
list = []


@app.route('/', methods=('GET', 'POST'))
def main():
    global com_premium
    global com_delta
    form = OptionForm()
    if request.method == 'POST':
        if form.is_submitted() and request.form != None:
Exemplo n.º 13
0
import paho.mqtt.client as mqtt
import time
from Calculations import Calculations
import RPi.GPIO as GPIO

c=Calculations()

try:
    STEPPIN_PAN = 20
    DIRPIN_PAN = 21
    STEPPIN_TILT = 14
    DIRPIN_TILT = 15
    M_PINS = (13, 19, 26)
    DELAYTILT = 0.0025
    DELAYPAN = 0.00025
    RESOLUTION = {'Full': (0, 0, 0),
                  'Half': (1, 0, 0),
                  '1/4': (0, 1, 0),
                  '1/8': (1, 1, 0),
                  '1/16': (0, 0, 1),
                  '1/32': (1, 0, 1)}

    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(STEPPIN_PAN, GPIO.OUT)
    GPIO.setup(DIRPIN_PAN, GPIO.OUT)
    GPIO.setup(STEPPIN_TILT, GPIO.OUT)
    GPIO.setup(DIRPIN_TILT, GPIO.OUT)
    GPIO.setup(M_PINS, GPIO.OUT)
    GPIO.output(M_PINS, RESOLUTION['Half'])
except Exception:
Exemplo n.º 14
0
from Data import Data
from Calculations import Calculations

## LOAD DATA - SAVE TO CSV
data = Data()

json_data = data.api_request()
df_data = data.data_transformation(json_data)
data.data_to_csv(df_data, filename='files/cryptocurrency_daily_data.csv')
print 'Data saved in files/cryptocurrency_daily_data.csv'

## CALCULATIONS
calculations = Calculations()

cryptocurrency_data = data.load_from_csv('files/cryptocurrency_daily_data.csv')
print 'Loaded data from files/cryptocurrency_daily_data.csv'

# close prices
close_prices = cryptocurrency_data[['Date', '4a. close (USD)']]
close_prices = calculations.append_week_info(close_prices)

average_closes = calculations.get_average_values(close_prices)
data.data_to_csv(average_closes, 'files/average_close_prices.csv')
print 'Average close prices saved in files/cryptocurrency_daily_data.csv'

# relative spans
relative_spans = calculations.get_relative_spans(close_prices)
print 'The week with greatest relative span is: ' + relative_spans.idxmax(axis=1)