This repository contains the game server and bot examples for the Bridge arena in CodeClash.
Bridge is a 4-player trick-taking card game played in teams:
- North/South (positions 0/2) vs East/West (positions 1/3)
Bridge/
├── game_server/ # Core game logic
│ ├── game.py # BridgeGame class - main game state manager
│ ├── deck.py # Card deck management and comparison
│ └── scoring.py # Bridge scoring rules
├── examples/
│ └── random_agent.py # Example bot implementation
└── README.md
Your bot must implement two functions in bridge_agent.py:
Make bidding decisions during the auction phase.
game_state contains:
position: Your position (0=North, 1=East, 2=South, 3=West)hand: List of cards in your hand (e.g.,["AS", "KH", "7D"])bids: List of previous bidslegal_bids: List of legal bids you can makedealer: Position of the dealervulnerability: Which teams are vulnerable
Returns: A bid string like "PASS", "1H", "2NT", "3S"
Play a card during the playing phase.
game_state contains:
position: Your position (0=North, 1=East, 2=South, 3=West)hand: List of cards currently in your handcurrent_trick: Cards played so far in current tricklegal_cards: List of legal cards you can playcontract: The current contract (level, suit, declarer)tricks_won: Tricks won by each team so far
Returns: A card string like "AS", "7H", "KD"
- Cards are represented as 2 characters:
<rank><suit> - Ranks: A, K, Q, J, T (10), 9, 8, 7, 6, 5, 4, 3, 2
- Suits: S (Spades), H (Hearts), D (Diamonds), C (Clubs)
- Examples:
"AS"= Ace of Spades,"7H"= 7 of Hearts,"TD"= 10 of Diamonds
- Pass:
"PASS" - Suit bids: Level (1-7) + Suit (C, D, H, S, NT)
- Examples:
"1H","2NT","4S","7NT"
- Examples:
Games are scored using standard Bridge scoring rules, then normalized to Victory Points (VP) on a 0-1 scale.
See examples/random_agent.py for a simple random bot implementation.
def get_bid(game_state):
legal_bids = game_state.get("legal_bids", ["PASS"])
# Your bidding logic here
return "PASS"
def play_card(game_state):
legal_cards = game_state.get("legal_cards", [])
# Your card playing logic here
return legal_cards[0]MIT License - See CodeClash repository for details.