Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Shepherd/recipemanager #733

Open
wants to merge 21 commits into
base: shepherd/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shepherd/Alliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Alliance:
team_1_number - Integer representing team number of first team
team_2_number - Integer representing team number of second team
score - Integer tracking the score of the Alliance
cooked - The number of ingredients that are cooked
"""

def __init__(self, name, team_1_name, team_1_number, team_2_name,
Expand All @@ -21,6 +22,7 @@ def __init__(self, name, team_1_name, team_1_number, team_2_name,
self.team_2_name = team_2_name
self.team_1_number = team_1_number
self.team_2_number = team_2_number
self.cooked = 0
self.score = 0
self.team_1_connection = False
self.team_2_connection = False
Expand All @@ -37,6 +39,7 @@ def change_score(self, amount):

def reset(self):
self.score = 0
self.cooked = 0
self.team_1_connection = False
self.team_2_connection = False
lcm_send(LCM_TARGETS.SCOREBOARD, SCOREBOARD_HEADER.SCORE,
Expand Down
77 changes: 77 additions & 0 deletions shepherd/RecipeManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from Utils import *


class RecipeManager():

master_recipes = [RECIPE_PROBABILITIES.EASY_RECIPE, RECIPE_PROBABILITIES.MEDIUM_RECIPE, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this is a list of references to an empty list... it does give me a good idea of how to manage the recipes tho.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to make it easier for us to load and reload the list by having a list that we can read from without the programmer looking back and forth
It's to make our lives and future people lives easier

Also, this is not empty (or I believe it shouldn't be)

RECIPE_PROBABILITIES.HARD_RECIPE, RECIPE_PROBABILITIES.VERY_HARD_RECIPE]
gold_recipes = []
blue_recipes = []
gold_recipes_completed = 0
blue_recipes_completed = 0

def generate_recipes(self):
ochan1 marked this conversation as resolved.
Show resolved Hide resolved
'''
reset recipe list with 4 newly selected recipes
both teams should have the same recipes
'''
self.gold_recipes.clear()
self.blue_recipes.clear()
for recipe in self.master_recipes:
self.gold_recipes += list(recipe.values)
self.blue_recipes += list(recipe.values)

def next_recipe(self, team):
'''
pop the recipe from the front of the list

The recipe being popped is done
'''
if team == ALLIANCE_COLOR.BLUE:
if self.blue_recipes:
self.blue_recipes.pop(0)
self.blue_recipes_completed += 1
else:
if self.gold_recipes:
self.gold_recipes.pop(0)
self.gold_recipes_completed += 1

def get_recipe(self, team):
'''
return first element of recipes
'''
if team == ALLIANCE_COLOR.BLUE:
if not self.blue_recipes:
return None
return self.blue_recipes[0]
else:
if not self.gold_recipes:
return None
return self.gold_recipes[0]

def check_recipe(self, team, ingredients, num_cooked=0):
'''
checks correctness of recipe
'''
recipes = []
if team == ALLIANCE_COLOR.BLUE:
recipes = self.blue_recipes
else:
recipes = self.gold_recipes
if len(recipes) != len(ingredients):
return False
else:
for item in ingredients:
if item not in recipes:
return False
return True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this line inside the else statement to appease the style checker :')


def set_recipes(self, gold_recipes, blue_recipes):
'''
overwrite recipes
'''
if gold_recipes != None:
self.gold_recipes = list(gold_recipes)

if blue_recipes != None:
self.blue_recipes = list(blue_recipes)
51 changes: 51 additions & 0 deletions shepherd/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,54 @@ class STATE():
WAIT = "wait"
TELEOP = "teleop"
END = "end"

class INGREDIENT():
BREAD = "Bread"
VEGETABLES = "Vegetables"
MEAT = "Meat"
CHEESE = "Cheese"
# COOKED_MEAT = "COOKED " + MEAT
# COOKED_BREAD = "COOKED " + BREAD
# COOKED_CHEESE = "COOKED " + CHEESE

class RECIPIES():
ochan1 marked this conversation as resolved.
Show resolved Hide resolved
BREADSTICKS = "Breadsticks"
SALAD = "Salad"
COLD_CUTS = "Cold Cuts"
TURKEY_SANDWICH = "Turkey Sandwich"
CAESAR_SALAD = "Caesar Salad"
MEAT_AND_POTATOES = "Meat and Potatoes"
HAMBURGER = "Hamburgers"
GRILLED_CHEESE = "Grilled Cheese"
JALAPENO_POPPERZ = "Jalapeno Popperz"
CHEESEBURGER = "Cheeseburger"
SHEPHERDS_PIE = "Sherpherd's Pie"
CHEESE_AND_CRACKERS = "Cheese and Crackers"

class RECIPE_PROBABILITIES():
Ingredients = "Ingredients"
Cooked = "Cooked"
RECIPE_PROBABILITIES = {0: [], 1: [], 2:[], 3:[]}
ochan1 marked this conversation as resolved.
Show resolved Hide resolved
EASY_RECIPE = {RECIPIES.BREADSTICKS:[INGREDIENT.BREAD], \
RECIPIES.SALAD:[INGREDIENT.VEGETABLES], \
RECIPIES.COLD_CUTS:[INGREDIENT.MEAT]}
MEDIUM_RECIPE = {RECIPIES.TURKEY_SANDWICH: [INGREDIENT.BREAD, INGREDIENT.MEAT], \
RECIPIES.CAESAR_SALAD: [INGREDIENT.VEGETABLES, INGREDIENT.BREAD], \
RECIPIES.MEAT_AND_POTATOES: [INGREDIENT.MEAT, INGREDIENT.VEGETABLES], \
RECIPIES.CHEESE_AND_CRACKERS: [INGREDIENT.BREAD, INGREDIENT.CHEESE]}
HARD_RECIPE = {RECIPIES.HAMBURGER: {Ingredients:[INGREDIENT.BREAD, INGREDIENT.MEAT, \
INGREDIENT.VEGETABLES], Cooked:1}, \
RECIPIES.GRILLED_CHEESE: {Ingredients:[INGREDIENT.BREAD, \
INGREDIENT.CHEESE], Cooked:1}, \
RECIPIES.JALAPENO_POPPERZ: {Ingredients:[INGREDIENT.CHEESE, \
INGREDIENT.VEGETABLES], Cooked:1}, \
RECIPIES.CHEESEBURGER: {Ingredients:[INGREDIENT.BREAD, \
INGREDIENT.MEAT, INGREDIENT.CHEESE], Cooked:1}
}
VERY_HARD_RECIPE = {RECIPIES.SHEPHERDS_PIE: {Ingredients:[INGREDIENT.MEAT,\
INGREDIENT.VEGETABLES,\
INGREDIENT.CHEESE], Cooked:2}}

class TELEOP_RECIPE_MAP():
MAPPING = {0:[1, 0, 0, 0], 1:[0.1, 0.8, 0.1, 0], 2:[0.1, 0.1, 0.8, 0], 3:[0.1, 0.2, 0.3, 0.4]}
# 0: Easy, 1: Medium, 2: Hard, 3: Very Hard
ochan1 marked this conversation as resolved.
Show resolved Hide resolved