What in carnation not letting me win

I am sure that I coded the right stuff for What in carnation but it’s not letting me win.

this is what my code does

this is my code

twoPi = 2 * Math.PI

Here are some functions for drawing shapes:
def degreesToRadians(degrees):
return (degrees/360)*twoPi

def drawPolyStars(center, radius, sides, skips, startAngle):
angle = startAngle
x = center.x
y = center.y
self.toggleFlowers(False)
loops = skips + 1
stepAngle = loops * (twoPi / sides)
if skips != 0 and (sides % loops) == 0:
loops = skips
endAngle = (twoPi * loops) + startAngle
while angle <= endAngle:
newX = x + radius * Math.cos(angle)
newY = y + radius * Math.sin(angle)
self.moveXY(newX, newY)
self.toggleFlowers(True)
angle += stepAngle

def drawStar(center, radius, sides, skips, startAngle):
skipsPlusOne = skips + 1
if ((sides/skipsPlusOne) != 1 and (sides%skipsPlusOne) == 0):
for index in range(skipsPlusOne):
angle = startAngle + index * (twoPi / sides)
drawPolyStars(center, radius, sides, skips, angle)
else:
drawPolyStars(center, radius, sides, skips, startAngle)

def drawPolygon(center, radius, sides, startAngle):
drawPolyStars(center, radius, sides, 0, startAngle)

def drawSpokes(center, radius, sides, startAngle):
x = center.x
y = center.y
endAngle = twoPi + startAngle
stepAngle = twoPi / sides
angle = startAngle
while angle < endAngle:
newX = x + radius * Math.cos(angle)
newY = y + radius * Math.sin(angle)
if int(self.pos.x) == int(x) and int(self.pos.y) == int(y):
self.toggleFlowers(True)
self.moveXY(newX, newY)
else:
self.toggleFlowers(False)
self.moveXY(newX, newY)
self.toggleFlowers(True)
self.moveXY(x, y)
self.toggleFlowers(False)
angle += stepAngle

def ternary(thisOne, condition, thatOne):
if condition:
return thisOne
else:
return thatOne

def drawSpiral(center, size, loopNum, startAngle):
x = center.x
y = center.y
self.toggleFlowers(False)
self.moveXY(x, y)
self.toggleFlowers(True)
steps = size * 2
direction = Math.sign(loopNum)
stepAngle = twoPi / steps / direction
loops = direction * loopNum
stepSize = size / steps / loops
curSize = 0
angle = startAngle
endAngle = (twoPi * loopNum) + startAngle
while ternary((angle>=endAngle),(loopNum<0),(angle<=endAngle)):
newX = x + curSize * Math.cos(angle)
newY = y + curSize * Math.sin(angle)
self.moveXY(newX, newY)
angle += stepAngle
curSize += stepSize
newX = x + size * Math.cos(endAngle)
newY = y + size * Math.sin(endAngle)
self.moveXY(newX, newY)

redX = {“x”: 28, “y”: 36}
whiteX = {“x”: 60, “y”: 36}
PI = 3.1415

self.setFlowerColor(“white”)
setFlowerColor
drawSpokes(redX, 10, 3, 55)
drawPolygon(redX, 10, 6, 55)

Draw a “3D style” box, using the drawPolygon and drawSpokes functions, centered on the red X and with a size of 10.
The simplest startAngles to calculate would be either “up” or “down”.
The drawing functions deal with angles in terms of radians. If you think in terms of degrees then please use the “degreesToRadians(degrees)” function so they can understand
drawPolygon(center, size, number of sides, start angle)
drawSpokes(center, size, number of spokes, start angle)
Draw the star bib, using the drawStar and drawSpiral functions. (See the Guide for an image of the shapes.)
The star is centered on the white X and has a size of 6.
The spirals have a size of 15. To get a spiral to go the other direction give it a negative number of loops.
self.setFlowerColor(“yellow”)
setFlowerColor
drawStar(center, size, sides, skips, startAngle)
drawStar(whiteX, 6, 14, 5,235)
setFlowerColor
self.setFlowerColor(“purple”)
drawSpiral(center, size, number of loops, start angle)
drawSpiral(center, size, number of loops, start angle)

drawSpiral({“x”: 60, “y”: 43}, 15, 1, 55)
drawSpiral({“x”: 60, “y”: 43}, 15, -1, 55)

FWI all the text parts have #s I just got rid of them so it wouldn’t show up so big as text.

And this is what the hint pic looks like

Please format your code according to the FAQ, otherwise we cannot tell if it is an indentation error or something. You can format your code by surrounding it with three backticks on either end, and it will show up something like this:

# example code
hero.say("example code")
# more example code
while True:
    hero say("The indentations can still show up!")
2 Likes
twoPi = 2 * Math.PI

# Here are some functions for drawing shapes:
def degreesToRadians(degrees):
    return (degrees/360)*twoPi

def drawPolyStars(center, radius, sides, skips, startAngle):
    angle = startAngle
    x = center.x
    y = center.y
    self.toggleFlowers(False)
    loops = skips + 1
    stepAngle = loops * (twoPi / sides)
    if skips != 0 and (sides % loops) == 0:
        loops = skips
    endAngle = (twoPi * loops) + startAngle
    while angle <= endAngle:
        newX = x + radius * Math.cos(angle)
        newY = y + radius * Math.sin(angle)
        self.moveXY(newX, newY)
        self.toggleFlowers(True)
        angle += stepAngle

def drawStar(center, radius, sides, skips, startAngle):
    skipsPlusOne = skips + 1
    if ((sides/skipsPlusOne) != 1 and (sides%skipsPlusOne) == 0):
        for index in range(skipsPlusOne):
            angle = startAngle + index * (twoPi / sides)
            drawPolyStars(center, radius, sides, skips, angle)
    else:
        drawPolyStars(center, radius, sides, skips, startAngle)

def drawPolygon(center, radius, sides, startAngle):
    drawPolyStars(center, radius, sides, 0, startAngle)

def drawSpokes(center, radius, sides, startAngle):
    x = center.x
    y = center.y
    endAngle = twoPi + startAngle
    stepAngle = twoPi / sides
    angle = startAngle
    while angle < endAngle:
        newX = x + radius * Math.cos(angle)
        newY = y + radius * Math.sin(angle)
        if int(self.pos.x) == int(x) and int(self.pos.y) == int(y):
            self.toggleFlowers(True)
            self.moveXY(newX, newY)
        else:
            self.toggleFlowers(False)
            self.moveXY(newX, newY)
            self.toggleFlowers(True)
            self.moveXY(x, y)
        self.toggleFlowers(False)
        angle += stepAngle

def ternary(thisOne, condition, thatOne):
    if condition:
        return thisOne
    else:
        return thatOne

def drawSpiral(center, size, loopNum, startAngle):
    x = center.x
    y = center.y
    self.toggleFlowers(False)
    self.moveXY(x, y)
    self.toggleFlowers(True)
    steps = size * 2
    direction = Math.sign(loopNum)
    stepAngle = twoPi / steps / direction
    loops = direction * loopNum
    stepSize = size / steps / loops
    curSize = 0
    angle = startAngle
    endAngle = (twoPi * loopNum) + startAngle
    while ternary((angle>=endAngle),(loopNum<0),(angle<=endAngle)):
        newX = x + curSize * Math.cos(angle)
        newY = y + curSize * Math.sin(angle)
        self.moveXY(newX, newY)
        angle += stepAngle
        curSize += stepSize
    newX = x + size * Math.cos(endAngle)
    newY = y + size * Math.sin(endAngle)
    self.moveXY(newX, newY)
 
redX = {"x": 28, "y": 36}
whiteX = {"x": 60, "y": 36}
PI = 3.1415
# --------------------------------------------------
self.setFlowerColor("white")
#setFlowerColor
drawSpokes(redX, 10, 3, 55)
drawPolygon(redX, 10, 6, 55)

# Draw a "3D style" box, using the drawPolygon and drawSpokes functions, centered on the red X and with a size of 10.
# The simplest startAngles to calculate would be either "up" or "down".
# The drawing functions deal with angles in terms of radians. If you think in terms of degrees then please use the "degreesToRadians(degrees)" function so they can understand
#drawPolygon(center, size, number of sides, start angle)
#drawSpokes(center, size, number of spokes, start angle)
# Draw the star bib, using the drawStar and drawSpiral functions. (See the Guide for an image of the shapes.)
# The star is centered on the white X and has a size of 6.
# The spirals have a size of 15. To get a spiral to go the other direction give it a negative number of loops.
self.setFlowerColor("yellow")
#setFlowerColor
#drawStar(center, size, sides, skips, startAngle)
drawStar(whiteX, 6, 14, 5,235) 
#setFlowerColor
self.setFlowerColor("purple")
#drawSpiral(center, size,  number of loops, start angle)
#drawSpiral(center, size,  number of loops, start angle)
drawSpiral({"x": 60, "y": 43}, 15,  1, 55)
drawSpiral({"x": 60, "y": 43}, 15,  -1, 55)

here is the code.

3 Likes

I used to have the same question as you do, really. Then I looked at other What In Carnation chats and realized that the degreesToRadians(degrees) function was there, and for a reason. I’d never noticed it there before at all.

So for the polygon and spokes, instead of start angle 55 it would be degreesToRadians(-90). Same deal with the spirals. The star would still be just start angle 235.

Also the spiral offset point is at {"x": 60, "y": 42} instead of "y": 43.
Every point on the map counts. :slightly_smiling_face: Precision is key.

5 Likes

Thank you very much!:smiley:

Happy to help @FlowerChi! :slightly_smiling_face:

1 Like

I’m also having trouble, My code is:

twoPi = 2 * Math.PI

# Here are some functions for drawing shapes:
def degreesToRadians(degrees):
    return (degrees/360)*twoPi

def drawPolyStars(center, radius, sides, skips, startAngle):
    angle = startAngle
    x = center.x
    y = center.y
    self.toggleFlowers(False)
    loops = skips + 1
    stepAngle = loops * (twoPi / sides)
    if skips != 0 and (sides % loops) == 0:
        loops = skips
    endAngle = (twoPi * loops) + startAngle
    while angle <= endAngle:
        newX = x + radius * Math.cos(angle)
        newY = y + radius * Math.sin(angle)
        self.moveXY(newX, newY)
        self.toggleFlowers(True)
        angle += stepAngle

def drawStar(center, radius, sides, skips, startAngle):
    skipsPlusOne = skips + 1
    if ((sides/skipsPlusOne) != 1 and (sides%skipsPlusOne) == 0):
        for index in range(skipsPlusOne):
            angle = startAngle + index * (twoPi / sides)
            drawPolyStars(center, radius, sides, skips, angle)
    else:
        drawPolyStars(center, radius, sides, skips, startAngle)

def drawPolygon(center, radius, sides, startAngle):
    drawPolyStars(center, radius, sides, 0, startAngle)

def drawSpokes(center, radius, sides, startAngle):
    x = center.x
    y = center.y
    endAngle = twoPi + startAngle
    stepAngle = twoPi / sides
    angle = startAngle
    while angle < endAngle:
        newX = x + radius * Math.cos(angle)
        newY = y + radius * Math.sin(angle)
        if int(self.pos.x) == int(x) and int(self.pos.y) == int(y):
            self.toggleFlowers(True)
            self.moveXY(newX, newY)
        else:
            self.toggleFlowers(False)
            self.moveXY(newX, newY)
            self.toggleFlowers(True)
            self.moveXY(x, y)
        self.toggleFlowers(False)
        angle += stepAngle

def ternary(thisOne, condition, thatOne):
    if condition:
        return thisOne
    else:
        return thatOne

def drawSpiral(center, size, loopNum, startAngle):
    x = center.x
    y = center.y
    self.toggleFlowers(False)
    self.moveXY(x, y)
    self.toggleFlowers(True)
    steps = size * 2
    direction = Math.sign(loopNum)
    stepAngle = twoPi / steps / direction
    loops = direction * loopNum
    stepSize = size / steps / loops
    curSize = 0
    angle = startAngle
    endAngle = (twoPi * loopNum) + startAngle
    while ternary((angle>=endAngle),(loopNum<0),(angle<=endAngle)):
        newX = x + curSize * Math.cos(angle)
        newY = y + curSize * Math.sin(angle)
        self.moveXY(newX, newY)
        angle += stepAngle
        curSize += stepSize
    newX = x + size * Math.cos(endAngle)
    newY = y + size * Math.sin(endAngle)
    self.moveXY(newX, newY)
 
redX = {"x": 28, "y": 36}
whiteX = {"x": 60, "y": 36}
PI = 3.1415
# --------------------------------------------------
self.setFlowerColor("white")
#setFlowerColor
drawSpokes(redX, 10, 3, 55)
drawPolygon(redX, 10, 6, 55)

# Draw a "3D style" box, using the drawPolygon and drawSpokes functions, centered on the red X and with a size of 10.
# The simplest startAngles to calculate would be either "up" or "down".
# The drawing functions deal with angles in terms of radians. If you think in terms of degrees then please use the "degreesToRadians(degrees)" function so they can understand
#drawPolygon(center, size, number of sides, start angle)
#drawSpokes(center, size, number of spokes, start angle)
# Draw the star bib, using the drawStar and drawSpiral functions. (See the Guide for an image of the shapes.)
# The star is centered on the white X and has a size of 6.
# The spirals have a size of 15. To get a spiral to go the other direction give it a negative number of loops.
 self.setFlowerColor("yellow")
#setFlowerColor
#drawStar(center, size, sides, skips, startAngle)
drawStar(whiteX, 6, 14, 5,235) 
#setFlowerColor
self.setFlowerColor("purple")
#drawSpiral(center, size,  number of loops, start angle)
#drawSpiral(center, size,  number of loops, start angle)
drawSpiral({"x": 60, "y": 42}, 15,  1, 55)
drawSpiral({"x": 60, "y": 42}, 15,  -1, 55)

sigh A necro… Still it’s better than creating a duplicate topic.

Ah well, what’s the problem?