I ask again : whatās wrong with my code ?
import sys
import math
from random import randint
width, height = [int(i) for i in input().split()]
def next_to(pos1,pos2):
| |if (pos1[0]==pos2[0] and abs(pos1[1]-pos2[1])==1) or (pos1[1]==pos2[1] and abs(pos1[0]-pos2[0])==1):
| | |return True
| |else:
| | |return False
def diagonal(pos1,pos2):
| |if abs(pos1[0]-pos2[0]) * abs(pos1[1]-pos2[1])==1:
| | |return True
| |else:
| | |return False
def close_to(pos1,pos2):
| |if abs(pos1[0]-pos2[0]) * abs(pos1[1]-pos2[1])<4 and abs(pos1[0]-pos2[0])<3 and abs(pos1[1]-pos2[1])<3:
| | |return True
| |else:
| | |return False
dir=āNā
def analysis(_root,thing,organism):
| |if (organism==āHARVESTERā and my_c * my_d>0) or (organism==āTENTACLEā and my_b * my_c>0):
| | |enough=True
| |else:
| | |enough=False
| | |return ānothingā
| |for i in thing:
| | |for j in _root:
| | | |if close_to(j[1],i)==True and enough==True:
| | | | |typ=organism
| | | | |if diagonal[i,j]==True:
| | | | | |liste=[i[0],i[1],j[0]]
| | | | | |if i[1]>j[1][1]:
| | | | | | |dir=āEā
| | | | | |elif i[1]<j[1][1]:
| | | | | | |dir=āWā
| | | | | |if i[0]>j[1][0]:
| | | | | | |liste[0]-=1
| | | | | |elif i[0]<j[1][0]:
| | | | | | |liste[0]+=1
| | | | |elif i[0]-j[1][0]==0:
| | | | | |if i[1]-j[1]>0:
| | | | | | |liste[1]-=1
| | | | | |else:
| | | | | | |liste[1]+=1
| | | | |elif i[1]-j[1][1]==0:
| | | | | |if i[0]-j[0]>0:
| | | | | | |liste[0]-=1
| | | | | |else:
| | | | | | |liste[0]+=1
game loop
while True:
| |positions=[]
| |proteins=[]
| |enemy=[]
| |walls=[]
| |organs={}
| |my_roots=[]
| |entity_count = int(input())
| |for i in range(entity_count):
| | |inputs = input().split()
| | |x = int(inputs[0])
| | |y = int(inputs[1])
| | |_type = inputs[2]
| | |owner = int(inputs[3])
| | |organ_id = int(inputs[4])
| | |organ_dir = inputs[5]
| | |organ_parent_id = int(inputs[6])
| | |organ_root_id = int(inputs[7])
| | |if _type==āAā or _type==āBā or _type==āCā or _type==āDā:
| | | | |proteins.append([x,y])
| | |elif _type==āWALLā:
| | | | |walls.append([x,y])
| | |elif owner==0:
| | | |enemy.append([x,y])
| | |elif owner==1:
| | | |positions.append([x,y])
| | | |if organ_root_id in organs:
| | | | |l=[]
| | | | |l.append(organs[organ_root_id])
| | | | |l.append(organ_id)
| | | | |l.append([x,y])
| | | | |organs[organ_root_id]=l
| | | |else:
| | | | |organs[organ_root_id]=organ_id
| | | | |my_roots.append([organ_id,[x,y]])
| |my_a, my_b, my_c, my_d = [int(i) for i in input().split()]
| |opp_a, opp_b, opp_c, opp_d = [int(i) for i in input().split()]
| |required_actions_count = int(input()) # your number of organisms, output an action for each one in any order
| |for i in range(required_actions_count):
| | |if len(positions)==1:
| | | |print(āGROWā,1,positions[0][0],positions[0][0]+2,āSPORERā,āEā)
| | |elif len(positions)==2:
| | | |print(āSPOREā,3,positions[1][0]+13,positions[1][1])
| | |else:
| | | |if my_a==0 and i+1<required_actions_count:
| | | | |print(āWAITā)
| | | |else:
| | | | |liste=[randint(1,width-1),randint(1,height-1)]
| | | |print(organs,file=sys.stderr,flush=True)
| | | |while (liste in positions) or (liste in enemy) or (liste in walls):
| | | | |liste=[randint(1,width-1),randint(1,height-1)]
| | | |if my_a>0:
| | | | |typ=āBASICā
| | | |elif my_b*my_c>0:
| | | | |typ=āTENTACLEā
| | | |else:
| | | | |typ=āHARVESTERā
| | | | |thing_that_dont_work_else=my_roots[i]
| | | | |organ_group=organs[thing_that_dont_work_else]
| | | | |analysis(organ_group,enemy,āTENTACLEā)
| | | | |analysis(organ_group,proteins,āHARVESTERā)
| | | | |print(āGROWā,my_roots[i],liste[0],liste[1],typ,dir,āslimy soundsā)