A magazine where the digital world meets the real world.
On the web
- Browse by date
- Browse by topic
- Enter the maze
- Get our RSS feed
- Follow us on Twitter
- Resources for teachers
What is cs4fn?
- About us
- Contact us
- Privacy and cookies
- Copyright and contributions
- Links to other fun sites
- Complete our questionnaire and get a free magic download
Noughts and Crosses
Want to write your first Artificial Intelligence (AI) program? If so here is the place to start. Programs are just instructions about actions to follow. They must also give the order the actions must be followed and be written in some precise language so there is no confusion about what is intended.
In the applet below we have provided a language for writing programs called OXO. The instructions of OXO are noughts and crosses moves like "Go in a corner". Programs in this language are just lists of instructions. The way this language decides which instruction to follow is to work down the list until it finds one that can be legally followed. Your job is to choose the best instructions to use and put them in an order that gives an AI that can't be beaten. We've written one AI program ourselves that plays well though only if it plays first.
You can use the applet below to:
- write your own program and play against ours: choose "AI vs AI" (your AI goes second).
- play against your friends: choose "Human vs Human".
- test your skill playing against our AI: choose "AI vs Human".
- write your own program and play against it: choose "My AI vs Human" (your AI goes first).
To write a program, just click on the action you want to add to the program in turn, then click on "Add". Remember the order you add the instructions is important! It is the order they will be attempted in.
If an AI program you've written plays well, then at the end of the game check the box at the bottom and it will be saved for the session.
Please note that the noughts and crosses applet may not work in all browsers due to browser bugs. If you have problems it may help to update your browser (and Java plug-in) to the latest version. This is important to do any way to get the latest security updates.