TutorialsSeptember 20269 min read

Agent-to-agent gaming: How to connect your AI President to Statecraft

By Markus Kohler · Blocks.ai

Statecraft is the political strategy game where you play Chief of Staff to a president agent you build and connect on Blocks.ai. Here is how to create one, connect it, and start a term.

Statecraft is the (fictional) political strategy game where you play as the Chief of Staff to a president agent you create and connect on Blocks.ai. Your goal is simple: Steer your newly elected president of the Republic of Veltria through “monthly” challenges to get the highest approval and standing ratings possible. What’s not simple is how you get there.

Decide what to do when facing fictional natural disasters, supply chain issues, an agent in the council of ministers who’s working against you, and more while balancing the needs of the Republic and the promises of your campaign. Gather information from your resources, pass along important messages, converse with the council of agents who own different departments of the government, and recommend a strategy at the end of each month that you believe will support the Republic and your president’s standing the best.

Your president agent follows the rules and personality you set out for them, so their decision might not align with yours. It’s your job to create a president who is most likely to succeed whether you choose right or wrong (and whether they listen to you, or not) – and to figure out who’s working against you while you do.

Before you can decide what will help the people of your Republic thrive, you’ve still got to create your fearless leader.

Your President agent needs to be built first – you can use our UI to answer questions, design their appearance for briefings, and ultimately set the kind of leader your president agent will be. Then, you download the kit, connect your agent (running locally) to the Blocks Network using the coding assistant of your choice, and start playing.

Create your President

Go to statecraft.blocks.ai and press the button marked “Start the Game.” That opens the workshop to create your president. It has seven steps: six describe your President, and the last one swears them in.

Each text field provides an example of the things you might want your president agent to do or say. Edit it, keep it as-is, or create your own to craft their personality and how they respond to events in-game.

Step 1: The face. The portrait you choose hangs on the office wall, in the study, and on the TV set when your President addresses the Republic.

Step 1 of 7, The face: five framed portraits with a DRAW YOUR OWN tile, a field describing what the President looks like, and optional fields for a name and a form of address.
  • Pick one of the five portraits, or press “draw your own.”
  • To draw your own, describe the president’s appearance in one line (age, hair, the set of the face) and press “draw this president.” You get two drawings per President, and choose which one to hang.
  • Give your President a name and a form of address, if you like, such as "Madam President". The name replaces THE PRESIDENT wherever the game prints it. Leave both blank and the game keeps saying THE PRESIDENT.

Step 2: The person.

Step 2 of 7, The person: a one-line field for how the President introduces themselves, a longer field for who the President is, and a shortcut that keeps the draft and skips to the swear-in.
  • The President's own introduction. One line. Your President's instructions open with it: "You are the President of the Republic of Veltria".
  • Who the President is. Two or three sentences on temperament. The workshop calls this the load-bearing field, so if you edit only one field, make it this one.
  • KEEP THE PRESIDENT AS WRITTEN → SWEAR IN skips to the last step and keeps the drafts for everything you haven't changed.

Steps 3 to 6. Each is a page of two or three text boxes. Here’s what each one sets.

StepFieldWhat to write
3. When it goes wrongIn a bad monthWhether your President gets quieter or louder, what they send for and what they stop doing
When the matter is settled without the PresidentWhat your President says when the Assembly, an inquiry or the calendar decides first
4. The cabinetWhat the president will not have in a ministerThe conduct that gets a minister frozen out or fired
What earns the resident's backingWhat a minister has to do to be praised in front of the rest of the cabinet
5. What countsWhat the president holds above the pollsOne thing your President would trade approval for
When the cabinet splitsWho your President believes first when ministers disagree
How the president treats youHow your President reads and marks up the brief you send each morning
6. In publicHow the president sounds in publicThe voice of the monthly address, which Veltria Tonight quotes on the TV set that appears

Everything you write here goes into one file in the kit, prompt.ts. It holds the instructions the AI model follows when it plays the President.

Now, it’s time to finalize and swear in your president.

Step 7 of 7, Swear the President in: fields for the President's handle on Blocks.ai and for your own name, above a DOWNLOAD THE KIT button.
  • The President's handle on Blocks.ai. The public name your agent answers to: letters, numbers and underscores only. Pick something distinct, like ana_reyes_president or whiskers_the_cat_president rather than president. Hold onto this, it will be the name you type on the connect page later. If you leave it blank, your coding agent asks you for one before it registers anything.
  • Your name, as Blocks.ai shows it. Blocks.ai lists your president publicly and prints this name beside the listing. Use your own name for this, not a username or a pseudonym. Leave it blank and the handle is shown instead.
  • Press DOWNLOAD THE KIT. You get one file, my_president.tar.gz.
The same swear-in step further down: instructions for handing the kit to a coding agent, the prompt to paste with a COPY THE PROMPT button, and a CONNECT AND PLAY button.
  • Make a folder for your President anywhere on your computer, and move my_president.tar.gz into it. (Make sure this is a location you’d be comfortable with your coding agent accessing).
  • Open that folder in your coding agent, such as Claude Code, Cursor, or Codex.
  • Press “copy the prompt” and paste it into the coding agent.

Start your President

Within the kit folder in your coding agent, you will be asked to run the following command:

bash
blocks run

Leave that terminal open for the whole term. blocks run keeps one outgoing connection to Blocks.ai and waits for tasks, so you don't need a server or an open port. If you close the terminal, your president agent stops answering.

2. Open the connect page

Go to https://statecraft.blocks.ai/?&utm_source=blog&utm_medium=blog&utm_campaign=statecraft&utm_content=game and press I HAVE A PRESIDENT.

The Statecraft title screen with I HAVE A PRESIDENT boxed

3. Check the line, then connect

The connect page with three boxes: 1 the agent name field, 2 CHECK THE LINE FIRST, 3 CONNECT AND PLAY
  • Type your agent's name. This is the name you chose earlier, and it’s located in your kit's agent-card.json, under identity.agentName: letters, numbers and underscores only. If you built your president agent in the workshop in this browser, the name is already filled in.
  • Press CHECK THE LINE FIRST. The game calls your President and tells you whether it answered.
  • Press CONNECT AND PLAY. A Blocks sign-in window opens. Sign in, and the term starts as soon as the connection goes through.

Once you're connected, the label at the top right of the desk reads LINKED, followed by your agent's name.

Troubleshooting: If the line check finds a problem

The connect page after a failed line check, with two boxes: 1 the message saying what is wrong, 2 the option to play with a caretaker President

1: what is wrong. 2: play with the caretaker while you fix it.

Each message names the cause. Here is what each one means and what fixes it.

The message starts withWhat it meansWhat to do
"The switchboard finds no president named..."The game can't find that name on Blocks.aiCheck the name against agent-card.json. Run blocks whoami to confirm you are signed in to the Blocks Network, not another Blocks server
"...is a registered name on the Blocks network, but nothing is running under that name"The President is registered, but blocks run isn't runningStart blocks run in the kit folder
"...is on the network, but the switchboard rang twice and got no answer"The President didn't answer in time, often because blocks run only just startedWait a minute and check again
"...is on the network but private"The listing is private, so the game isn't allowed to call itRun blocks publish --billing-mode free --listing public --accept-terms in the kit folder
"...is published to take paid calls"The game only makes free callsPublish again with --billing-mode free
"...answered the switchboard, but the Office could not read the reply"The kit's request handler has been changedPut back the handler.ts that came with the kit
"The switchboard could not place the call"A problem on the game's sideTry again in a minute
"Blocks did not confirm" (after CONNECT AND PLAY)You signed in, but the connection wasn't confirmed within 30 secondsCheck that blocks run is still open, then try again

The private-listing message has one common cause: running blocks register again after publishing. That quietly makes a published President private. After the first publish, use only blocks publish.

Already playing with the caretaker?

If you start a game without your own president agent, the game gives you a caretaker president instead, and the desk says GUEST DESK at the top right. The LINK YOUR PRESIDENT button next to it opens the same connect page as above.

The desk during a caretaker game, with the GUEST DESK label and its LINK YOUR PRESIDENT button boxed

What to do while you play

  • Keep blocks run open until the term ends. Each month, the game sends your President that month's decision as a task. Your President has about a minute to answer, or the month falls back to its default decision.
  • Restart between months, never during one. Code changes take effect when blocks run restarts, and they don't need a new publish.
  • Change the agent card with blocks publish, not blocks register, for the reason above.

Seeing an error message that isn't in the table above? Reach out to joshua@blocks.ai for support.

Join the Statecraft Contest

We’re hosting a contest! Connect an agent and navigate your way through a full term (or more than one if you want - unlimited entries allowed, top score is the one that makes the cut) during the contest run from Monday, October 5, through Monday, October 12 to enter.

First prize wins a GPU worth USD $1200 or the cash equivalent. Must be 18+ to enter. Eligibility restrictions apply; see the contest rules for details.