<commit_before>import common, colors
import psmove
import time
import psutil, os
import random
import numpy
from piaudio import Audio
from enum import Enum
from multiprocessing import Process, Value, Array
import json


# How fast/slow the music can go
SLOW_MUSIC_SPEED = 1.5
#this was 0.5
FAST_MUSIC_SPEED = 0.5

# The min and max timeframe in seconds for
# the speed change to trigger, randomly selected
MIN_MUSIC_FAST_TIME = 4
MAX_MUSIC_FAST_TIME = 8
MIN_MUSIC_SLOW_TIME = 10
MAX_MUSIC_SLOW_TIME = 23

#Sensitivity of the contollers
#changes by the values in common
#TODO: make commander should be harder to kill
SLOW_MAX = 1.3
SLOW_WARNING = 0.28
FAST_MAX = 2.5
FAST_WARNING = 1.3



#How long the speed change takes
INTERVAL_CHANGE = 1.5

#How long the winning moves shall sparkle
END_GAME_PAUSE = 4
KILL_GAME_PAUSE = 4


class Opts(Enum):
    alive = 0
    selection = 1
    holding = 2
    team = 3
    is_commander = 4

class Selections(Enum):
    nothing = 0
    a_button = 1
    trigger = 2
    triangle = 3

class Holding(Enum):
    not_holding = 0
    holding = 1

class Bool(Enum):
    no = 0
    yes = 1


#alpha bravo
Commander_colors = [colors.Colors.Orange.value,colors.Colors.Blue.value]
Overdrive_colors = [colors.Colors.Yellow.value,colors.Colors.Purple.value]
Current_commander_colors = [colors.Colors.Magenta.value,colors.Colors.Green.value]

class Team(Enum):
    alpha = 0
    bravo = 1


def calculate_flash_time(r,g,b, score):
    flash_percent = max(min(float(score)+0.2,1.0),0.0)
    #val_percent = (val-(flash_speed/2))/(flash_speed/2)
    new_r = int(common.lerp(255, r, flash_percent))
    new_g = int(common.lerp(255, g, flash_percent))
    new_b = int(common.lerp(255, b, flash_percent))
    return (new_r, new_g, new_b)

def track_move(move_serial, move_num, team, num_teams, dead_move, force_color, music_speed, commander_intro, move_opts, power, overdrive):
    #proc = psutil.Process(os.getpid())
    #proc.nice(3)


    start = False
    no_rumble = time.time() + 1
    move_last_value = None
    move = common.get_move(move_serial, move_num)
    team_colors = colors.generate_colors(num_teams)
    #keep on looping while move is not dead
    ready = False
    move.set_leds(0,0,0)
    move.update_leds()
    time.sleep(1)
    vibrate = False
    vibration_time = time.time() + 1
    flash_lights = True
    flash_lights_timer = 0
    change_arr = [0,0,0]

    death_time = 8
    time_of_death = time.time()

    while commander_intro.value == 1:
        if move.poll():
            button = common.Button(move.get_buttons())
            if button == common.Button.MIDDLE and move_opts[Opts.holding.value] == Holding.not_holding.value:

                move_opts[Opts.selection.value] = Selections.a_button.value
                move_opts[Opts.holding.value] = Holding.holding.value
            elif button == common.Button.TRIANGLE and move_opts[Opts.holding.value] == Holding.not_holding.value:

                move_opts[Opts.selection.value] = Selections.triangle.value
                move_opts[Opts.holding.value] = Holding.holding.value

            elif move_opts[Opts.is_commander.value] == Bool.no.value and move_opts[Opts.holding.value] == Holding.holding.value:
                move.set_leds(200,200,200)

            elif move_opts[Opts.is_commander.value] == Bool.yes.value and move_opts[Opts.holding.value] == Holding.holding.value:
                    move.set_leds(*Current_commander_colors[team])
            else:
                move.set_leds(*Commander_colors[team])
        move.update_leds()

    move_opts[Opts.holding.value] = Holding.not_holding.value
    move_opts[Opts.selection.value] = Selections.nothing.value

    while True:
        if sum(force_color) != 0:
            no_rumble_time = time.time() + 5
            time.sleep(0.01)
            move.set_leds(*force_color)
            move.update_leds()
            move.set_rumble(0)
            no_rumble = time.time() + 0.5
        #if we are not dead
        elif dead_move.value == 1:
            if move.poll():
                ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf)
                total = sum([ax, ay, az])
                if move_last_value is not None:
                    change_real = abs(move_last_value - total)
                    change_arr[0] = change_arr[1]<commit_msg>Sqrt to commander<commit_after>import common, colors
import psmove
import time
import psutil, os
import random
import numpy
from piaudio import Audio
from enum import Enum
from multiprocessing import Process, Value, Array
import json


# How fast/slow the music can go
SLOW_MUSIC_SPEED = 1.5
#this was 0.5
FAST_MUSIC_SPEED = 0.5

# The min and max timeframe in seconds for
# the speed change to trigger, randomly selected
MIN_MUSIC_FAST_TIME = 4
MAX_MUSIC_FAST_TIME = 8
MIN_MUSIC_SLOW_TIME = 10
MAX_MUSIC_SLOW_TIME = 23

#Sensitivity of the contollers
#changes by the values in common
#TODO: make commander should be harder to kill
SLOW_MAX = 1.3
SLOW_WARNING = 0.28
FAST_MAX = 2.5
FAST_WARNING = 1.3



#How long the speed change takes
INTERVAL_CHANGE = 1.5

#How long the winning moves shall sparkle
END_GAME_PAUSE = 4
KILL_GAME_PAUSE = 4


class Opts(Enum):
    alive = 0
    selection = 1
    holding = 2
    team = 3
    is_commander = 4

class Selections(Enum):
    nothing = 0
    a_button = 1
    trigger = 2
    triangle = 3

class Holding(Enum):
    not_holding = 0
    holding = 1

class Bool(Enum):
    no = 0
    yes = 1


#alpha bravo
Commander_colors = [colors.Colors.Orange.value,colors.Colors.Blue.value]
Overdrive_colors = [colors.Colors.Yellow.value,colors.Colors.Purple.value]
Current_commander_colors = [colors.Colors.Magenta.value,colors.Colors.Green.value]

class Team(Enum):
    alpha = 0
    bravo = 1


def calculate_flash_time(r,g,b, score):
    flash_percent = max(min(float(score)+0.2,1.0),0.0)
    #val_percent = (val-(flash_speed/2))/(flash_speed/2)
    new_r = int(common.lerp(255, r, flash_percent))
    new_g = int(common.lerp(255, g, flash_percent))
    new_b = int(common.lerp(255, b, flash_percent))
    return (new_r, new_g, new_b)

def track_move(move_serial, move_num, team, num_teams, dead_move, force_color, music_speed, commander_intro, move_opts, power, overdrive):
    #proc = psutil.Process(os.getpid())
    #proc.nice(3)


    start = False
    no_rumble = time.time() + 1
    move_last_value = None
    move = common.get_move(move_serial, move_num)
    team_colors = colors.generate_colors(num_teams)
    #keep on looping while move is not dead
    ready = False
    move.set_leds(0,0,0)
    move.update_leds()
    time.sleep(1)
    vibrate = False
    vibration_time = time.time() + 1
    flash_lights = True
    flash_lights_timer = 0
    change_arr = [0,0,0]

    death_time = 8
    time_of_death = time.time()

    while commander_intro.value == 1:
        if move.poll():
            button = common.Button(move.get_buttons())
            if button == common.Button.MIDDLE and move_opts[Opts.holding.value] == Holding.not_holding.value:

                move_opts[Opts.selection.value] = Selections.a_button.value
                move_opts[Opts.holding.value] = Holding.holding.value
            elif button == common.Button.TRIANGLE and move_opts[Opts.holding.value] == Holding.not_holding.value:

                move_opts[Opts.selection.value] = Selections.triangle.value
                move_opts[Opts.holding.value] = Holding.holding.value

            elif move_opts[Opts.is_commander.value] == Bool.no.value and move_opts[Opts.holding.value] == Holding.holding.value:
                move.set_leds(200,200,200)

            elif move_opts[Opts.is_commander.value] == Bool.yes.value and move_opts[Opts.holding.value] == Holding.holding.value:
                    move.set_leds(*Current_commander_colors[team])
            else:
                move.set_leds(*Commander_colors[team])
        move.update_leds()

    move_opts[Opts.holding.value] = Holding.not_holding.value
    move_opts[Opts.selection.value] = Selections.nothing.value

    while True:
        if sum(force_color) != 0:
            no_rumble_time = time.time() + 5
            time.sleep(0.01)
            move.set_leds(*force_color)
            move.update_leds()
            move.set_rumble(0)
            no_rumble = time.time() + 0.5
        #if we are not dead
        elif dead_move.value == 1:
            if move.poll():
                ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf)
                #total = sum([ax, ay, az])
                total = sqrt(sum([ax**2, ay**2, az**2]))
                if move_last_value is not None:
                    change_real = abs(move_last_value - total)
                    change_arr[0] = change_arr[1]
{'fraction_non_alphanumeric': 0.10121364781314403, 'fraction_numerical': 0.020952599038241357, 'mean_word_length': 2.8077593722755014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6736985', 'n_tokens_mistral': 3147, 'n_tokens_neox': 2951, 'n_words': 661}