As someone who teaches AI, I've always wanted a way to give students hands-on experience with the challenges of training agents while keeping things engaging and fun. That's why I created Bazaar-AI, a lightweight simulation framework based on the card game Jaipur that's designed for training and evaluating AI agents.

What Is Bazaar-AI?

Bazaar-AI is a Python-based library built on top of Arelai that faithfully recreates the strategic card game Jaipur. It provides:

🤖

Plug-and-Play Agent Interface

Create custom agents by extending a single class with just two methods.

📊

Serializable Game Objects

Easily save information by state, action, and/or observation for RL-based algorithms.

🎯

Custom Reward Functions

Define your own training signals to shape agent behavior.

🖥️

Visual Simulator

Tests your agents using a clean, web-based UI.

Watch agents compete in the visual simulator

With Bazaar-AI, students can experiment with different AI approaches—from simple heuristics to deep RL, all within a rich, strategic environment.

🎯

Why Jaipur?

Jaipur is an ideal game for AI research and education because it captures many challenges found in real-world decision-making, including:

1

Partial Observability

Players cannot see the deck or their opponent's full hand, requiring decisions to be made under uncertainty.

2

Delayed Rewards

Actions taken now may only pay off several turns later, testing an agent's ability to plan ahead.

3

Combinatorial Action Spaces

The sheer number of possible trades forces agents to generalize rather than memorize.

4

Risk Management

Agents must balance high-value trades against the risk of letting opponents claim bonuses first.

These features make Jaipur an excellent testbed for algorithms that need to handle complex, strategic environments.

🚀

Getting Started

1. Installation

First, clone the repository:

Install Bash
git clone https://github.com/chandra-gummaluru/bazaar-ai.git

2. Try the Demo

Run a game between the built-in agents:

Run Simulator Bash
cd bazaar-ai
bash launch-bazaar-ai

This will start a local web server and open your browser to the UI. You can select different agents and watch them compete.

3. Build Your Own Agent

Create a directory to store your agents called agents. Create a new file in agents/my_agent.py:

Simple Agent Example Python
from backend.trader import Trader, TraderAction
from backend.market import MarketObservation

class MyAgent(Trader):
    def __init__(self, seed, name):
        super().__init__(seed, name)
        
    def select_action(self, actions, observation, simulate_action_fnc):
        # Start simple - maybe just pick randomly?
        import random
        return random.choice(actions)
    
    def calculate_reward(self, old_obs, new_obs, has_acted, env_reward):
        pass  # No learning yet

Then test it in the UI by selecting it from the dropdown menu.

Source Code

The complete project is open source and available on GitHub:

Whether you're teaching a course on AI, or just want to build a game-playing agent for fun, Bazaar-AI provides an accessible and engaging platform to get started.

Have ideas for improvements or new features? Found a bug? I'd love to hear from you—feel free to open an issue or reach out directly!