Check out this free technology and STEM game, where students learn programming and python coding in a. CodeCombat: Ogre Encounter. Time to Play. Code Combat is a fantastic and enjoyable way for kids to learn how to code! This web app is basically a game that players control by using easy to learn snippets of code. In this video, we use.
PermalinkGitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up# https://codecombat.com/play/level/protect-and-serve? |
# Защищай рабочих и животных! |
# Обороняй эти две позиции: |
defend= [] |
defend[0] = { 'x': 98, 'y': 28 } |
defend[1] = { 'x': 84, 'y': 7 } |
soldiers= [] |
friends=hero.findFriends() |
forfriendinfriends: |
iffriend.type'soldier': |
soldiers.append(friend) |
else: |
# Обороняй рабочих: |
defend.append(friend) |
whileTrue: |
# Используй цикл `for` для назначения каждому солдату определённой защитной цели |
# Используй `command(soldier, 'defend', thang)` или `command(soldier, 'defend', position)` |
foriinrange(len(soldiers)): |
soldier=soldiers[i] |
self.command(soldier, 'defend', defend[i%len(soldiers)]) |
enemy=hero.findNearestEnemy() |
ifenemy: |
hero.attack(enemy) |
# The warlock used the 'clone' spell and created evil antipodes of our archers.# But even that evil spell has weakness.# If your archer touches his antipode, then it will disappear.# If an archer touches the wrong clone or attacks one of them, then the clones start to fight.# We can find antipodes by their names - they are each other's reverse.# This function check two units whether they are antipodes or not.def areAntipodes( unit1, unit2):reversed1 = 'for i in range( len( unit1. Id) - 1, - 1, - 1):reversed1 += unit1. Id ireturn reversed1 unit2. Idfriends = hero. FindFriendsenemies = hero.
FindEnemies# Find antipodes for each of your archers.# Iterate all friends.for friend in friends:# For each of friends iterate all enemies.for enemy in enemies:# Check if the pair of the current friend and the enemy are antipodes.if areAntipodes( friend, enemy):# If they are antipodes, command the friend move to the enemy.hero. Command( friend, 'move', enemy. Pos)# When all clones disappears, attack the warlock.hero. Happy wheels game.
Wait( 20)enemies = hero. FindEnemieswhile len( enemies) 1:hero. Attack( hero. FindNearestEnemy).Copy lines.Copy permalink.Go.