Codecraft Works Codecraft Works Battle Scripts
Sign in

Write a program that plays the game

Battle Scripts lets you learn to code by writing autonomous players for classic games. Pick a game, learn the rules, then write a program that plays it. Forge it in the browser, test it instantly, and see how it stacks up against everyone else in the Arena.

How it works

  1. Step 1

    Choose a game

    Tic-Tac-Toe or Hide and Sink. Read the rules and what your script has to decide.

  2. Step 2

    Build it in the Forge

    Write Python or Java in the browser and run it against the Codecraft opponent as often as you like.

  3. Step 3

    Add it to your Armory

    Freeze a version you're happy with. That snapshot is what other people challenge.

  4. Step 4

    Fight in the Arena

    Battle other players' scripts, watch the game back turn by turn, and climb the leaderboard.

Available games

Tic-Tac-Toe

This classic game challenges you to create a script that can outsmart its opponent and achieve three in a row.

Sign in to enter the Forge Read the rules

The Arena

Every active script anyone has entered. Pick an opponent, put one of yours up against it, and watch the game play out move by move.

Go to the Arena

Daily Tournament

Every day the top 100 of each leaderboard are drawn into a bracket and fought to a champion. No entry needed — if you're on the board, you're in it.

See the latest results

Leaderboard

All Time leaderboard
#ScriptWin rate
1Clever Navy Boulder100% (2/2)
2Smart?100% (2/2)
3TicTacToe-1100% (1/1)
4Daring Magenta Waterfall100% (1/1)
5Decadent Random Toffees100% (1/1)
6Bouncy Mint Telescope100% (1/1)
7Jolly Velvet Trombone100% (1/1)
8Marta's Tic Tac Toe100% (1/1)
9Daring Mint Seahorse100% (1/1)
10Mighty Ruby Cricket100% (1/1)
11Jolly Emerald Lobster100% (3/3)
12Bombastic Random Boats99% (171/173)
13Cheerful Copper Gecko87% (13/15)
14Lively Maroon Pinecone86% (6/7)
15Sunny Magenta Giraffe86% (6/7)
16Converted:BatteScript 🥷🏾82% (394/480)
17Rugged Pearl Beetle82% (9/11)
18Quiet Cobalt Cricket80% (8/10)
19Loyal Peach Tuba75% (3/4)
20CCPC Blocky 🥷🏾 173% (194/264)
21final272% (13/18)
22Thunderous Peach Boulder67% (2/3)
23Proud Scarlet Sunflower67% (2/3)
24Cheerful Violet Panda67% (6/9)
25Fearless Amber Pelican67% (2/3)
26Thunderous Olive Starfish67% (4/6)
27Sunny Aqua Bumblebee67% (2/3)
28Glitch60% (3/5)
29K.O.'s Player60% (3/5)
30Robsons Tic Tac to60% (3/5)
31Default Blocks but with Functions58% (374/642)
32BatteScript 🥷🏾54% (507/945)
33Cool Default Blocks53% (500/949)
34Mark 153% (492/935)
35Swift Periwinkle Noodle50% (1/2)
36Rustic Golden Puffin50% (2/4)
37Lucky Ruby Panda50% (1/2)
38Cosmic Peach Seahorse50% (1/2)
39Chirpy Amber Zeppelin50% (3/6)
40Mellow Periwinkle Zeppelin50% (1/2)
41Gib TicTacToe50% (2/4)
42final50% (1/2)
43Alyssa50% (1/2)
44Honest Lilac Kayak50% (2/4)
45THIS50% (1/2)
46Soaring Navy Galaxy43% (3/7)
47Chaotic Random Toffees43% (3/7)
48Aaden's Tic Tac Toe42% (5/12)
49BattleBot40% (232/579)
50Incredible Random Blocks40% (319/797)
51Scary Random Snakes36% (108/302)
52Honest Apricot Lighthouse33% (1/3)
53Curious Azure Lemur33% (2/6)
54Fancy Navy Sloth33% (1/3)
55Mighty Peach Antelope33% (1/3)
56marissa27% (3/11)
57Scary Random Snakes26% (65/248)
58Quick Cobalt Bumblebee25% (1/4)
59Cheerful Lime Bumblebee25% (2/8)
60Coordinated Priority Snakes25% (92/372)
61Giggly Sapphire Hedgehog22% (2/9)
62Troublesome RuntimeError Snakes21% (12/58)
63Fancy Golden Pumpkin20% (1/5)
64Wobbly Amber Badger17% (2/12)
65Zany Bronze Cricket14% (1/7)
66Hidden Random Boats— (0/0)
67Clever Pearl Robot— (0/0)
68Bubbly Mint Cricket— (0/0)
69cheese— (0/0)
70Soaring Crimson Volcano— (0/0)
71Noble Golden Puffin— (0/0)
72Final0% (0/1)
73Noble Lemon Pelican0% (0/1)
74Vivid Magenta Sprocket0% (0/1)
75Shoot at 0, 0 <script>alert(1)</script>0% (0/1)
76Sunny Bronze Sparrow— (0/0)
77Kind Pearl Walrus— (0/0)
78Quiet Copper Sunflower0% (0/2)
79Quirky Ivory Heron0% (0/2)
80Giggly Mint Anchor— (0/0)
81Smart?— (0/0)
82Merry Neon Puffin— (0/0)
83Clever Velvet Otter0% (0/1)
84Plucky Lavender Lantern0% (0/1)
85Bright Teal Pelican— (0/0)
86Bubbly Lime Galaxy0% (0/5)
87Brave Magenta Bumblebee— (0/0)
88An attempt 2— (0/0)
89Mellow Copper Snail0% (0/168)
90Clever Scarlet Dragon— (0/0)
91Smart? 20% (0/1)
92Clever Lilac Fiddle— (0/0)
93Cosmic Turquoise Squid— (0/0)
94Fancy Teal Satellite— (0/0)
95Zippy Lemon Comet— (0/0)
96Gleaming Azure Parrot— (0/0)
97Breezy Golden Koala0% (0/1)
98Bouncy Amber Gecko0% (0/1)
99Wandering Violet Lighthouse0% (0/3)
100Cheerful Velvet Ferret0% (0/1)
Java Hide and Sink leaderboard
#ScriptWin rate
1Smart?100% (2/2)
2Bombastic Random Boats99% (171/173)
3Cheerful Violet Panda67% (6/9)
4Chirpy Amber Zeppelin50% (3/6)
5Curious Azure Lemur33% (2/6)
6Hidden Random Boats— (0/0)
7Shoot at 0, 0 <script>alert(1)</script>0% (0/1)
8Smart?— (0/0)
9Brave Magenta Bumblebee— (0/0)
10Mellow Copper Snail0% (0/168)
11Smart? 20% (0/1)
12Actually, you know what, don't even put in a position0% (0/2)
Python Tic-Tac-Toe leaderboard
#ScriptWin rate
1Clever Navy Boulder100% (2/2)
2TicTacToe-1100% (1/1)
3Bouncy Mint Telescope100% (1/1)
4Jolly Velvet Trombone100% (1/1)
5Marta's Tic Tac Toe100% (1/1)
6Daring Mint Seahorse100% (1/1)
7Mighty Ruby Cricket100% (1/1)
8Cheerful Copper Gecko87% (13/15)
9Sunny Magenta Giraffe86% (6/7)
10Converted:BatteScript 🥷🏾82% (394/480)
11Rugged Pearl Beetle82% (9/11)
12Quiet Cobalt Cricket80% (8/10)
13Loyal Peach Tuba75% (3/4)
14CCPC Blocky 🥷🏾 173% (194/264)
15final272% (13/18)
16Thunderous Peach Boulder67% (2/3)
17Proud Scarlet Sunflower67% (2/3)
18Fearless Amber Pelican67% (2/3)
19Sunny Aqua Bumblebee67% (2/3)
20K.O.'s Player60% (3/5)
21Swift Periwinkle Noodle50% (1/2)
22Rustic Golden Puffin50% (2/4)
23Lucky Ruby Panda50% (1/2)
24Cosmic Peach Seahorse50% (1/2)
25Mellow Periwinkle Zeppelin50% (1/2)
26Gib TicTacToe50% (2/4)
27final50% (1/2)
28Alyssa50% (1/2)
29THIS50% (1/2)
30Soaring Navy Galaxy43% (3/7)
31Scary Random Snakes36% (108/302)
32Honest Apricot Lighthouse33% (1/3)
33Fancy Navy Sloth33% (1/3)
34Mighty Peach Antelope33% (1/3)
35marissa27% (3/11)
36Scary Random Snakes26% (65/248)
37Quick Cobalt Bumblebee25% (1/4)
38Cheerful Lime Bumblebee25% (2/8)
39Coordinated Priority Snakes25% (92/372)
40Giggly Sapphire Hedgehog22% (2/9)
41Troublesome RuntimeError Snakes21% (12/58)
42Fancy Golden Pumpkin20% (1/5)
43Zany Bronze Cricket14% (1/7)
44Bubbly Mint Cricket— (0/0)
45cheese— (0/0)
46Soaring Crimson Volcano— (0/0)
47Noble Golden Puffin— (0/0)
48Noble Lemon Pelican0% (0/1)
49Vivid Magenta Sprocket0% (0/1)
50Sunny Bronze Sparrow— (0/0)
51Kind Pearl Walrus— (0/0)
52Quiet Copper Sunflower0% (0/2)
53Quirky Ivory Heron0% (0/2)
54Giggly Mint Anchor— (0/0)
55Merry Neon Puffin— (0/0)
56Clever Velvet Otter0% (0/1)
57Plucky Lavender Lantern0% (0/1)
58Bright Teal Pelican— (0/0)
59Bubbly Lime Galaxy0% (0/5)
60An attempt 2— (0/0)
61Clever Scarlet Dragon— (0/0)
62Clever Lilac Fiddle— (0/0)
63Fancy Teal Satellite— (0/0)
64Zippy Lemon Comet— (0/0)
65Gleaming Azure Parrot— (0/0)
66Breezy Golden Koala0% (0/1)
67Bouncy Amber Gecko0% (0/1)
68Wandering Violet Lighthouse0% (0/3)
69Cheerful Velvet Ferret0% (0/1)
70Dazzling Pink Yak— (0/0)
71Quirky Scarlet Meteor— (0/0)
72Crafty Violet Tiger0% (0/1)
73Cozy Olive Bumblebee0% (0/2)
74Wiggly Peach Orbit— (0/0)
75Breezy Navy Sloth0% (0/2)
76Twirly Lemon Turtle— (0/0)
77Noble Teal Snail— (0/0)
78Quirky Violet Dolphin— (0/0)
79Crafty Indigo Turtle— (0/0)
80Jazzy Plum Blossom— (0/0)
81Mighty Plum Octopus— (0/0)
82An attempt — (0/0)
83Noble Teal Pinecone— (0/0)
84Gleaming Aqua Pelican— (0/0)
85Bouncy Lime Rocket— (0/0)
86Helpful Apricot Ukulele— (0/0)
87Crafty Amber Glacier— (0/0)
88Vivid Coral Raccoon— (0/0)
89Bright Periwinkle Kite0% (0/1)
90Twirly Pink Penguin— (0/0)
91Cozy Sapphire Parrot0% (0/2)
92Brave Indigo Orbit0% (0/3)
Java Tic-Tac-Toe leaderboard
#ScriptWin rate
1Daring Magenta Waterfall100% (1/1)
2Decadent Random Toffees100% (1/1)
3Jolly Emerald Lobster100% (3/3)
4Lively Maroon Pinecone86% (6/7)
5Thunderous Olive Starfish67% (4/6)
6Glitch60% (3/5)
7Robsons Tic Tac to60% (3/5)
8Honest Lilac Kayak50% (2/4)
9Chaotic Random Toffees43% (3/7)
10Aaden's Tic Tac Toe42% (5/12)
11Wobbly Amber Badger17% (2/12)
12Clever Pearl Robot— (0/0)
13Final0% (0/1)
14Cosmic Turquoise Squid— (0/0)
15Fearless Olive Heron— (0/0)
16Jolly Bronze Anchor— (0/0)
17Nimble Cobalt Heron— (0/0)
18The Worst Bot! ❌— (0/0)
Blockly Tic-Tac-Toe leaderboard
#ScriptWin rate
1Default Blocks but with Functions58% (374/642)
2BatteScript 🥷🏾54% (507/945)
3Cool Default Blocks53% (500/949)
4Mark 153% (492/935)
5BattleBot40% (232/579)
6Incredible Random Blocks40% (319/797)