注意
这项挑战已经结束,不再需要重新判断,但可以随时发布答案并使用“控制程序”与其他程序进行测试!
这项挑战的目的是通过在25x25的网格上策略性地绘制一堵墙来阻挡对手,从而使AI赢得与另一AI的对抗。
输入值
25行;
,以命令行参数分隔并以结尾。这将包括:
- 空的空间
.
- 墙
#
- 玩家
1
和2
(对手总是2
)
例
###############..........;..............#..........;..............#..........;..............#..........;..............#..........;...........1###..........;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;.........................;...................###...;...................#.##..;2..................#..#..;#..................##.#..;#...................#.###;....................#####;
代表以下地图:
###############..........
..............#..........
..............#..........
..............#..........
..............#..........
...........1###..........
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
.........................
...................###...
...................#.##..
2..................#..#..
#..................##.#..
#...................#.###
....................#####
输出量
写入控制台的字符串,其开头的字符代表AI希望转向的方向。这是区分大小写的!
- 北
N
- 东
E
- 南
S
- 西方
W
- 放弃(别的)
例
W
游戏规则
- 随着AI的移动,它们将在其后面留下坚固的墙痕。
- 玩家从左上角和右下角开始
- 游戏将持续到任何AI撞墙或AI撞向对方为止。
- 如果对手首先崩溃,则AI获胜
- 如果两个AI同时输掉,就没有赢家或输家。
- 如果AI从网格的一侧移出,它们将从另一侧沿相同方向继续延伸。
排名
第一名-FloodBot(Java,12胜)
第二名-FluidBot(Python,9胜)
第三名-FillUpBot(C ++,8胜)
第四名-AwayBot(Ruby,5胜)
第五名-ArcBot(Python,4胜)
第六名-BlindSnake(批次,2胜)
第六名-RandomBot(C#,2获胜)
控制程序(经过Python 3.3.3测试)
该程序使用两个命令的参数和""
AI 的单个参数(如果不需要)运行。Control.py "ruby" "AwayBot.rb" "FillUpBot.exe" ""
。可以在这里下载。
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