The Online Code Editor

Introduction

The AI Gaming Online Code Editor lets you create bots and compete with them in seconds.

If this is your first time in the editor, you can simply click the Run button at the top of the page and the sample code that's been pre-loaded into your editor window will play a game of Battleships using your default botname.

How simple was that?

You can immediately start tweaking the code in the editor window and start improving your bot.

The Basics

There are some basics to know about the code and the options you can choose before you hit the Run button

Your Bot Name

Any bot you write needs to state its bot name. You'll be able to see the bot name in the example code loaded when you first come to the editor, or, if you load any of the bot templates

botName='winner-bot'

Your bot name must be unique. You are assigned a default bot name as soon as you register your account and this default bot name is automatically inserted into your code if you load any of the bot templates for any of the games. You can also create your own bot names by going to the Bot Management screen under My Account and choosing the Create New Bot button at the top right of your list of bots.

You can create a bot that has a more memorable or descriptive name like 'MegaBot' or 'BattlingBehemoth'!

Selecting An Opponent

To exercise your bot, you have to play against someone (tip: that someone can be yourself!).

You choose your opponent from the dropdown at the top of the Editor page named, Select Opponent.

Playing a Housebot

The easiest way to get started is to play against one of our Housebots. Their names give you a clue as to how they play but if you choose one, you'll soon get a feel for how good they are.

Select one from the dropdown list and try running your bot against them

Playing Another Specific Bot

If you know another person's bot name, or if you want to compete against a friend, you can specify their bot name. You do this by typing their bot name into the Select Opponent dropdown.

If you do this, your bot will wait and it will only play the bot name you have specified. Remember that if the specified bot does not play a compatible game, your bot will sit and wait forever

Playing Anyone

You can also play a combination of Housebots and other people by selecting the Anyone option from the Select Opponent dropdown. This option means that your bot will play against any compatible bot that is available. A great option when you get your bot's strategy implemented.

Playing Yourself

Playing yourself lets you get used to running games and, you can play the same bot against itself, or, you can write different versions of a bot and have them play against each other. Just state the name of your own bot in the Select Opponent field and then, in another browser tab or window, load up your bot in the Editor window and enter your first bots name in the Select Opponent field. Click Run oon both the windows and your bots will find each other and start competing.

Choosing a Game Style

Another key component is choosing the Game Style or the variant of the game you want to play. Game Styles exist for all of the different games that you can play on the AI Gaming site: Battleships, Texas Hold 'Em Poker, Noughts And Crosses and more.

For each Game Type, there may be several Game Styles. For example, in the Battleships Game Type, there might be a Game Style that only has 1 ship instead of the usual 5 ships. There might also be a Game Style of Battleships that includes land as well as sea when it creates the playing board.

Different Game Styles add different challenges for your bot, but, it's important to remember that if you try to play a specific bot or your friends bot, you have to play the same Game Style too. If your bot is looking for Game Style 101 and your friends bot is looking for Game Style 102, you won't find each other

Adding Debug Information

No coding would be complete without the ability to debug along the way. To add debuf information to your bot, just use the Python print() function. Anything you print will be shown in this Info Display column while your bot is running, and, when your game has finished, you'll be able to see the output from the last game run by clicking on the terminal icon in the right hand column of the Editor page.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License