What’s wrong with my code ? The analysis function don’t work and my organism try to reach walls sometimes.
import sys
import math
from random import randint
width, height = [int(i) for i in input().split()]
def near_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
dir=“N”
def analysis(thing,organism):
if (organism==“HARVESTER” and my_c * my_d==1) or (organism==“TENTACLE” and my_b *my_c==1):
enough=True
else:
enough=False
for i in thing:
for j in positions:
if diagonal(j,i)==True and enough==True:
typ=organism
liste=[i[0],i[1],j[2]]
if i[1]>j[1]:
dir=‘E’
elif i[1]<j[1]:
dir=‘W’
if i[0]>j[0]:
liste[0]-=1
elif i[0]<j[0]:
liste[0]+=1
while True:
positions=[]
proteins=[]
enemy=[]
walls=[]
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]
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,organ_id])
organ_parent_id = int(inputs[6])
organ_root_id = int(inputs[7])
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):
liste=[randint(1,width-1),randint(1,height-1),1]
while (liste in positions) or (liste in enemy) or (liste in walls):
liste=[randint(1,width-1),randint(2,height-2),1]
if my_a>0:
typ=“BASIC”
analysis(enemy,“TENTACLE”)
analysis(proteins,“HARVESTER”)
print(“GROW”,liste[2],liste[0],liste[1],typ,dir)
is there a way to jump back a league to do some practice? I mean I can use Boss N as an enemy, but I need some seed for “simpler” maps as well; is there any chance to get those?
need help, I’m at wood level 1, I beat the boss every time, but I don’t move up to the bronze league, I remain stuck in the places between 7 and 3, I have modified my code, I don’t see what is blocking and how the points are calculated, I currently have a score of 22.64, the one just before me has a score of 23.09 but I don’t see any difference, he wins all his fights also against the boss, who can help me understand, thanks in advance
It’s the same for me. I don’t understand how beat the boss because the only possibility is to create a TENTACULE but it’s not possible, we have not enough B proteine. One is needed to create the SPORER and second one to create the second ROOT. And you start with only 2 B proteines…
This only checks that my_c and my_d are strictly equal to 1, what you want to check is whether you have at least one of each protein, so you must replace the condition with my_c * my_d >= 1. (Same issue with my_b * my_c == 1 for the tentacle)
Yes, that’s according to the game rules. Two organisms tried to grow an organ in the same square “(6, 2)” and “growth collision” creates a wall, described in “Action order for one turn” in the rules. Note that the same player can also have multiple organisms and a wall is created regardless of whether the organisms attempting growth in same square belong to the same or different players.