def somulate(self):
    waves_dict = {}
    max_wavelen = 0
    avg_wavelen = 0
    max_total = 0
    total_comps = 0
    computers_in_environment = 0
    score = 0
    try:
        if (not self.connected):
            print("Can't simulate without a valid DB connection!")
        else:
            self.session = self.driver.session()
            computers = self.get_start_computers()
            print('Running simulation...')
            computers_in_environment = self.count_computers()
            future_to_totals_waves_pairs = {self.executor.submit(self.simulate_wave_for_computer, computer): computer for computer in computers}
            for future in as_completed(future_to_totals_waves_pairs):
                computer = future_to_totals_waves_pairs[future]
                try:
                    total_waves_pair = future.result()
                    total = total_waves_pair[0]
                    waves = total_waves_pair[1]
                    score += total
                    if (total > 0):
                        total_comps += 1
                        if (len(waves) > max_wavelen):
                            max_wavelen = len(waves)
                        if (total > max_total):
                            max_total = total
                        avg_wavelen += len(waves)
                        waves_dict[computer] = {'total': total, 'waves': waves}
                        print('{},{},{}'.format(computer, str(total), ','.join(waves)))
                    else:
                        waves_dict[computer] = {'total': 0, 'waves': ['0']}
                        print('{} - no waves'.format(computer))
                except Exception as exc:
                    print(('Exception while processing %s: %s' % (computer, exc)))
            if (total_comps > 0):
                avg_wavelen = (avg_wavelen / total_comps)
                score = round(((score / (computers_in_environment ** 2)) * 100))
            else:
                avg_wavelen = 0
            sorted_waves = {k: v for (k, v) in sorted(waves_dict.items(), key=(lambda item: item[1]['total']), reverse=True)}
            return (sorted_waves, max_wavelen, avg_wavelen, max_total, total_comps, computers_in_environment, score)
    except Exception as err:
        print('Error during simulation: {}'.format(err))
def somulate(self):
    waves_dict = {}
    max_wavelen = 0
    avg_wavelen = 0
    max_total = 0
    total_comps = 0
    computers_in_environment = 0
    score = 0
    try:
        if (not self.connected):
            print("Can't simulate without a valid DB connection!")
        else:
            self.session = self.driver.session()
            computers = self.get_start_computers()
            print('Running simulation...')
            computers_in_environment = self.count_computers()
            future_to_totals_waves_pairs = {self.executor.submit(self.simulate_wave_for_computer, computer): computer for computer in computers}
            for future in as_completed(future_to_totals_waves_pairs):
                computer = future_to_totals_waves_pairs[future]
                try:
                    total_waves_pair = future.result()
                    total = total_waves_pair[0]
                    waves = total_waves_pair[1]
                    score += total
                    if (total > 0):
                        total_comps += 1
                        if (len(waves) > max_wavelen):
                            max_wavelen = len(waves)
                        if (total > max_total):
                            max_total = total
                        avg_wavelen += len(waves)
                        waves_dict[computer] = {'total': total, 'waves': waves}
                        print('{},{},{}'.format(computer, str(total), ','.join(waves)))
                    else:
                        waves_dict[computer] = {'total': 0, 'waves': ['0']}
                        print('{} - no waves'.format(computer))
                except Exception as exc:
                    print(('Exception while processing %s: %s' % (computer, exc)))
            if (total_comps > 0):
                avg_wavelen = (avg_wavelen / total_comps)
                score = round(((score / (computers_in_environment ** 2)) * 100))
            else:
                avg_wavelen = 0
            sorted_waves = {k: v for (k, v) in sorted(waves_dict.items(), key=(lambda item: item[1]['total']), reverse=True)}
            return (sorted_waves, max_wavelen, avg_wavelen, max_total, total_comps, computers_in_environment, score)
    except Exception as err:
        print('Error during simulation: {}'.format(err))