song_match¶
song_match.config¶
-
song_match.config.ROOT_DIR= '/home/docs/checkouts/readthedocs.org/user_builds/cozmo-song-match/checkouts/latest/song_match'¶ Root directory of the package to help load
.wavfiles.
-
song_match.config.init_mixer() → None[source]¶ Initializes pygame’s mixer module by calling
init().See https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init.
IMPORTANT: Must be called before constructing any
Noteobjects.Returns: None
song_match.cube_mat¶
-
class
song_match.cube_mat.CubeMat[source]¶ Bases:
objectClass to convert cube IDs to mat positions and vise versa.
Each cube has an ID of 1, 2, or 3 associated with it.
Consider the following cubes with IDs from left to right:
_______ _______ _______ | | | | | | | 2 | | 1 | | 3 | |_______| |_______| |_______|
The mat position of each cube from the player’s perspective is as follows:
_______ _______ _______ | | | | | | | 1 | | 2 | | 3 | |_______| |_______| |_______|
Where the the left-most position is assigned 1, middle position 2, and right-most position 3.
This class is responsible for converting from one to the other.
In this example, the conversion from cube id to mat position is:
- 2 -> 1
- 1 -> 2
- 3 -> 3
-
classmethod
cube_id_to_position(cube_id: int) → int[source]¶ Maps the
cube_idto a mat position.Parameters: cube_id – cube_idReturns: The ordered cube ID.
-
classmethod
get_light_cubes(song_robot) → List[cozmo.objects.LightCube][source]¶ Convenience method to get a list of light cubes.
- Note:
- This is duplicated in song_match.cube.util due to import issues.
Parameters: song_robot – SongRobotReturns: A list of three LightCubeinstances.
-
classmethod
get_positions() → List[int][source]¶ Get a list of mat positions ordered by cube ID.
Returns: A list of mat positions ordered by cube ID.
song_match.game_constants¶
-
song_match.game_constants.MAX_STRIKES= 3¶ The maximum number of notes a player can get wrong
-
song_match.game_constants.STARTING_POSITION= 3¶ The number of notes you start with in the sequence
-
song_match.game_constants.TIME_IN_BETWEEN_PLAYERS_AND_COZMO= 1¶ Time in seconds to wait in between the players and Cozmo
song_match.option_prompter¶
-
class
song_match.option_prompter.OptionPrompter(song_robot: song_match.song_robot.SongRobot)[source]¶ Bases:
objectA class to help the user select an option from three different choices.
-
get_option(prompt: str, options: List[str]) → int[source]¶ Prompts the user to select from three different options by tapping a cube.
- Cozmo will prompt the user with
prompt. - Cozmo will point to each cube saying the corresponding
option. - The light chaser effect will start signaling the game is awaiting user input.
- Upon successful tap
collect-point.wavis played and the cube flashes green.
Parameters: - prompt – The prompt for Cozmo to say.
- options – A list of options associated with each cube.
Returns: cube_idof the tapped cube.- Cozmo will prompt the user with
-
song_match.player¶
song_match.song_match¶
Module containing SongMatch.
-
class
song_match.song_match.SongMatch(song: song_match.song.song.Song = None, num_players: int = None)[source]¶ Bases:
objectMain game class.
-
play(robot: cozmo.robot.Robot) → None[source]¶ Play the Song Match game.
Pass this function into
cozmo.run_program().Parameters: robot ( Robot) – Cozmo Robot instance.Returns: None
-
song_match.song_robot¶
Module containing SongRobot.
-
class
song_match.song_robot.SongRobot(robot: cozmo.robot.Robot, song: song_match.song.song.Song)[source]¶ Bases:
objectWrapper class for Cozmo
Robotinstance.-
did_win¶ Property for accessing whether Cozmo won the game.
Returns: Whether Cozmo won the game.
-
play_anim(animation_name: str, **kwargs) → cozmo.anim.Animation[source]¶ Wrapper method for
play_anim().Parameters: - animation_name – The name of the animation.
- kwargs – See
play_anim().
Returns:
-
play_anim_trigger(animation_trigger, **kwargs) → cozmo.anim.AnimationTrigger[source]¶ Wrapper method for
play_anim_trigger().Parameters: - animation_trigger – The animation trigger.
- kwargs – See
play_anim_trigger().
Returns:
-
play_note(note: song_match.song.note.Note) → None[source]¶ Make Cozmo play a note.
Parameters: note – The Noteto play.Returns: None
-
play_note_with_error(note: song_match.song.note.Note, sequence_length: int = 1) → Tuple[bool, song_match.song.note.Note][source]¶ Make Cozmo play a
Notewith a chance for error.Parameters: - note – The
Noteto play. - sequence_length – The length of the sequence to play.
Returns: Whether Cozmo played the correct note, and the
Notehe played.Return type: - note – The
-
play_notes(notes: List[song_match.song.note.Note], with_error=False) → Tuple[bool, Union[NoneType, song_match.song.note.Note]][source]¶ Make Cozmo play a series of notes.
Parameters: - notes – The series of notes to play.
- with_error – Whether to play the series of notes with a chance for error.
Returns: Whether cozmo played the correct notes and the incorrect note he played if any.
Return type:
-
say_text(text: str) → cozmo.robot.SayText[source]¶ Wrapper method for
say_text().Returns: SayText
-
tap_cube(cube_id) → cozmo.anim.Animation[source]¶ Make Cozmo tap a cube.
Parameters: cube_id – cube_idReturns: Animation
-
turn_back_to_center(in_parallel=False) → None[source]¶ Turn Cozmo back to the center.
Parameters: in_parallel – Whether to do the action in parallel or wait until it’s completed. Returns: None
-
-
song_match.song_robot.random() → x in the interval [0, 1).¶