Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Extremely hard game!

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’]

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.

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

I went in the link wanna play?

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

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

You haven’t updated the starter code yet :slight_smile:

1 Like

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

1 Like

Interesting :slight_smile: 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.

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.

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.

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

Match vs Nick

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

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

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 {
    if ( > this.costOf("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

Simple JS is not that far from simple Python.

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

1 Like

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

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).

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

Too many dead. :frowning:
Like 6 or 7.

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.

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

1 Like

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

1 Like

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

1 Like