Cody

# Problem 327. TRON challenge

Create a solver for the classic arcade TRON game

Description

Your function should return the next move of your bike ('light cycle' if you prefer) for any given state of the board.

The board is described by a 50x50 matrix, with values:

```   0: empty space
1: your bike (bright blue dot on the figure above)
2: your opponents bike (bright red dot)
-1: walls created by your bike (blue lines)
-2: walls created by your opponents bike (red lines)
-3: external walls (white)```

Your bike's next move is described by a single character:

```   'N': moves up (next lower row)
'S': moves down (next higher row)
'W': moves west (next lower column)
'E': moves east (next higher column)```

For each challenge, both bikes will start at a random position at the border of the board. Your solver will be called iteratively against a default solver (implementing a simple collision avoidance procedure). The last person standing after the other crashes against a wall is the winner. Your solver needs to be able to win 90 out of 100 challenges.

notes

For the purpose of collision detection both bikes are considered to move simultaneously for each iteration. A collision of the two bikes is considered a tie (not a win).

Whether you pass or not the tester will let you know how many wins/ties/looses your code accomplished against the default solver. Since I was not able to include this 'performance' measure in your solver score please let us know how well your solver does in the comments (I might create a second TRON challenge pairing you against the best solvers here)

If you wish to display the challenges graphically copy and paste the evaluation code on your computer and change the first line to 'doDraw=true;'

### Solution Stats

37.63% Correct | 62.37% Incorrect
Last solution submitted on Nov 27, 2015

Tags

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today