importnumpyasnp
defdfs(maze,start,end):
stack=[start]
visited=set()
whilestack:
x,y=stack.pop()
if(x,y)==end:
returnTrue
visited.add((x,y))
fordx,dyin[(1,0),(1,0),(0,1),(0,1)]:
nx,ny=x+dx,y+dy
if0<= nx < len(maze) and 0 <= ny < len(maze[0]) and maze[nx][ny] == 0 and (nx, ny) not in visited:
stack.append((nx,ny))
returnFalse
importnumpyasnp
defavoid_traps(maze,traps):
path=
x,y=0,0
while(x,y)!=(len(maze)1,len(maze[0])1):
path.append((x,y))
next_moves=
fordx,dyin[(1,0),(1,0),(0,1),(0,1)]:
nx,ny=x+dx,y+dy
if0<= nx < len(maze) and 0 <= ny < len(maze[0]) and maze[nx][ny] == 0 and (nx, ny) not in traps:
next_moves.append((nx,ny))
ifnext_moves:
x,y=min(next_moves,key=lambdap:abs(p[0](len(maze)1))+abs(p(len(maze[0])1)))
else:
returnNone
returnpath
defkill_boss(boss_health,team_damage):
whileboss_health>0:
fordamageinteam_damage:
boss_health=damage
ifboss_health<= 0:
returnTrue
returnFalse