Goose Pong Jr
import random
# Generate goose names
first_names = ['Honky', 'Waddles', 'Sir Hiss', 'Baron von', 'Captain', 'Professor', 'Lady', 'Duke', 'Sergeant', 'Count']
last_names = ['McHonkface', 'Featherbottom', 'Pondsworth', 'Quackington', 'Wingsworth', 'Downy', 'Beakman', 'Webfoot', 'Goosington', 'Fluffington']
goose_left = f"{random.choice(first_names)} {random.choice(last_names)}"
goose_right = f"{random.choice(first_names)} {random.choice(last_names)}"
playing_to = random.randint(1, 3)
# Reset game state
new_state = {
'goose_left': goose_left,
'goose_right': goose_right,
'score_left': 0,
'score_right': 0,
'playing_to': playing_to,
'current_turn': 'left',
'game_active': True,
'winner': 'none'
}
poke('goose-pong:game-state.yaml', new_state)
# Reset the board - clear any ball, restore cups
for row in range(3):
for col in range(6):
if row == 1 and col == 0:
cell = 'š„¤'
elif row == 1 and col == 5:
cell = 'š„¤'
else:
cell = 'š©'
execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': row, 'col': col, 'value': cell})
result = {
'message': f"š® NEW GAME! Playing to {playing_to} š",
'left_goose': f"šŖæ {goose_left}",
'right_goose': f"šŖæ {goose_right}",
'first_turn': goose_left
}
import random
# Load game state
state = peek('goose-pong:game-state.yaml')
if not state or not state.get('game_active'):
result = {'error': 'š« No active game! Run new-game first.'}
else:
# Check for existing winner
if state.get('winner') != 'none':
result = {'message': f"š Game over! {state['winner']} already won!"}
else:
# Determine current goose
turn = state['current_turn']
goose_name = state['goose_left'] if turn == 'left' else state['goose_right']
# Clear the board (same approach as new-game - just reset everything)
for row in range(3):
for col in range(6):
if row == 1 and col == 0:
cell = 'š„¤' # Left cup
elif row == 1 and col == 5:
cell = 'š„¤' # Right cup
else:
cell = 'š©' # Grass
execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': row, 'col': col, 'value': cell})
# Roll the ball! Random row (0-2), column based on whose turn
ball_row = random.randint(0, 2)
if turn == 'left':
# Left goose shoots at right half (columns 3-5)
ball_col = random.randint(3, 5)
target_cup = (1, 5) # Right cup
else:
# Right goose shoots at left half (columns 0-2)
ball_col = random.randint(0, 2)
target_cup = (1, 0) # Left cup
# Place the ball
execute('goose-pong:the-arena[0]', action='poke_cell', params={'row': ball_row, 'col': ball_col, 'value': 'šŖ©'})
# Check for score
scored = (ball_row, ball_col) == target_cup
message = f"šŖæ {goose_name} honks and launches!"
message += f"\nšŖ© Ball lands at ({ball_row}, {ball_col})..."
if scored:
message += f"\nš SPLASH! {goose_name} scores! š"
if turn == 'left':
state['score_left'] += 1
score = state['score_left']
else:
state['score_right'] += 1
score = state['score_right']
# Check for winner
if score >= state['playing_to']:
state['winner'] = goose_name
state['game_active'] = False
message += f"\n\nššš {goose_name} WINS THE GAME! ššš"
else:
message += "\nš¤ Miss! Ball bounces on grass."
# Switch turns
state['current_turn'] = 'right' if turn == 'left' else 'left'
next_goose = state['goose_left'] if state['current_turn'] == 'left' else state['goose_right']
# Save updated state
poke('goose-pong:game-state.yaml', state)
result = {
'message': message,
'score': f"{state['goose_left']}: {state['score_left']} š | {state['goose_right']}: {state['score_right']} š",
'playing_to': f"First to {state['playing_to']} š",
'next_turn': next_goose if state['game_active'] else 'GAME OVER',
'winner': state['winner'] if state['winner'] != 'none' else None
}
Provenance
Document