# \[SOLVED\] Ring Bearer Please Help

**URL:** <https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929>\
**Category:** Uncategorized\
**Created:** [June 9, 2018, 5:58am UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929 "2018-06-09T05:58:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chichi\_King](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chichi_king/32/8247_2.png) [@chichi\_King](https://discourse.codecombat.com/u/chichi_King)\
**Post date:** [June 9, 2018, 5:58am UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/1 "2018-06-09T05:58:50Z")

</div>

```python
function findSoldierOffset(soldiers, i) {
    var soldier = soldiers[i];
    var angle = i * 360 / soldiers.length;
    return radialToCartesian(5, angle);
}

// This function does the math to determine the offset a soldier should stand at.
function radialToCartesian(radius, degrees) {
    var radians = Math.PI / 180 * degrees;
    var xOffset = radius * Math.cos(radians);
    var yOffset = radius * Math.sin(radians);
    return {x: xOffset, y: yOffset};
}
 var peasant = hero.findByType("peasant")[0]; 
// Use findByType to get an array of your soldiers.
while(true) {
    // Use a for-loop to iterate over your array of soldiers.
    var soldiers = hero.findByType("soldier");
    for(var i = 0; i < soldiers.length; i ++) {
       var soldier = soldiers[i];
       var offset = findSoldierOffset(soldiers, i);
       var offsetX = peasant.pos.x + offset.x;
       var offsetY = peasant.pos.y + offset.y;
       var position = {"x": offsetY, "y": offsetY};
       hero.command(soldier, "move", position);
    
    }
    // Find the offset for a soldier.
    // Add the offset.x and offset.y to the peasant's pos.x and pos.y.
    // Command the soldier to move to the new offset position.
    // The hero should keep pace with the peasant!
    hero.move({x: hero.pos.x + 0.2, y: hero.pos.y});
}

```

So the problem is that the soldiers are stop moving in the middle.

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [June 9, 2018, 7:21pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/2 "2018-06-09T19:21:36Z")

</div>

What map is this? Please give any other additional information about errors and etc.

---

<div class="post-metadata">

**Author:** ![chichi\_King](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chichi_king/32/8247_2.png) [@chichi\_King](https://discourse.codecombat.com/u/chichi_King)\
**Post date:** [June 9, 2018, 8:48pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/3 "2018-06-09T20:48:50Z")

</div>

[https://codecombat.com/play/level/ring-bearer](https://codecombat.com/play/level/ring-bearer)?

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [June 9, 2018, 10:09pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/4 "2018-06-09T22:09:44Z")

</div>

It’s in cloudrip mountain.

---

<div class="post-metadata">

**Author:** ![chichi\_King](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chichi_king/32/8247_2.png) [@chichi\_King](https://discourse.codecombat.com/u/chichi_King)\
**Post date:** [June 10, 2018, 7:25am UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/5 "2018-06-10T07:25:01Z")

</div>

The soldiers always stops in the middle. And I have no idea why.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [June 10, 2018, 12:27pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/6 "2018-06-10T12:27:18Z")

</div>

> [@chichi\_King](#):
>
> var offsetX = peasant.pos.x + offset.x;  
> var offsetY = peasant.pos.y + offset.y;  
> var position = {“x”: offsetY, “y”: offsetY};

These lines aren’t needed, you can put these on one line. Use your `var position` to store the `peasant.pos.x + offset.x` and the `peasant.pos.y + offset.y` in the `var position` and command your soldier to move to “position” apart from that your code is right.

---

<div class="post-metadata">

**Author:** ![chichi\_King](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chichi_king/32/8247_2.png) [@chichi\_King](https://discourse.codecombat.com/u/chichi_King)\
**Post date:** [June 11, 2018, 10:39am UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/7 "2018-06-11T10:39:56Z")

</div>

> [@Deadpool198](#):
>
> `peasant.pos.x + offset.x`

Maan!  
You rock!  
Thank you.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [June 11, 2018, 10:53am UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/8 "2018-06-11T10:53:06Z")

</div>

My pleasure. 😁 (20 chars)

---

<div class="post-metadata">

**Author:** ![David\_Thompson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/david_thompson/32/20591_2.png) [@David\_Thompson](https://discourse.codecombat.com/u/David_Thompson)\
**Post date:** [February 17, 2021, 6:17pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/9 "2021-02-17T18:17:52Z")

</div>

What is the final solution to the level? Whats the whole code look like?

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [February 17, 2021, 6:23pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/10 "2021-02-17T18:23:54Z")

</div>

We don’t give out working code, also welcome to the forums. We also don’t revive “dead topics”

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 17, 2021, 6:23pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/11 "2021-02-17T18:23:55Z")

</div>

Welcome to the forum. We can not give solutions but if you need help you can make a new topic.

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [February 17, 2021, 6:23pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/12 "2021-02-17T18:23:57Z")

</div>

Sorry we cant give answers

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review [this topic](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

---

<div class="post-metadata">

**Author:** ![Falcons118](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/falcons118/32/32017_2.png) [@Falcons118](https://discourse.codecombat.com/u/Falcons118)\
**Post date:** [February 17, 2021, 6:24pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/13 "2021-02-17T18:24:11Z")

</div>

wow all of us posted at the same time 😁

---

<div class="post-metadata">

**Author:** ![David\_Thompson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/david_thompson/32/20591_2.png) [@David\_Thompson](https://discourse.codecombat.com/u/David_Thompson)\
**Post date:** [February 17, 2021, 6:30pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/14 "2021-02-17T18:30:04Z")

</div>

bruh i need it for school. can you just give me the code to complete the level ? ☹

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [February 17, 2021, 6:31pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/15 "2021-02-17T18:31:45Z")

</div>

Then you wouldn’t learn anything. Give us your code and we can help you.

---

<div class="post-metadata">

**Author:** ![David\_Thompson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/david_thompson/32/20591_2.png) [@David\_Thompson](https://discourse.codecombat.com/u/David_Thompson)\
**Post date:** [February 17, 2021, 6:32pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/16 "2021-02-17T18:32:37Z")

</div>

Im running out of time but i tried to complete the level. I need to complete it for school

function findSoldierOffset(soldiers, i) {  
var soldier = soldiers[i];  
var angle = i \* 360 / soldiers.length;  
return radialToCartesian(5, angle);  
}  
function radialToCartesian(radius, degrees) {  
var radians = Math.PI / 180 \* degrees;  
var xOffset = radius \* Math.cos(radians);  
var yOffset = radius \* Math.sin(radians);  
return {x: xOffset, y: yOffset};  
}

var peasant = hero.findByType(“peasant”)[0];

while(true) {

```
 var soldiers = hero.findByType("soldier");
 for(var i = 0; i < soldiers.length; i ++) {

  var soldier = soldiers[i];
   var offset = findSoldierOffset(soldiers, i);
    var x = offset.x + peasant.pos.x;
   var y = offset.y + peasant.pos.y;
hero.command(soldiers, "move", {'x': x, 'y': y});
}
hero.move({x: hero.pos.x + 0.2, y: hero.pos.y});

```

}

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [February 17, 2021, 6:34pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/17 "2021-02-17T18:34:06Z")

</div>

Look at this and please try and write your own code.

> [@Deadpool198](#):
>
> > [@](#):
> >
> > var offsetX = peasant.pos.x + offset.x;
> > 
> > > var offsetY = peasant.pos.y + offset.y;  
> > > var position = {“x”: offsetY, “y”: offsetY};
> 
> These lines aren’t needed, you can put these on one line. Use your `var position` to store the `peasant.pos.x + offset.x` and the `peasant.pos.y + offset.y` in the `var position` and command your soldier to move to “position” apart from that your code is right.

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 17, 2021, 6:38pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/19 "2021-02-17T18:38:01Z")

</div>

Stop being rude and listen to the rules.

---

<div class="post-metadata">

**Author:** ![David\_Thompson](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/david_thompson/32/20591_2.png) [@David\_Thompson](https://discourse.codecombat.com/u/David_Thompson)\
**Post date:** [February 17, 2021, 6:39pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/20 "2021-02-17T18:39:03Z")

</div>

can u give me code pls. I might get bad grade in school ☹

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 17, 2021, 6:39pm UTC](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929/21 "2021-02-17T18:39:29Z")

</div>

Well sorry I don’t do JavaScript and again no we can’t give you the code.

[Next page](https://discourse.codecombat.com/t/solved-ring-bearer-please-help/14929.md?page=2)
