Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,011 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ audio/Zombie/music/ | |
|
||
#other stuff | ||
*.ini | ||
*.yaml | ||
apfiles/ap_active | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<<<<<<< Updated upstream | ||
from enum import Enum | ||
|
||
class Colors(Enum): | ||
Pink = (255,96,96) | ||
Magenta = (255,0,192) | ||
Orange = (255,64,0) | ||
Yellow = (255,255,0) | ||
Green = (0,255,0) | ||
Turquoise = (0,255,255) | ||
Blue = (0,0,255) | ||
Purple = (96,0,255) | ||
|
||
color_list = [x for x in Colors] | ||
|
||
quad_teams_banned = { | ||
Colors.Pink : [Colors.Magenta,Colors.Purple], | ||
Colors.Magenta : [Colors.Pink,Colors.Purple], | ||
Colors.Orange : [Colors.Yellow], | ||
Colors.Yellow : [Colors.Orange], | ||
Colors.Green : [Colors.Turquoise], | ||
Colors.Turquoise : [Colors.Green,Colors.Blue], | ||
Colors.Blue : [Colors.Turquoise], | ||
Colors.Purple : [Colors.Magenta,Colors.Pink] | ||
} | ||
|
||
for a,b,c,d in [(a,b,c,d) for a in range(8) for b in range(a+1,8) for c in range(b+1,8) for d in range(c+1,8)]: | ||
quad = [color_list[x] for x in (a,b,c,d)] | ||
|
||
quad_banned = [quad_teams_banned[i] for i in quad] | ||
quad_banned = list(set([i for sublist in quad_banned for i in sublist])) | ||
bad = False | ||
for color in quad: | ||
if color in quad_banned: | ||
bad = True | ||
if not bad: | ||
print(quad) | ||
======= | ||
import common | ||
|
||
for t in [2,3,17]: | ||
for i in range(20): | ||
teams = common.generate_team_colors(t) | ||
print([x.name for x in teams]) | ||
>>>>>>> Stashed changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import psmove | ||
import colorsys | ||
import time | ||
|
||
def hsv2rgb(h, s, v): | ||
return tuple(int(color * 255) for color in colorsys.hsv_to_rgb(h, s, v)) | ||
|
||
moves = [psmove.PSMove(x) for x in range(psmove.count_connected())] | ||
|
||
rgbwheel = [ | ||
'FF0000', | ||
'FF8000', | ||
'FFFF00', | ||
'80FF00', | ||
'00FF00', | ||
'00FF80', | ||
'00FFFF', | ||
'0080FF', | ||
'0000FF', | ||
'8000FF', | ||
'FF00FF', | ||
'FF0080'] | ||
|
||
rbywheel = [ | ||
'FE2712', | ||
'FC600A', | ||
'FB9902', | ||
'FCCC1A', | ||
'FEFE33', | ||
'B2D732', | ||
'66B032', | ||
'347C98', | ||
'0247FE', | ||
'4424D6', | ||
'8601AF', | ||
'C21460'] | ||
|
||
rbywheel2 = [ | ||
'FF0000', | ||
'FF2000', | ||
'FF4000', | ||
'FFA000', | ||
'FFFF00', | ||
'80FF00', | ||
'00FF00', | ||
'008080', | ||
'0000FF', | ||
'4000FF', | ||
'8000FF', | ||
'800080'] | ||
|
||
joustwheel = [ | ||
'FF7070', #pink | ||
'FF00C0', #magenta | ||
'FF4000', #orange | ||
'FFFF00', #yellow | ||
'00FF00', #green | ||
'00FFFF', #turquoise | ||
'0000FF', #blue | ||
'6000FF', #purple | ||
'ffffff', #white | ||
'FF0000', #red | ||
'FF3278', #splatoon pink | ||
'1edc00'] #splatoon green | ||
|
||
newcolors = [ | ||
'FFFF00', #yellow | ||
'6000FF', #purple | ||
'FF4000', #orange | ||
'FF6060', #pink | ||
'00FFFF', #turquoise | ||
'FF0000', #red | ||
'ffff14', #YELLOW = | ||
'7e1e9c', #PURPLE = | ||
'f97306', #ORANGE = | ||
'ff81c0', #PINK = | ||
'06c2ac', #TURQUOISE = | ||
'653700'] #BROWN = | ||
|
||
def colorhex(hex): | ||
r = int(hex[0:2],16) | ||
g = int(hex[2:4],16) | ||
b = int(hex[4:6],16) | ||
return (r,g,b) | ||
|
||
|
||
s=0 | ||
while True: | ||
for i,move in enumerate(moves): | ||
color = colorhex(joustwheel[(s+i)%12]) | ||
move.set_leds(*color) | ||
move.update_leds() | ||
time.sleep(0.01) | ||
#s += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export PYTHONPATH=/home/pi/psmoveapi/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from enum import Enum | ||
|
||
class Colors(Enum): | ||
Pink = (255,96,96) | ||
Magenta = (255,0,192) | ||
Orange = (255,64,0) | ||
Yellow = (255,255,0) | ||
Green = (0,255,0) | ||
Turquoise = (0,255,255) | ||
Blue = (0,0,255) | ||
Purple = (96,0,255) | ||
|
||
color_list = [x for x in Colors] | ||
|
||
quad_teams_banned = { | ||
Colors.Pink : [Colors.Magenta,Colors.Purple], | ||
Colors.Magenta : [Colors.Pink,Colors.Purple], | ||
Colors.Orange : [Colors.Yellow], | ||
Colors.Yellow : [Colors.Orange], | ||
Colors.Green : [Colors.Turquoise], | ||
Colors.Turquoise : [Colors.Green,Colors.Blue], | ||
Colors.Blue : [Colors.Turquoise], | ||
Colors.Purple : [Colors.Magenta,Colors.Pink] | ||
} | ||
|
||
for a,b,c,d in [(a,b,c,d) for a in range(8) for b in range(a+1,8) for c in range(b+1,8) for d in range(c+1,8)]: | ||
quad = [color_list[x] for x in (a,b,c,d)] | ||
|
||
quad_banned = [quad_teams_banned[i] for i in quad] | ||
quad_banned = list(set([i for sublist in quad_banned for i in sublist])) | ||
bad = False | ||
for color in quad: | ||
if color in quad_banned: | ||
bad = True | ||
if not bad: | ||
print(quad) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import psmove | ||
import colorsys | ||
import time | ||
from enum import Enum | ||
import random | ||
|
||
|
||
color_range = 255 | ||
|
||
def hsv2rgb(h, s, v): | ||
return tuple(int(color * color_range) for color in colorsys.hsv_to_rgb(h, s, v)) | ||
|
||
def generate_colors(color_num): | ||
Hue = [ ((num + 1.0)/color_num, 1, 1) for num in range(color_num) ] | ||
colors = [ hsv2rgb(*hsv_color) for hsv_color in Hue ] | ||
return colors | ||
|
||
def generate_team_colors(num_teams): | ||
if num_teams == 1: | ||
#only Werewolf, and it's ignored anyway, but let's prevent errors, eh? | ||
return [random.choice(team_color_list)] | ||
if num_teams == 2: | ||
team1 = random.choice(team_color_list) | ||
team2 = random.choice(dual_teams[team1]) | ||
return [team1,team2] | ||
elif num_teams == 3: | ||
team1 = random.choice(team_color_list) | ||
team2 = random.choice(tri_teams[team1]) | ||
allowed = tri_teams[team1] + tri_teams[team2] | ||
team3_allowed = [x for x in allowed if x in tri_teams[team1] and x in tri_teams[team2]] | ||
team3 = random.choice(team3_allowed) | ||
return [team1,team2,team3] | ||
elif num_teams == 4: | ||
team_a = random.choice([Colors.Orange,Colors.Yellow]) | ||
team_b = random.choice([Colors.Purple,Colors.Pink,Colors.Magenta]) | ||
teams = [Colors.Green,Colors.Blue,team_a,team_b] | ||
random.shuffle(teams) | ||
return teams | ||
elif num_teams in [5,6,7,8]: | ||
teams = [five_colors,six_colors,seven_colors,eight_colors][num_teams-5] | ||
random.shuffle(teams) | ||
return teams | ||
elif num_teams > 8: | ||
#we're in FFA territory now | ||
remaining = eight_colors[:] | ||
teams = eight_colors[:] | ||
for i in range(7,num_teams): | ||
next_team = random.choice(remaining) | ||
remaining.remove(next_team) | ||
teams.append(next_team) | ||
if remaining == []: | ||
remaining = eight_colors[:] | ||
random.shuffle(teams) | ||
return teams | ||
|
||
def change_color(color_array, r, g, b): | ||
color_array[0] = r | ||
color_array[1] = g | ||
color_array[2] = b | ||
|
||
class Colors(Enum): | ||
#first 8 are team colors | ||
Pink = (255,108,108) | ||
Magenta = (255,0,192) | ||
Orange = (255,64,0) | ||
Yellow = (255,255,0) | ||
Green = (0,255,0) | ||
Turquoise = (0,255,255) | ||
Blue = (0,0,255) | ||
Purple = (96,0,255) | ||
#these are used for various things | ||
White = (255,255,255) | ||
White80 = (200,200,200) | ||
White60 = (150,150,150) | ||
White20 = (50,50,50) | ||
Red = (255,0,0) | ||
Red60 = (150,0,0) | ||
Red80 = (200,0,0) | ||
Green80 = (0,200,0) | ||
LimeGreen = (100,255,0) | ||
Zombie = (50,150,50) | ||
Black = (0,0,0) | ||
#stay fresh | ||
SplatoonGreen = (255,50,120) | ||
SplatoonPink = (30,220,0) | ||
|
||
team_color_list = [x for x in Colors][0:8] | ||
|
||
#pick one color, then pick among the colors not near the first | ||
dual_teams = { | ||
Colors.Pink : [Colors.Yellow,Colors.Green,Colors.Turquoise,Colors.Blue], | ||
Colors.Magenta : [Colors.Yellow,Colors.Green,Colors.Turquoise,Colors.Blue], | ||
Colors.Orange : [Colors.Green,Colors.Turquoise,Colors.Blue,Colors.Purple], | ||
Colors.Yellow : [Colors.Turquoise,Colors.Blue,Colors.Purple,Colors.Pink,Colors.Magenta], | ||
Colors.Green : [Colors.Purple,Colors.Pink,Colors.Magenta,Colors.Orange], | ||
Colors.Turquoise : [Colors.Purple,Colors.Pink,Colors.Magenta,Colors.Orange,Colors.Yellow], | ||
Colors.Blue : [Colors.Pink,Colors.Magenta,Colors.Orange,Colors.Yellow], | ||
Colors.Purple : [Colors.Orange,Colors.Yellow,Colors.Green,Colors.Turquoise] | ||
} | ||
|
||
#remove pairings from dual_teams that don't have a shared third color | ||
#pick two colors like dual_team, then pick third shared between those two | ||
tri_teams = { | ||
Colors.Pink : [Colors.Yellow,Colors.Turquoise,Colors.Blue], | ||
Colors.Magenta : [Colors.Yellow,Colors.Turquoise,Colors.Blue], | ||
Colors.Orange : [Colors.Green,Colors.Turquoise,Colors.Purple], | ||
Colors.Yellow : [Colors.Turquoise,Colors.Blue,Colors.Purple,Colors.Pink,Colors.Magenta], | ||
Colors.Green : [Colors.Purple,Colors.Orange], | ||
Colors.Turquoise : [Colors.Purple,Colors.Pink,Colors.Magenta,Colors.Orange,Colors.Yellow], | ||
Colors.Blue : [Colors.Pink,Colors.Magenta,Colors.Yellow], | ||
Colors.Purple : [Colors.Orange,Colors.Yellow,Colors.Green,Colors.Turquoise] | ||
} | ||
|
||
""" | ||
quad_teams - generated above, here's how | ||
all groups have green and blue, one of orange/yellow, one of pink/magenta/purple | ||
""" | ||
|
||
#at this point just force colors | ||
five_colors = [Colors.Orange,Colors.Yellow,Colors.Green,Colors.Blue,Colors.Purple] | ||
six_colors = [Colors.Magenta,Colors.Orange,Colors.Yellow,Colors.Green,Colors.Blue,Colors.Purple] | ||
seven_colors = team_color_list[1:] #all but pink | ||
eight_colors = team_color_list | ||
|
||
multi_colors = [five_colors,six_colors,seven_colors,eight_colors] |
Oops, something went wrong.