Exemplo n.º 1
0
 def setUp(self):
     """Build Pair object and example days."""
     self.pair_maker = pair_mod.Pair()
     # Days with *0 are one week, days with *1 are the next week
     self.monday0 = date(2014, 8, 25)
     self.tuesday0 = date(2014, 8, 26)
     self.friday0 = date(2014, 8, 29)
     self.monday1 = date(2014, 9, 1)
Exemplo n.º 2
0
def test_pair_sum():
    """
    Test procedure for the sum method in the Pair class
    """
    print('Testing class Pair (sum)')
    try:
        obj = pair.Pair(1,2)
    except:
        introcs.quit_with_error('The initializer for Pair has the wrong number of parameters')

    introcs.assert_true(hasattr(obj,'sum'))
    result = 0
    try:
        result = obj.sum()
    except:
        introcs.quit_with_error('The sum method has the wrong number of parameters')
    introcs.assert_equals(3,result)
    introcs.assert_equals(7,pair.Pair(3,4).sum())
Exemplo n.º 3
0
 def centroid(self):
     """Returns the centroid of this set of points, as a Pair object."""
     n = len(self)
     if n == 0:
         return None
     sum = pair.Pair()  # initialize sum as the pair (0, 0)
     for point in self._points:
         sum += point
     sum.scale(1 / n)  # divide the sum by the number of points
     return sum
Exemplo n.º 4
0
def test_pair_init():
    """
    Test procedure for the initializer in the Pair class
    """
    print('Testing class Pair (__init__)')
    try:
        result = pair.Pair(1,2)
    except:
        introcs.quit_with_error('The initializer for Pair has the wrong number of parameters')

    introcs.assert_equals(pair.Pair, type(result))
    introcs.assert_true(hasattr(result,'first'))
    introcs.assert_true(hasattr(result,'second'))
    introcs.assert_equals(1, result.first )
    introcs.assert_equals(2, result.second)

    result = pair.Pair(3,5)
    introcs.assert_equals(pair.Pair, type(result))
    introcs.assert_equals(3, result.first )
    introcs.assert_equals(5, result.second)
Exemplo n.º 5
0
def lector():
    mensaje = " "
    while mensaje != "1":
        mensaje = input('Digite su oracion\n')
        #print(mensaje)
        myPair = pair.Pair(mensaje)
        listaResultados.append(myPair)
        cola.put(myPair)
        sem1.release()
    # Aqui sigue cuando lo que se encuentra es un 1
    sem2.acquire()
    imprimirResultados()
Exemplo n.º 6
0
    def __init__(self, command_queue=Queue(), status_manager=Manager()):

        if not os.path.isfile('joustconfig.ini'):
            self.create_settings()
        else:
            config = configparser.ConfigParser()
            config.read("joustconfig.ini")
            self.audio_toggle = config.getboolean("GENERAL", "audio")
            self.sensitivity = int(config['GENERAL']['sensitivity'])
            self.instructions = config.getboolean("GENERAL", "instructions")
            self.con_games = []
            for i in range(len(common.game_mode_names)):
                mode = common.game_mode_names[i]
                if config.getboolean("CONGAMES", mode):
                    self.con_games.append(i)
            if self.con_games == []:
                self.con_games = [0]

        self.enforce_minimum = True
        self.move_can_be_admin = True
        self.move_count = psmove.count_connected()
        self.dead_count = Value('i', 0)
        self.moves = [
            psmove.PSMove(x) for x in range(psmove.count_connected())
        ]
        self.admin_move = None
        #move controllers that have been taken out of play
        self.out_moves = {}
        self.random_added = []
        self.rand_game_list = []

        self.show_battery = Value('i', 0)

        self.tracked_moves = {}
        self.force_color = {}
        self.paired_moves = []
        self.move_opts = {}
        self.teams = {}
        self.game_mode = common.Games.Random.value
        self.old_game_mode = common.Games.Random.value
        self.pair = pair.Pair()

        self.command_queue = command_queue
        self.status_manager = status_manager
        self.status_ns = status_manager.Namespace()
        self.status_ns.status_dict = dict()
        self.command_from_web = ''

        self.i = 0
        #load audio now so it converts before the game begins
        self.choose_new_music()
Exemplo n.º 7
0
    def __init__(self):

        self.command_queue = Queue()
        self.joust_manager = Manager()
        self.ns = self.joust_manager.Namespace()

        self.web_proc = Process(target=webui.start_web,
                                args=(self.command_queue, self.ns))
        self.web_proc.start()

        self.ns.status = dict()
        self.ns.settings = dict()
        self.ns.battery_status = dict()
        self.command_from_web = ''
        self.initialize_settings()
        self.update_settings_file()

        #defined outside of ns.settings as it's a purely dev option
        self.experimental = False

        self.move_count = psmove.count_connected()
        self.dead_count = Value('i', 0)
        self.moves = [
            psmove.PSMove(x) for x in range(psmove.count_connected())
        ]
        self.admin_move = None
        #move controllers that have been taken out of play
        self.out_moves = {}
        self.random_added = []
        self.rand_game_list = []

        self.show_battery = Value('i', 0)

        #only allow one move to be paired at a time
        self.pair_one_move = True
        self.tracked_moves = {}
        self.force_color = {}
        self.paired_moves = []
        self.move_opts = {}
        self.teams = {}
        self.game_mode = common.Games.Random
        self.old_game_mode = common.Games.Random
        self.pair = pair.Pair()

        self.i = 0
        #load audio now so it converts before the game begins
        self.choose_new_music()
Exemplo n.º 8
0
    def __init__(self):
        self.move_count = psmove.count_connected()
        self.moves = [
            psmove.PSMove(x) for x in range(psmove.count_connected())
        ]
        self.out_moves = {}
        #may need to make it a dict of a list?
        self.random_added = []
        self.rand_game_list = list(range(GAME_MODES))
        self.rand_game_list.remove(common.Games.JoustTeams.value)
        self.rand_game_list.remove(common.Games.Random.value)
        self.rand_game_list.remove(common.Games.Commander.value)

        self.tracked_moves = {}
        self.paired_moves = []
        self.move_opts = {}
        self.teams = {}
        self.game_mode = common.Games.JoustFFA.value
        self.pair = pair.Pair()
        self.game_loop()
Exemplo n.º 9
0
    def __init__(self):
        self.move_count = psmove.count_connected()
        self.moves = [psmove.PSMove(x) for x in range(psmove.count_connected())]
        self.admin_move = None
        #move controllers that have been taken out of play
        self.out_moves = {}
        self.random_added = []
        self.rand_game_list = []

        self.sensitivity = Sensitivity.mid.value
        self.instructions = True
        self.show_battery = Value('i', 0)
        
        self.tracked_moves = {}
        self.force_color = {}
        self.paired_moves = []
        self.move_opts = {}
        self.teams = {}
        self.con_games = [common.Games.JoustFFA.value]
        self.game_mode = common.Games.Random.value
        self.old_game_mode = common.Games.Random.value
        self.pair = pair.Pair()
        self.game_loop()
Exemplo n.º 10
0
        """Returns the centroid of this set of points, as a Pair object."""
        n = len(self)
        if n == 0:
            return None
        sum = pair.Pair()  # initialize sum as the pair (0, 0)
        for point in self._points:
            sum += point
        sum.scale(1 / n)  # divide the sum by the number of points
        return sum

    def __str__(self):
        return repr([(point[0], point[1]) for point in self._points])


points = [
    pair.Pair(random.randint(0, 100), random.randint(0, 100)) for i in range(4)
]
for point in points:
    print(point)

pset = Pointset(points)
print(pset)
print(f"calling len on pset: {len(pset)}")
print(pset.centroid())

points = [(0, 0), (2, 0), (0, 2), (2, 2)]
pairified = [pair.Pair(i[0], i[1]) for i in points]
pset = Pointset(pairified)
print(f"second test pointset is \n\t{pset}")
expected = pair.Pair(1, 1)  # centroid should be the point right in the middle
actual = pset.centroid()
Exemplo n.º 11
0
    def __init__(self):

        self.command_queue = Queue()
        self.joust_manager = Manager()
        self.ns = self.joust_manager.Namespace()
        self.web_proc = Process(target=webui.start_web,
                                args=(self.command_queue, self.ns))
        self.web_proc.start()
        self.ns.status = dict()
        self.ns.settings = dict()
        self.ns.battery_status = dict()
        self.command_from_web = ''
        self.initialize_settings()
        self.update_settings_file()

        #check for update
        if platform == "linux" or platform == "linux2":
            self.big_update = update.check_for_update(
                self.ns.settings['menu_voice'])
        self.git_hash = update.run_command("git rev-parse HEAD")[:7]

        #defined outside of ns.settings as it's a purely dev option
        self.experimental = False
        self.move_count = psmove.count_connected()
        self.dead_count = Value('i', 0)
        self.moves = [
            psmove.PSMove(x) for x in range(psmove.count_connected())
        ]
        self.admin_move = None
        #move controllers that have been taken out of play
        self.out_moves = {}
        self.random_added = []
        self.rand_game_list = []

        self.show_battery = Value('i', 0)

        #only allow one move to be paired at a time
        self.pair_one_move = True
        self.tracked_moves = {}
        self.force_color = {}
        self.paired_moves = []
        self.move_opts = {}
        self.teams = {}
        self.game_mode = common.Games[self.ns.settings['current_game']]
        self.old_game_mode = self.game_mode
        self.pair = pair.Pair()

        self.menu = Value('i', 1)
        self.controller_game_mode = Value('i', 1)
        self.restart = Value('i', 0)
        self.controller_teams = {}
        self.controller_colors = {}
        self.dead_moves = {}
        self.music_speed = Value('d', 0)
        self.werewolf_reveal = Value('i', 2)
        self.show_team_colors = Value('i', 0)
        self.red_on_kill = Value('i', 0)
        self.zombie_opts = {}
        self.commander_intro = Value('i', 1)
        self.commander_move_opts = {}
        self.commander_powers = [Value('d', 0.0), Value('d', 0.0)]
        self.commander_overdrive = [Value('i', 0), Value('i', 0)]
        self.five_controller_opts = {}
        self.swapper_team_colors = Array('i', [0] * 6)
        self.fight_club_colors = {}
        self.invincible_moves = {}
        self.num_teams = Value('i', 1)
        self.bomb_color = Array('i', [0] * 3)
        self.game_start = Value('i', 0)
        self.false_colors = {}
        self.was_faked = {}
        self.rumble = {}
        self.kill_controller_proc = {}
        self.controller_sensitivity = Array('d', [0] * 10)
        self.dead_invince = Value('b', False)

        self.i = 0
        #load audio now so it converts before the game begins
        self.menu_music = Music("menu")
        self.joust_music = Music("joust")
        self.zombie_music = Music("zombie")
        self.commander_music = Music("commander")
        self.choose_new_music()
Exemplo n.º 12
0
import sys
import os
import time
sys.path.insert(0, '/home/pi/psmoveapi/build/')
import psmove
import pair

pairObj = pair.Pair()

exit = False
while not exit:
	connected = psmove.count_connected()
	input("Connect Moves via USB and press Enter.\nOr disconnect all USB Moves and press Enter to quit.")
	print("Moves connected: %d" % connected)
	moves = [psmove.PSMove(x) for x in range(connected)]
	exit = True
	for move in moves:
		print("Move %s connected via %s" % (move.get_serial(), ['Bluetooth','USB'][move.connection_type]))
		move.poll()
		print("Temperature is %d" % move.get_temperature())
		if move.connection_type == psmove.Conn_USB:
			pairObj.pair_move(move)
			move.set_leds(100,100,100)
			exit = False
			move.update_leds()
Exemplo n.º 13
0
 def __init__(self, initial):
     self.mean = pair.Pair(initial = initial)
     self.variance = initial
     self.count = 0
Exemplo n.º 14
0
 def setUp(self):
     """Build Pair object."""
     self.pair_maker = pair_mod.Pair()
Exemplo n.º 15
0
 def test_even_number_devs(self):
     """Build Pair object with an even number of devs, should stay even."""
     pair_mod.Pair.devs = ["dev1", "dev2"]
     pair_maker = pair_mod.Pair()
     assert len(pair_maker.devs) == 2
Exemplo n.º 16
0
 def test_odd_number_devs(self):
     """Build Pair object with odd number of devs, should be made even."""
     pair_mod.Pair.devs = ["dev1", "dev2", "dev3"]
     pair_maker = pair_mod.Pair()
     assert len(pair_maker.devs) == 4