# How to get ants to solve a chess problem

##### January 30, 2014 by Graham Kendall, The Conversation

Take a set of chess pieces and throw them all away except for one knight. Place the knight on any one of the 64 squares of a chess board.

Can you make 63 legal moves so that you visit every square on the chess board exactly once? As a reminder, a knight can move two squares in a straight line, followed by a ninety degree turn and a move of one further square. It might seem like a hard task, but this set of moves, called the knight's tour, can be achieved in too many ways to count.

If you are able to make the 63 moves and end up on a square from which you can move back to the original square with the 64th legal move, then this is known as a closed tour. Other tours are called open tours.

Mathematicians have pondered how many closed tours exist, and they have come up with an astonishing number: more than 26 trillion. There are so many more open tours that we do not know the exact number.

Both Philip Hingston and I were so captivated by the knight's tour problem that we wanted to find a different way to solve it. We found that motivation in nature – specifically in .

Ants use a certain pattern, or algorithm, to forage for food. This algorithm can be used to tackle many types of problems including the Travelling Salesman Problem and Vehicle Routing Problems. Philip and Graham wondered if they could use the ant colony optimisation algorithm to solve the knight's tour problem.

Here's how that algorithm works: a computer program is used to simulate a population of ants. These ants are assigned the task to find a solution to a problem. As each ant goes about their task they lay a pheromone trail – a smelly substance that ants use to communicate with each other. In the simulated algorithm, the most successful ants (the ones that solve the problem better), lay more pheromone than those that perform poorly.

We repeat this procedure many times (perhaps millions of times). Through repetitions, the pheromone trails on good solutions increase and they decrease on the poorer solutions due to evaporation, which is also programmed in the simulation algorithm.

In the simulation to solve the knight's tour problem, the ants could only make legal knight moves and were restricted to stay within the confines of the chess board. If an ant successfully completes a tour then we reinforce that tour by depositing more pheromone on that tour, when compared to a tour that was not a full tour.

Ants which attempt to find later tours are more likely to follow higher levels of pheromone. This means that they are more likely to make the same moves as previously successful ants.

There is a balance to be struck. If the ants follow the successful ants too rigidly, then the algorithm will quickly converge to a single tour. If we encourage the ants too much, not to follow the of previous ants, then than they will just act randomly. So it is a case of tuning the algorithm's parameters to try and find a good balance.

Using this algorithm, we were able to find almost half a million tours. This was a significant improvement over previous work, which was based on a genetic algorithm. These algorithms emulate Charles Darwin's principle of natural evolution – survival of the fittest. Fitter members (those that perform well on the problem at hand) of a simulated population survive and weaker members die off.

It is not easy to say why the ant algorithm performed so well, when compared to the genetic . Perhaps it was down to tuning the algorithmic parameters, or perhaps ants really do like to play chess!

The knight's tour problem was being worked on as far back as 840 AD. Little did those problem-solvers know that ants, albeit simulated ones, would be tackling the same puzzle more than 1,000 years in the future.

Explore further: Field study shows group decision making not always the best

## Related Stories

#### Field study shows group decision making not always the best

August 1, 2013

(Phys.org) —A combined team of researchers from Arizona State University and Uppsala University in Sweden has found that collective decision making by ants doesn't always result in selecting the best option for adopting ...

#### Robot ants successfully mimic real colony behavior

March 28, 2013

Scientists have successfully replicated the behaviour of a colony of ants on the move with the use of miniature robots, as reported in the journal PLOS Computational Biology.

#### Swimming ants don shades to save their eyesight

December 17, 2013

Australia's unusual swimming ants take their own 'sunglasses' when they go to the beach – to shield their sensitive eyes from bright sunlight.

#### A search engine for social networks based on the behavior of ants

June 4, 2012

Research at Carlos III University in Madrid is developing an algorithm, based on ants' behavior when they are searching for food, which accelerates the search for relationships among elements that are present in social networks.

#### Houston, we have ants: Mimicking how ants adjust to microgravity in space could lead to better robots, scientist says

January 20, 2014

Professor Deborah Gordon recently sent hundreds of ants to the orbiting International Space Station. By studying how the ants adjust their behavior to cope with near-zero gravity conditions, scientists could improve the algorithms ...

#### Next generation of algorithms inspired by problem-solving ants

December 10, 2010

(PhysOrg.com) -- An ant colony is the last place you'd expect to find a maths whiz, but University of Sydney researchers have shown that the humble ant is capable of solving difficult mathematical problems.

## Recommended for you

#### System lets users design and fabricate drones with a wide range of shapes and structures

December 6, 2016

This fall's new Federal Aviation Administration regulations have made drone flight easier than ever for both companies and consumers. But what if the drones out on the market aren't exactly what you want?

#### Humans play computer game using only direct brain stimulation

December 6, 2016

In the Matrix film series, Keanu Reeves plugs his brain directly into a virtual world that sentient machines have designed to enslave mankind.

#### Cars without drivers scoot around Nissan plant, towing cars

December 5, 2016

Nissan Motor Co. is testing self-driving cars at one of its plants in Japan that can tow vehicles on a trailer to the wharf for loading on transport ships.

#### Apple reveals autonomous vehicle ambitions

December 3, 2016

Apple has revealed it is investing heavily in autonomous vehicles in a letter asking the government to make it easier to develop self-driving cars.

#### Thomas Edison's lab door key, lightbulbs up for auction

December 2, 2016

Thomas Edison's door key to the 19th century lab in New Jersey where he invented the phonograph goes up for auction this weekend, along with lightbulbs he perfected.

#### UChicago startup turns renewable energy into natural gas

December 1, 2016

One of the biggest challenges to wider adoption of wind and solar power is how to store the excess energy they often produce.