Binary Deployment code help needed[Python]


#1

Can i please have help.
i don’t know how to do this.
ANY help on strategy or concept would be helpful!
:grin:


#2

We don’t have superpowers, first, can you put out your code? And also tell us what’s wrong, don’t just ask for help and expect us to be psychics so we can read your mind.


#3

i don’t know how to binary deployment with code.
i have no idea where to start
the only thing i know is that i have to use vectors


#4

press Reload and then copy - paste the default stuff.


#5

Recruit soldiers and archers to fill out each squadron.

Each paladin has a decimal number stored in her deployment attribute.

Convert these to binary and represent them with line soldiers and archers next to each paladin.

Soldiers are 0s, archers are 1s.

For the bonus goal, add griffins as 2s for trinary number lines next to the warlocks.

Check the guide for help with binary numbers.


#6

i have tried and i’m so close!
here’s my code:

# Recruit soldiers and archers to fill out each squadron.
# Each paladin has a decimal number stored in her deployment attribute.
# Convert these to binary and represent them with line soldiers and archers next to each paladin.
# Soldiers are 0s, archers are 1s.
# For the bonus goal, add griffins as 2s for trinary number lines next to the warlocks.
# Check the guide for help with binary numbers.
def getNum(number, delimer = 2):
    return number%delimer

summonTypes = ["soldier", "archer", "griffin-rider"]
def summonTroops(num, coorX, coorY):
    type = summonTypes[num]
    if self.gold > self.costOf(type):
        self.summon(type)
        friend = self.findByType(summonTypes[num], self.findFriends())
        self.command(friends[len(friends)-1], "move", {'x':coorX, 'y':coorY})*
array = []
maxY = 55
minY = 10
countY = 7
minX = 22
maxX = 63
countX = 8
iY = 0
friends = self.findByType('paladin', self.findFriends())
for index, friend in enumerate(friends):
    array.append([friend.deployment, 2, friend.pos.y])
friends = self.findByType('warlock', self.findFriends())
for index, friend in enumerate(friends):
    array.append([friend.deployment, 3, friend.pos.y])
for y in range(maxY, minY - 1, (minY - maxY)/(countY - 1)):
    iX = 0
    number = array[iY][0]
    for x in range(maxX, minX - 1, (minX - maxX)/(countX - 1)):
        num = getNum(number, array[iY][1])
        number = Math.floor(number/array[iY][1])
        summonTroops(num, x, array[iY][2])
        iX = iX + 1
    iY = iY + 1

*that is where it says “hero placeholder can’t command type warlock”


Binary Deployment code help needed [Python]
Binary Deployment (Python) - Help Please
#7

Please avoid posting the same problem in multiple threads, that will mostly confuse people and waste effort.

As for the code:

        friend = self.findByType(summonTypes[num], self.findFriends())
        self.command(friends[len(friends)-1], "move", {'x':coorX, 'y':coorY})

You’re defining a variable called “friend” but then trying to read the last item from a completely different variable called “friends”. You can either fix this typo, or just use:

        self.command(self.built[-1], "move", {'x':coorX, 'y':coorY})

#8

i’m sorry ultcombo i didn’t know that ty