示例#1
0
    def buy(self):
        """Buy upgrades for both attack and defense

        Requires the confirmation popup button for EXP purchases in settings
        to be turned OFF.

        This uses all available exp, so use with caution.
        """
        Stats.set_value_with_ocr("XP")

        if Stats.OCR_failed:
            print('OCR failed, exiting upgrade routine.')
            return

        current_exp = Stats.xp

        if current_exp < 1000:
            return

        total_price = (coords.RATTACK_COST * self.attack)
        total_price += (coords.RDEFENSE_COST * self.defense)

        # Skip upgrading if we don't have enough exp to buy at least one
        # complete set of upgrades, in order to maintain our perfect ratios :)

        if total_price > current_exp:
            if self.report:
                print("No XP Upgrade :{:^8} of {:^8}".format(
                    Helper.human_format(current_exp),
                    Helper.human_format(total_price)))
            return

        amount = int(current_exp // total_price)

        a_attack = amount * self.attack
        a_defense = amount * self.defense

        Navigation.exp_rich()

        Inputs.click(*coords.EM_ADV_BOX)
        Inputs.send_string(str(a_attack))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_ADV_BOX)
        Inputs.send_string(str(a_defense))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_ADV_BOX)
        Inputs.click(*coords.EM_ADV_BOX)

        Stats.set_value_with_ocr("XP")

        total_spent = coords.RATTACK_COST * a_attack
        total_spent += coords.RDEFENSE_COST * a_defense

        if self.report:
            print("Spent XP:{:^8}{:^3}Attack:{:^8}{:^3}Defense:{:^8}".format(
                Helper.human_format(total_spent), "|",
                Helper.human_format(a_attack), "|",
                Helper.human_format(a_defense)))
示例#2
0
    def save(photo, profile, text, filter, crest, folder):
        # Open the image
        background_image = Files.open_url(photo)

        # Resize and crop
        background_image = Images.treat_image(background_image)

        # Set the black grandient layer
        background_image = Images.set_gradient(background_image, 'full')

        background_image = Images.set_gradient(background_image, 'footer')

        # Apply the Data Science logo
        logo = Files.open_local('./src/images/logo.png')
        background_image = Images.apply_image(background_image, logo, (10, 10),
                                              (75, 75))

        # Stats
        if profile:
            stats = Stats.get_player_data(profile, filter)
            background_image = Images.set_stats(background_image, stats, text)

        # Apply the club crest
        if crest:
            thumb_size = 125, 125
            for i in range(len(crest)):
                crest_i = i + 1
                crest_len = len(crest)
                crest_item = Files.open_url(crest[i])
                crest_item.thumbnail(thumb_size, Image.ANTIALIAS)
                crest_position = Images.get_crest_position(
                    background_image, crest_item, stats['player'], crest_i,
                    crest_len)
                background_image = Images.apply_image(background_image,
                                                      crest_item,
                                                      crest_position,
                                                      (crest_item.size))

        file_name = Files.get_file_name(stats['player'], text)
        Files.save(background_image, folder, file_name)
pd.options.mode.chained_assignment = None

from classes.preprocessing import Preprocessing
from classes.stats import Stats


if __name__ == '__main__':
    
    # ************************************************** #
    #           PREPROCESSING OF THE DATASET             #
    # ************************************************** #

    dir = os.path.dirname(os.path.realpath(__file__))
    dataset = pd.read_csv(dir + '/dataset/IMDBDataset.csv')
    
    stats = Stats()
    prep = Preprocessing(dataset)
    
    # Make a dictionary by tokenizing all words in the dataset
    prep.make_dictionary()
    
    # Encode all words with integer IDs
    # Encode only the most used words in the dataset, any other words encode as 0
    n_top_used_words = 10000
    dataset = prep.encode_dataset_column(df=dataset, field="review", use_top_words=n_top_used_words)

    # Encode target variables to binary representation
    dataset = prep.string_to_int(df=dataset, params={"sentiment": {'positive': 1, 'negative': 0}})

    # Pad all reviews, remove reviews that have no words, trim reviews that exceed the review_len value
    review_len = 500
示例#4
0
import pandas as pd
pd.options.mode.chained_assignment = None

from classes.preprocessing import Preprocessing
from classes.stats import Stats

if __name__ == '__main__':

    # ************************************************** #
    #           PREPROCESSING OF THE DATASET             #
    # ************************************************** #

    dir = os.path.dirname(os.path.realpath(__file__))
    dataset = pd.read_csv(dir + '/dataset/IMDBDataset.csv')

    stats = Stats()
    prep = Preprocessing(dataset)

    # Make a dictionary by tokenizing all words in the dataset
    prep.make_dictionary()

    # Encode all words with integer IDs
    # Encode only the most used words in the dataset, any other words encode as 0
    n_top_used_words = 10000
    dataset = prep.encode_dataset_column(df=dataset,
                                         field="review",
                                         use_top_words=n_top_used_words)

    # Encode target variables to binary representation
    dataset = prep.string_to_int(
        df=dataset, params={"sentiment": {
    # ************************************************** #
    stats_bank = {"lstm":[], "lstm_cnn":[]}
    
    state_size  = 256
    max_words   = n_top_used_words
    vector_size = 32
    input_size  = X_train.shape[1]
    batch_size  = 250
    epochs      = 4


    # ************************************************** #
    #              THE CNN LSTM MODEL                    #
    # ************************************************** #

    lstmcnn_stats = Stats()

    lstmcnn_model=Sequential([
        Embedding(max_words + 1, output_dim=vector_size, input_length=input_size, batch_input_shape=[batch_size, None]),
        Conv1D(filters=128, kernel_size=32, padding='same', activation=tf.nn.tanh),
        MaxPooling1D(),
        LSTM(state_size, return_sequences=True, stateful=True, activation=tf.nn.tanh),
        Flatten(),
        Dense(128, activation=tf.nn.relu, use_bias=True),
        Dense(1, activation=tf.nn.sigmoid)
    ])

    # print_layer_config(lstmcnn_model.layers)
    lstmcnn_model.compile(loss=losses.binary_crossentropy, optimizer='adam', metrics=['accuracy'])
    # Train the model
    for i in range(epochs):
示例#6
0
import pandas as pd
pd.options.mode.chained_assignment = None

from classes.preprocessing import Preprocessing
from classes.stats import Stats

if __name__ == '__main__':

    # ************************************************** #
    #           PREPROCESSING OF THE DATASET             #
    # ************************************************** #

    dir = os.path.dirname(os.path.realpath(__file__))
    dataset = pd.read_csv(dir + '/../IMDB/dataset/IMDBDataset.csv')

    stats = Stats()
    prep = Preprocessing(dataset)

    # Make a dictionary by tokenizing all words in the dataset
    prep.make_dictionary()

    # Encode all words with integer IDs
    # Encode only the most used words in the dataset, any other words encode as 0
    n_top_used_words = 10000
    dataset = prep.encode_dataset_column(df=dataset,
                                         field="review",
                                         use_top_words=n_top_used_words)

    # Encode target variables to binary representation
    dataset = prep.string_to_int(
        df=dataset, params={"sentiment": {
示例#7
0
    def buy(self):
        """Buy upgrades for both energy and magic.

        Requires the confirmation popup button for EXP purchases in settings
        to be turned OFF.

        This uses all available exp, so use with caution.
        """
        if self.ecap < 10000 or self.ecap % 250 != 0:
            print("Ecap value not divisible by 250 or lower than 10000, not" +
                  " spending exp.")
            return
        if self.mcap < 10000 or self.mcap % 250 != 0:
            print("Mcap value not divisible by 250 or lower than 10000, not" +
                  " spending exp.")
            return

        Stats.set_value_with_ocr("XP")
        if Stats.OCR_failed:
            print('OCR failed, exiting upgrade routine.')
            return

        current_exp = Stats.xp

        e_cost = coords.EPOWER_COST + coords.ECAP_COST * self.ecap + (
            coords.EBAR_COST * self.ebar)

        m_cost = coords.MPOWER_COST + coords.MCAP_COST * self.mcap + (
            coords.MBAR_COST * self.mbar)

        total_price = m_cost + self.e2m_ratio * e_cost

        # Skip upgrading if we don't have enough exp to buy at least one
        # complete set of upgrades, in order to maintain our perfect ratios :)

        if total_price > current_exp:
            if self.report:
                print("No XP Upgrade :{:^8} of {:^8}".format(
                    Helper.human_format(current_exp),
                    Helper.human_format(total_price)))
            return

        amount = int(current_exp // total_price)

        e_power = amount * self.e2m_ratio
        e_cap = amount * self.ecap * self.e2m_ratio
        e_bars = amount * self.ebar * self.e2m_ratio
        m_power = amount
        m_cap = amount * self.mcap
        m_bars = amount * self.mbar

        Navigation.exp()

        Inputs.click(*coords.EM_POW_BOX)
        Inputs.send_string(str(e_power))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_CAP_BOX)
        Inputs.send_string(str(e_cap))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_BAR_BOX)
        Inputs.send_string(str(e_bars))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_POW_BUY)
        Inputs.click(*coords.EM_CAP_BUY)
        Inputs.click(*coords.EM_BAR_BUY)

        Navigation.exp_magic()

        Inputs.click(*coords.EM_POW_BOX)
        Inputs.send_string(str(m_power))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_CAP_BOX)
        Inputs.send_string(str(m_cap))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_BAR_BOX)
        Inputs.send_string(str(m_bars))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_POW_BUY)
        Inputs.click(*coords.EM_CAP_BUY)
        Inputs.click(*coords.EM_BAR_BUY)

        Stats.set_value_with_ocr("XP")

        total_spent = coords.EPOWER_COST * e_power + coords.ECAP_COST * e_cap + coords.EBAR_COST * e_bars
        total_spent += coords.MPOWER_COST * m_power + coords.MCAP_COST * m_cap + coords.MBAR_COST * m_bars

        if self.report:
            print("Spent XP:{:^8}".format(Helper.human_format(total_spent)))
            print(
                "Energy | Pow:{:^8}{:^3}Cap:{:^8}{:^3}Bar:{:^8}{:^3}Magic | Pow:{:^8}{:^3}Cap:{:^8}{:^3}Bar:{:^8}"
                .format(Helper.human_format(e_power), "|",
                        Helper.human_format(e_cap), "|",
                        Helper.human_format(e_bars), "|",
                        Helper.human_format(m_power), "|",
                        Helper.human_format(m_cap), "|",
                        Helper.human_format(m_bars)))
示例#8
0
    def buy(self):
        """Buy upgrades for hack energy

        Requires the confirmation popup button for EXP purchases in settings
        to be turned OFF.

        This uses all available exp, so use with caution.
        """
        if (self.hcap < 10000 or self.hcap % 250 != 0) and self.hcap != 0:
            print("Ecap value not divisible by 250 or lower than 10000, not" +
                  " spending exp.")
            return

        Stats.set_value_with_ocr("XP")
        if Stats.OCR_failed:
            print('OCR failed, exiting upgrade routine.')
            return

        current_exp = Stats.xp

        total_price = coords.HPOWER_COST * self.hpower + coords.HCAP_COST * self.hcap + coords.HBAR_COST * self.hbar

        # Skip upgrading if we don't have enough exp to buy at least one
        # complete set of upgrades, in order to maintain our perfect ratios :)

        if total_price > current_exp:
            if self.report:
                print("No XP Upgrade :{:^8} of {:^8}".format(
                    Helper.human_format(current_exp),
                    Helper.human_format(total_price)))
            return

        amount = int(current_exp // total_price)

        h_power = amount * self.hpower
        h_cap = amount * self.hcap
        h_bars = amount * self.hbar

        Navigation.exp_hack()

        Inputs.click(*coords.EM_POW_BOX)
        Inputs.send_string(str(h_power))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_CAP_BOX)
        Inputs.send_string(str(h_cap))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_BAR_BOX)
        Inputs.send_string(str(h_bars))
        time.sleep(userset.MEDIUM_SLEEP)

        if h_power > 0:
            Inputs.click(*coords.EM_POW_BUY)
        if h_cap > 0:
            Inputs.click(*coords.EM_CAP_BUY)
        if h_bars > 0:
            Inputs.click(*coords.EM_BAR_BUY)

        Stats.set_value_with_ocr("XP")

        total_spent = coords.HPOWER_COST * h_power + coords.HCAP_COST * h_cap + coords.HBAR_COST * h_bars

        if self.report:
            print("Spent XP:{:^8}".format(Helper.human_format(total_spent)))
            print("New | Pow:{:^8}{:^3}Cap:{:^8}{:^3}Bar:{:^8}".format(
                Helper.human_format(h_power), "|", Helper.human_format(h_cap),
                "|", Helper.human_format(h_bars)))
示例#9
0
    def buy(self):
        """Buy upgrades for power, toughness, health and regen

        Requires the confirmation popup button for EXP purchases in settings
        to be turned OFF.

        This uses all available exp, so use with caution.
        """
        Stats.set_value_with_ocr("XP")

        if Stats.OCR_failed:
            print('OCR failed, exiting upgrade routine.')
            return

        current_exp = Stats.xp

        total_price = (coords.APOWER_COST * self.power * self.ratio)
        total_price += (coords.ATOUGHNESS_COST * self.toughness * self.ratio)
        total_price += (coords.AHEALTH_COST * self.health * 10)
        total_price += math.floor(coords.AREGEN_COST * self.regen / 10)

        # Skip upgrading if we don't have enough exp to buy at least one
        # complete set of upgrades, in order to maintain our perfect ratios :)

        if total_price > current_exp:
            if self.report:
                print("No XP Upgrade :{:^8} of {:^8}".format(
                    Helper.human_format(current_exp),
                    Helper.human_format(total_price)))
            return

        amount = int(current_exp // total_price)

        a_power = amount * self.ratio
        a_toughness = amount * self.ratio
        a_health = amount * 10
        a_regen = math.floor(amount / 10)
        if a_regen < 1: a_regen = 1.0

        Navigation.exp_adventure()

        Inputs.click(*coords.EM_ADV_BOX)
        Inputs.send_string(str(a_power))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_POW_BOX)
        Inputs.send_string(str(a_toughness))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_CAP_BOX)
        Inputs.send_string(str(a_health))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_BAR_BOX)
        Inputs.send_string(str(a_regen))
        time.sleep(userset.MEDIUM_SLEEP)

        Inputs.click(*coords.EM_ADV_BUT)
        Inputs.click(*coords.EM_POW_BUY)
        Inputs.click(*coords.EM_CAP_BUY)
        Inputs.click(*coords.EM_BAR_BUY)

        Stats.set_value_with_ocr("XP")

        total_spent = coords.APOWER_COST * a_power
        total_spent += coords.ATOUGHNESS_COST * a_toughness
        total_spent += coords.AHEALTH_COST * a_health
        total_spent += coords.AREGEN_COST * a_regen

        if self.report:
            print("Spent XP:{:^8}".format(Helper.human_format(total_spent)))
            print(
                "Power:{:^8}{:^3} Defense:{:^8}{:^3} Health:{:^8}{:^3} Regen:{:^8}"
                .format(Helper.human_format(a_power), "|",
                        Helper.human_format(a_toughness), "|",
                        Helper.human_format(a_health), "|",
                        Helper.human_format(a_regen)))
示例#10
0
 def save(data, profile, folder):
     stats, bio, ribbon = Stats.get_all_season(profile)
     for i in range(len(data)):
         sheet = Storyboard.draw_sheet(data[i], i, stats, bio, ribbon)
         file_name = Files.get_file_name(bio['name'], str(i))
         Files.save(sheet, folder, file_name)
示例#11
0
pd.options.mode.chained_assignment = None

from classes.preprocessing import Preprocessing
from classes.stats import Stats

if __name__ == '__main__':

    # ************************************************** #
    #           PREPROCESSING OF THE DATASET             #
    # ************************************************** #

    dir = os.path.dirname(os.path.realpath(__file__))
    dataset = pd.read_csv(dir + '/dataset/IMDBDataset.csv')
    dataset_orig = dataset.copy()

    stats = Stats()
    prep = Preprocessing(dataset)

    # Make a dictionary by tokenizing all words in the dataset
    prep.make_dictionary()

    # Encode all words with integer IDs
    # Encode only the most used words in the dataset, any other words encode as 0
    n_top_used_words = 10000
    dataset = prep.encode_dataset_column(df=dataset,
                                         field="review",
                                         use_top_words=n_top_used_words)

    # Encode target variables to binary representation
    dataset = prep.string_to_int(
        df=dataset, params={"sentiment": {