Build a Python Bot and rank on the Leaderboard in 7 minutes

Saakshi Baheti
4 min read

What was your first thought about the Smart Bots?

Some might have been scared to start, as they immediately thought they could not rank in the Leaderboard.  If that's the case, you are not alone; many participants are going through the same phase.

Some people may be confused on how to start or from where to start?

Some participants may still be waiting for the deadline to approach, but building the best bot in a two-days timeline is next to impossible.

So get started now.

Here we decoded 10 steps to help you build and rank your bot in the Leaderboard.

Step 1: Get the Starter Code

Clone the SmartBots starter-code repository

Here's how to do that:

Clone the github starter code
Clone the starter code

Type this in your terminal.

`git clone`

This is how it will look in your terminal:

Your terminal will show how it is running the starter code
Your terminal will run the starter code

Step 2: Setup Python Environment

  • Go to python directory inside the repository
  • Create an environment using `python -m venv env` in your terminal
  • Activate the virtual environment using `source env/bin/activate`
  • Install dependencies using `pip install -r requirements.txt`
Building the python environment in terminal
Building the python environment

Step 3: Start the Python Server

Start the server by typing this to the terminal: 'python src/'

Start Python Server
Get Started with Python Server

Step 4: Interact with the Sandbox

  • Login to the dashboard and click “Sandbox”
  • Click “New Game” in the sandbox
Sandbox Layout
Explore the Sandbox
  • Check your server log. You will see HTTP request and response.

Your sample bot is now playing the game.

Note: Your bid is 16 in the default code. Next we will update code to bid 17.
Your bot is playing games in Sandbox
The default bid is 16

Step 5: Make Changes to your Bot Code

  • Open “” file in the editor of your choice. You will see minimum bid is 16.
Make some little changes in the beginning
Make some little changes in the beginning 
  • Change 16 to 17 as the minimum bid and save your file.
Change the bid
It's time to tweak your bot
  • Stop the python server and start it again.
  • Click “New Game” to see that your bid is now 17. Hurray.
Bot will play with updated bid
Your bid is now updated
  • Similarly, when you come back the second time, make some other changes.
  • You can think of applying another algorithm to your bot or just add some basic game rules.

Step 6: Prepare Docker Image for Submission

Now it’s time to create a docker image. Make sure docker is installed on your system, and start docker.

  • Create a docker image

  `docker build --platform x86_64 -t my_docker .`

Build a Docker Image
Build a Docker Image
  • Save your docker image

    docker save my_docker | gzip > my_docker.tar.gz

Save your docker image
Save your docker image

Step 7: Submit your Docker Image

  • Go to “Docker Submission” panel.
This is how "Docker Submission" panel looks like
  • Upload your newly created “my_docker.tar.gz” file
Upload your Docker on "Docker Submission" channel
Upload your Docker on "Docker Submission" channel
Drag your docker image and upload it on "docker submission" tab
Your docker upload might take few minutes. Sit Relaxed!
  • Once the upload is complete, games will run.
Docker Image status: Running(bot playing games)
Your bot is playing against Bhoos' bots. 

Yay! the bot is playing games.

Step 8: See yourself in the Leaderboard

You are on the leaderboard
Rock the Leaderboard

Step 9: Explore your GamePlay

  • Go to “Game Analytics” tab.
  • Understand how your bot is playing.
Game Analytics is here to analyze your bot's performance
Analyze your Gameplay

Step 10: Improve. Code. Go to Step 5.

You shall move up the leaderboard now. Good luck.

If videos resonates more with you, here's the beginners' playlist.

Happy Coding!