2017-11-04 Sa OCT codecombat
def hasEnemy():
e = hero.findNearestEnemy()
if e:
return True
else:
return False
def enemyTooClose():
e = hero.findNearestEnemy()
if e:
return hero.distanceTo(e) < 30
else:
return False
def healthTooLow():
return hero.health < 200
def nearestEnemyHook(hook):
if not hook:
return False
e = hero.findNearestEnemy()
if e:
hook(e)
return True
return False
def attackNearestEnemy():
nearestEnemyHook(hero.attack)
def bashNearestEnemy():
nearestEnemyHook(hero.bash)
def attackByType(eType):
t = hero.findNearest([x for x in hero.findEnemies() if x.type == eType])
if t:
hero.attack(t)
return True
else:
return False
def bashByType(eType):
t = hero.findNearest([x for x in hero.findEnemies() if x.type == eType])
if t:
hero.bash(t)
return True
else:
return False
def moveTo(i):
if i:
hero.moveXY(i.pos.x, i.pos.y)
return True
return False
def collectNearestItem():
i = hero.findNearestItem()
if i:
moveTo(i)
return True
return False
def moveToFlag(color):
f = hero.findFlag(color)
if f:
hero.pickUpFlag(f)
return True
return False
def desert_SarvenSiege():
# Defend your towers in this replayable challenge level!
# Step on an X if you have 20 gold to build a soldier.
def attack():
attackNearestEnemy()
def passiveAttack():
f = hero.findFlag("black")
if f:
hero.pickUpFlag(f)
attackNearestEnemy()
return True
return False
def buildSoldier():
pass
while True:
if not move():
attack()
if hero.gold >= 20:
buildSoldier()
def forest_backwoodsBrawl_lv0():
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
while True:
attackNearestEnemy()
def forest_backwoodsBrawl_lv1():
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
while True:
if not attackByType('thrower'):
attackNearestEnemy()
def forest_backwoodsBrawl_lv2():
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
while True:
if not attackByType('thrower'):
attackNearestEnemy()
def forest_backwoodsBrawl_lv3():
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
while True:
attackByType('thrower') or attackByType('orge') or attackNearestEnemy()
# Backwoods Treasure
# Gather gleaming gold from ogre-guarded groves in this player-created replayable level by Kevin Holland.
# It gets harder (and more lucrative) each time you win! But if you lose, you must wait a day to resubmit
#
# Goals
# Collect 100 gold
#
# Collect 100 gold from two or three groves.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
def forest_backwoodsTreasure_lv0():
while True:
attackNearestEnemy() or collectNearestItem()
def forest_backwoodsTreasure_lv1():
while True:
if hasEnemy():
if enemyTooClose() and healthTooLow():
attackNearestEnemy()
continue
collectNearestItem()
# Thoktar's clone army guards the gate to the Cloudrip Mountains.
# equip the 'simple sword' (6 damage) (have to equip one sword), only use bash. so that the cloned one use 'simple sword' too
# painted steel shield, 740 gold, 73.4 damage
def desert_clashofClones_v1():
# You'll need good strategy to win this one!
# Your clone will have the same equipment you have!
# But, they're not very skilled at using special powers.
def ass(e, t):
for i in e:
if i and i.type == t:
if t == 'scout' and hero.distanceTo(i) >= 10:
continue
hero.attack(i)
return True
return False
def has(e, t):
for i in e:
if i.type == t:
return True
return False
def fn(e, t): # find nearest
n = None
nd = 999999999
for i in e:
d = hero.distanceTo(i)
if i.type == t and d < nd:
n = i
nd = d
return (n, nd)
def a():
while True:
e = hero.findEnemies()
# scout first
if has(e, 'scout'):
(sc, scd) = fn(e, 'scout')
if has(e, 'archer'):
(ar, ard) = fn(e, 'archer')
if ard < scd:
hero.attack(ar)
hero.attack(sc)
# if ass(e, 'scout') or ass(e, 'archer'):
# pass
while True:
g = hero.findFlag("green")
if g:
hero.pickUpFlag(g)
continue
v = hero.findFlag("violet")
if v:
hero.pickUpFlag(v)
hero.shield()
b = hero.findFlag("black")
if b:
hero.pickUpFlag(b)
es = hero.findEnemies()
if False:#has(es, 'alejandro'):
(a, ad) = fn(es, 'alejandro')
hero.attack(a)
else:
e = hero.findNearestEnemy()
if e:
if hero.isReady("cleave"):
hero.cleave()
hero.attack(e)
def desert_clashofClones_v2():
while True:
moveToFlag('green') or bashByType('alejandro')
def desert_clashofClones_v3():
while True:
moveToFlag('green') or bashNearestEnemy()
def desert_clashofClones():
desert_clashofClones_v3()
# Sarven Treasure
# Gather 150 gold while evading ogres and running through teleporters. It gets harder (and more lucrative) each time you win! But if you lose, you must wait a day to resubmit.
# #Basic Syntax #Reading the Docs
#
# Goals
# Collect 150 gold
# Survive
#
# Collect 150 gold while evading ogres with teleporters.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
def desert_sarvenTreasure_lv0():
while True:
attackNearestEnemy() or collectNearestItem()
def desert_sarvenTreasure_lv1():
while True:
attackNearestEnemy() or collectNearestItem()
desert_clashofClones()
2017-11-04 Sa OCT codecombat的更多相关文章
- [软件工程基础]2017.11.04 第八次 Scrum 会议
具体事项 项目交接燃尽图 每人工作内容 成员 已完成的工作 计划完成的工作 工作中遇到的困难 游心 #10 搭建可用的开发测试环境:#9 阅读分析 PhyLab 后端代码与文档:#8 掌握 Larav ...
- 2017-11-11 Sa Oct 消参
2017-11-11 Sa Oct 消参 Prior versions: 2017-11-04 Sa Oct 消参 2017-11-10 Fr Oct 消参 2017-11-04 Sa $ P(-3, ...
- 2017-11-11 Sa Oct How to open a browser in Python
2017-11-11 Sa Oct How to open a browser in Python python -m webbrowser "http://www.example.com/ ...
- How to Write and Publish a Scientific Paper: 7th Edition(科技论文写作与发表教程)(11.04更新)
How to Write and Publish a Scientific Paper: 7th Edition(科技论文写作与发表教程)(11.04更新) 重要通知: 最近开题报告已差不多告一段落, ...
- 安装qt5.3.2后,qtcreator在ubuntu 11.04无法启动的问题
在官方网站下载.run文件安装后,qtcreator启动失败,然后找到命令行启动,失败原因如下: shr@shr-Sieyuan:~/Qt5.3.2/Tools/QtCreator/bin$ ./qt ...
- ubuntu 11.04 源 更新不了,全显示ign、404
原文地址:http://blog.csdn.net/enjio/article/details/11603373 ubuntu 11.04 源 更新不了 分类: 开发相关2013-09-12 14 ...
- ubuntu 11.04安装笔记
首先,本文查询了网络中各位大大的经验共享,特别是<UltraISO制作U盘启动Ubuntu 8.10 LiveCD>,地址在http://blog.sina.com.cn/s/blog_5 ...
- 怎么样ubuntu 64 11.04 在执行32位程序
上网一查非常多的信息,头发上的今天ubuntu 64 11.04 在执行32位程序安装ia32-libs包,可执行例如,下面的命令.但提示无法安装 apt-get install ia32-libs ...
- u盘安装ubuntu10.04 、11.04 server
10.04 先将 ubuntu server 的 iso 放到优盘上,然后在提示无法找到光驱时,按 alt+f2 打开一个新的 console 窗口,将 iso mount 上,具体操作如下: ls ...
随机推荐
- python用schedule模块实现定时任务
1 import schedule 2 import time 3 4 def test(): 5 print("I'm working...") 6 def test2(): 7 ...
- CoAP、MQTT、RESTful协议区别
/********************************************************************** * CoAP.MQTT.RESTful协议区别 * 说明 ...
- #20175120彭宇辰 java第五周学习总结
第六章 接口与实现 教材学习内容总结 接口-接口声名interace -接口体1.只有常量声明和抽象方法2.所有常量和方法的访问权限都为public3.常量都为static常量4.可省略pulic\s ...
- 4.python字符串格式化
格式化字符串时,Python使用一个字符串作为模板.模板中有格式符,这些格式符为真实值预留位置,并说明真实数值应该呈现的格式.Python用一个tuple将多个值传递给模板,每个值对应一个格式符.py ...
- angular6新建项目
mkdir angular6project cd angular6project ng new demo 新建一个普通项目 ng new demo --routing 新建一个带路由的项 ...
- 关于C++指针
C++继承于C,对C的语法做了一些扩展.C语言中的指针占一个机器长度(32位处理器上一个指针占32位,64位处理器上安装64位操作系统一个指针占64位),指针的作用就是使用这块内存(4字节或者8字节) ...
- c#获取汉字首字母拼音
/* * 由SharpDevelop创建. * 用户: lenovo * 日期: 2013/10/22 * 时间: 20:15 * * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 */ ...
- 在windows上使用ssh秘钥连接git服务器
git部署在centos7上 安装好git后,新建一个用户test(注意要加入git用户组)配置ssh秘钥登录,我的另一篇博客有写配置步骤 重点的地方是在windows系统上使用秘钥登录git服务器 ...
- BNF
Backus-Naur Form, 巴科斯-诺尔 范式:一种描述高级语言语法的表示法. BNF 符号概览 符号 描述 ::= 该符号左边的元素被该符号右边的结构所定义 *: 该符号前面的结构可以重复零 ...
- [zz]有哪些优秀的科学网站和科研软件推荐给研究生?
https://www.zhihu.com/question/37061410 如题,各位科研前辈,有没有一些好的科研网站或者适合科研人员用的软件以及APP,推荐给一只研一的菜鸡,帮助我们提高科研效率 ...