Notice
This challenge has ended and will not be re-judged, but feel free to post answers and test your program against the others with the Control Program!
The aim of this challenge is to make an AI to win a fight against another AI by strategically drawing a wall on a 25x25 grid to block the opponent.
Input
25 lines separated by and ending with ;
as a command-line argument. This will include:
- Empty spaces
.
- Walls
#
- Players
1
and2
(The opponent is always2
)
Example
###############..........;..............#..........;..............#..........;..............#..........;..............#..........;...........1###..........;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;...................###...;...................#.##..;2..................#..#..;#..................##.#..;#...................#.###;....................#####;
which represents the following map:
###############..........
..............#..........
..............#..........
..............#..........
..............#..........
...........1###..........
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
...................###...
...................#.##..
2..................#..#..
#..................##.#..
#...................#.###
....................#####
Output
A string written to the console starting with the character representing the direction the AI wishes to turn. This is case sensitive!
- North
N
- East
E
- South
S
- West
W
- Give up (Anything else)
Example
W
Game Rules
- As the AIs move, they will leave a solid trail of walls behind them.
- The players start in the top-left and bottom-right corners
- The game lasts until any AI hits a wall or the AIs crash into each other.
- An AI wins if their opponent crashes first
- There is no winner or loser if the AIs both lose at the same time.
- If an AI goes off one edge of the grid, they continue in the same direction from the other side.
Rankings
1st Place - FloodBot (Java, 12 wins)
2nd Place - FluidBot (Python, 9 wins)
3rd Place - FillUpBot (C++, 8 wins)
4th Place - AwayBot (Ruby, 5 wins)
5th Place - ArcBot (Python, 4 wins)
6th Place - BlindSnake (Batch, 2 wins)
6th Place - RandomBot (C#, 2 wins)
Control Program (Tested for Python 3.3.3)
The program is run with arguments of the two commands and a single argument (""
if not required) for the AIs eg. Control.py "ruby" "AwayBot.rb" "FillUpBot.exe" ""
. It can be downloaded here.
import sys, subprocess
Program1, Argument1, Program2, Argument2, Player1, Player2, Grid = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], [0, 0], [24, 24], [['.' for y in range(25)] for x in range(25)]
while True:
Str = ''
for x in range(25):
for y in range(25):
if Grid[x][y] == '1' or Grid[x][y] == '2':
Grid[x][y] = '#'
Grid[Player1[0]][Player1[1]] = '1'
Grid[Player2[0]][Player2[1]] = '2'
for y in range(25):
for x in range(25):
Str += Grid[x][y]
Str += ';'
if Argument1 == '':
move = subprocess.Popen([Program1, Str], stdout=subprocess.PIPE).stdout.read().decode('ASCII')[0]
else:
move = subprocess.Popen([Program1, Argument1, Str], stdout=subprocess.PIPE).stdout.read().decode('ASCII')[0]
Lose1 = False
if move == 'N':
if Player1[1] > 0:
Player1[1] -= 1
else:
Player1[1] = 24
elif move == 'E':
if Player1[0] < 24:
Player1[0] += 1
else:
Player1[0] = 0
elif move == 'S':
if Player1[1] < 24:
Player1[1] += 1
else:
Player1[1] = 0
elif move == 'W':
if Player1[0] > 0:
Player1[0] -= 1
else:
Player1[0] = 24
else:
Lose1 = True
if Grid[Player1[0]][Player1[1]] == '#' or Grid[Player1[0]][Player1[1]] == '2':
Lose1 = True
print('Player 1:', move)
if Argument2 == '':
move = subprocess.Popen([Program2, Str.replace('2','3').replace('1','2').replace('3','1')], stdout=subprocess.PIPE).stdout.read().decode('ASCII')[0]
else:
move = subprocess.Popen([Program2, Argument2, Str.replace('2','3').replace('1','2').replace('3','1')], stdout=subprocess.PIPE).stdout.read().decode('ASCII')[0]
Lose2 = False
if move == 'N':
if Player2[1] > 0:
Player2[1] -= 1
else:
Player2[1] = 24
elif move == 'E':
if Player2[0] < 24:
Player2[0] += 1
else:
Player2[0] = 0
elif move == 'S':
if Player2[1] < 24:
Player2[1] += 1
else:
Player2[1] = 0
elif move == 'W':
if Player2[0] > 0:
Player2[0] -= 1
else:
Player2[0] = 24
elif Lose1:
Lose2 = True
else:
Lose2 = True
print('Player 2:', move)
print(Str.replace(';', '\n'))
if Grid[Player2[0]][Player2[1]] == '#':
Lose2 = True
if Lose1 and Lose2:
print('Draw!')
break
elif Lose1:
print('Player 2 wins!')
break
elif Lose2:
print('Player 1 wins!')
break