# Extremely hard game!

**URL:** <https://discourse.codecombat.com/t/extremely-hard-game/29287>\
**Category:** Artisan\
**Created:** [June 10, 2021, 1:33pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287 "2021-06-10T13:33:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 10, 2021, 1:33pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/1 "2021-06-10T13:33:45Z")

</div>

I made an EXTREMELY HARD multiplayer game. Here is how to play. There are 2 castles, with 2 treasure chests in each. You must steal both of the enemy treasure chests. To make things fun, a warlock guards each chest. You can summon [‘soldiers’, ‘archers’, ‘fire-shamans’, ‘water-shamans’, ‘earth-shamans’]  
hero.summon(“fire-shaman”)

You must command every troop you summon. For the shamans, canCast is enabled, so you can effectively command them to cast their helpful spells. Fire-Shamans have flame-armor, Earth-Shamans have earthskin, Water-Shamans have haste. This applies for both you and your opponent. You also must choose the right time to steal your enemies treasure, but never forget to defend you own. If both players fail to capture the enemy treasure within 60 seconds, the game is a tie. Have some fun here. But you must know for loops, while loops, if, else, canCast, arrays, append, findNearest, command, defining, modulo, functions and I probably forgot to mention some other stuff.  
Play here.

> **[CodeCombat - Coding games to learn Python and JavaScript](https://codecombat.com/play/ladder/castle-wars)**
>
> Learn typed code through a programming game. Learn Python, JavaScript, and HTML as you solve puzzles and learn to make your own coding games and websites.

@Hydrobolic, this is a nice and hard game, you might like it.

---

<div class="post-metadata">

**Author:** ![The\_legendary\_pro19](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_legendary_pro19/32/31950_2.png) [@The\_legendary\_pro19](https://discourse.codecombat.com/u/The_legendary_pro19)\
**Post date:** [June 10, 2021, 1:37pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/2 "2021-06-10T13:37:15Z")

</div>

I went in the link wanna play?

---

<div class="post-metadata">

**Author:** ![The\_legendary\_pro19](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_legendary_pro19/32/31950_2.png) [@The\_legendary\_pro19](https://discourse.codecombat.com/u/The_legendary_pro19)\
**Post date:** [June 10, 2021, 1:38pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/3 "2021-06-10T13:38:09Z")

</div>

Actually can’t play I am not that far in code combat

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 10, 2021, 6:03pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/4 "2021-06-10T18:03:49Z")

</div>

Some advanced coders would probably be better suited, like people who finisehd the entire mountain, (sub included) and understand concepts

---

<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 11, 2021, 12:52am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/5 "2021-06-11T00:52:01Z")

</div>

You haven’t updated the starter code yet 🙂

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 1:42am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/6 "2021-06-11T01:42:01Z")

</div>

@Chaboi_3000, I updated the sample code, and gave a lot of advice in it.

---

<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 11, 2021, 1:52am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/7 "2021-06-11T01:52:48Z")

</div>

Interesting 🙂 I’ll definitely get to it soon. You should modify the Simple CPU code so it forces the player to modify their code, since right now it just collects gems without attacking or summoning.

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 1:53am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/8 "2021-06-11T01:53:43Z")

</div>

Unfortunately, I do not know how to do that. I copy pasted sum of the zero sum code (geddit sum? zero sum?) and it did not work.

---

<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 11, 2021, 1:55am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/9 "2021-06-11T01:55:39Z")

</div>

You can modify the AI code in the enemy placeholder’s aiSource section. It’s really just JS code, so you can create the AI code in the actual level in JS, then once it works, you can simply paste that in there.

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 1:56am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/10 "2021-06-11T01:56:27Z")

</div>

BTW, if you watch some of my matches, you can see what ot looks like.

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 1:56am UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/11 "2021-06-11T01:56:53Z")

</div>

[Match vs Nick](https://codecombat.com/play/spectate/castle-wars?session-one=60c1569b508762001970d209&session-two=60c24887c55b76001e460b7b)  
GTG RN

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 5:47pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/12 "2021-06-11T17:47:00Z")

</div>

Update: Added 2 new shamans.  
Lightning shaman ; 60 health, 25 dmg, chain - lightning spell  
Shadow shaman; 60 health, 25 dmg, invisibity  
@Chaboi_3000

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 6:06pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/13 "2021-06-11T18:06:15Z")

</div>

@Chaboi_3000  
I did as you said, and the simple cpu has an error.

```python
var insults = ["You'll never defeat me!", "I am invincible!", "The default AI will prevail!", "Eat sample code!", "Talking makes me stop attacking!", "Beware, beautiful player!", "Taste my wand!", "Stupidhead!", "C'mon, fight back!"];
while(true) {
    if (this.findNearestEnemy) {
        var enemy = this.findNearestEnemy();
    } else if (this.findNearest) {
        enemy = this.findNearest(this.findEnemies());
    } else {
        enemy = "Hero Placeholder";
    }
    if (enemy) {
        if (Math.random() < 0.10) {
            this.say(insults[Math.floor(Math.random() * insults.length)]);
        }
        else {
            this.attack(enemy);
        }
    }
    if (this.gold > this.costOf("soldier")) {
        this.summon('soldier');
    }
    var friends = this.findFriends();
    for (var friendIndex = 0; friendIndex < friends.length; ++friendIndex) {
        var friend = friends[friendIndex];
        if (enemy)
            this.command(friend, "attack", enemy);
    }
}

```

I believe I know what is going wrong.  
`command`'s argument `minion` should have type `unit`, but got `object`: `Dungeon Door 4`.  
Hero Placeholder 1 can’t command type `"door"` (only types: fire-mage,earth-mage,water-mage,fire-shaman,earth-shaman,water-shaman,shadow-shaman,lightning-shaman,soldier,archer,griffin-rider,peasant).  
I got this from the console log. The hero is trying to command a door.  
It has the boss star ii, and the ai, maes the simple cpu loop through all it’s friends. It cannot command doors.  
However, I have no experiance whatsoever in JavaScript, as I only use python. Can you please post or send me the correct code for the AI? I just want you to change the for loop, making it so then the cpu loops through its friends, and only if the friends type is a soldier, command it to attack. Thanks.  
The AI was copy pasted from Zero SUm.  
Also, I made an acc called simpleaitest, and I cant change it to js

- Grant

---

<div class="post-metadata">

**Author:** ![Hydrobolic](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hydrobolic](https://discourse.codecombat.com/u/Hydrobolic)\
**Post date:** [June 11, 2021, 8:16pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/14 "2021-06-11T20:16:38Z")

</div>

Simple JS is not that far from simple Python.

Python: `if friend.type != "door" and enemy:`  
JS: `if (friend.type !== "door" && enemy)`

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 8:52pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/15 "2021-06-11T20:52:14Z")

</div>

Also, can @Hydrobolic can I have some tips for having my shamans dodge enemy missiles?

```python
shots = hero.findEnemyMissiles()
shot = friend.findNearest(shots)
    if shot and shot.type == 'earth-arrow':
        hero.command(friend, moveXY, friend.pos.x, friend.pos.y)

```

I enabled moveXY in the Hero Placeholder commanding system.  
I also made it so you can command the custom entities.  
My shamans still fail to dodge Nick’s earth tower’s earth arrows, and get massacred, and I want to minimize my casualties, cuz shamans r kinda cute, and I am a perfectionist (kinda).

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 8:57pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/16 "2021-06-11T20:57:06Z")

</div>

Come on shamans, I won, but not like this, since I actually care about the units I summon.  
![Castle Wars - Learn to Code in Python, JavaScript, HTML \_ CodeCombat - Blisk 6\_11\_2021 3\_55\_03

 ![Castle Wars - Learn to Code in Python, JavaScript, HTML _ CodeCombat - Blisk 6_11_2021 3_58_24 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/0/9/09f996033efe994989905e3248390cdb5be833df.jpeg)

Too many dead. ☹  
Like 6 or 7.

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 9:09pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/17 "2021-06-11T21:09:41Z")

</div>

Also, can you play? It is actually quite fun, and I can tell you are an extremely good coder. I have over 150 lines! The game is very hard to play well.

> **[CodeCombat - Coding games to learn Python and JavaScript](https://codecombat.com/play/ladder/castle-wars)**
>
> Learn typed code through a programming game. Learn Python, JavaScript, and HTML as you solve puzzles and learn to make your own coding games and websites.

---

<div class="post-metadata">

**Author:** ![Hydrobolic](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hydrobolic](https://discourse.codecombat.com/u/Hydrobolic)\
**Post date:** [June 11, 2021, 9:10pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/18 "2021-06-11T21:10:03Z")

</div>

Missile dodging can be hard. I haven’t written a proper bit of code for that in a long time, so I’ll have to experiment.

If you’re messing around with missile dodging, look into manipulating Vectors. One simple method of dodging would be to identify the nearest projectile within a couple meters and step directly away from it. A more complicated method would be to test several different points near your unit and calculate which one is furthest from the line any nearby projectiles take.

[Relevant Level](https://codecombat.com/play/level/skating-away)

---

<div class="post-metadata">

**Author:** ![RangerGrant9307](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/rangergrant9307/32/26001_2.png) [@RangerGrant9307](https://discourse.codecombat.com/u/RangerGrant9307)\
**Post date:** [June 11, 2021, 9:10pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/19 "2021-06-11T21:10:42Z")

</div>

Thank yoyu so much! I will look at it.  
Also, please play when you have time  
Thanks for the help!  
@Hydrobolic

---

<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 11, 2021, 11:29pm UTC](https://discourse.codecombat.com/t/extremely-hard-game/29287/20 "2021-06-11T23:29:31Z")

</div>

@RangerGrant9307 here’s a video I made a while ago with a very rough missile-dodging code

[![](https://img.youtube.com/vi/UUhdqwKsMWw/maxresdefault.jpg "Vicious Discs") ](https://www.youtube.com/watch?v=UUhdqwKsMWw)

[Next page](https://discourse.codecombat.com/t/extremely-hard-game/29287.md?page=2)
