# Manage the queue without mistakes.
# Useful string constants.
PHRASE_IN = " in"
PHRASE_OUT = " out"
IDLE = "idle"
# The list of workers.
workers = hero.findByType("peasant", hero.findFriends())
# Use this array to control the worker queue.
queue = []
while True:
# Iterate through all the workers:
for work in workers:
if work.status == IDLE:
hero.say(work + PHRASE_IN)
# If the worker's "status" property is "idle":
queue.append(work)
# Say the worker's name and the string " in":
# Add the worker to the end of the queue:
item = hero.findNearestItem()
# If the item exists and the queue isn't empty:
if item and queue != []:
hero.say(work + PHRASE_OUT)
# Say the name of the first worker in the queue
# with the string " out":
queue.pop()
# Remove (shift) the first worker from the queue:
He just put instead of the “is” the “==” and instead of “array.remove()” this “array.pop()”. The rest is exactly the same. And if read the hints he would see that pop() does not work really welll in Python.
@crafter I am positive you copied the code since it looks identical. What is the point of using CodeCombat if you’re not even writing the code yourself, so please don’t copy others code.
I did actually see it, and having decided it was copied, I asked if the link could be removed. Because people can’t seem to stop using it and claiming it’s their own, I think it would be better the fewer people knew about it. Just my opinion… I think it’s the best way to deal with it, a few years ago when most people didn’t know about it I didn’t see stolen code that often.
Danny