流枫模拟器:修订间差异
来自 LNN的:not(博客)?
更多操作
小无编辑摘要 |
小无编辑摘要 |
||
| 第53行: | 第53行: | ||
except EOFError: pass | except EOFError: pass | ||
</source> | </source> | ||
[[分类:整活]] | {{DEFAULTSORT:LiuFeng moniqi}}[[分类:整活]] | ||
2021年9月4日 (六) 19:50的版本
流枫-沐珀◆模拟器(交互式,建议用Python IDLE运行)
用Try It Online在线运行(处理输入输出的代码略有改动)
import random
def find(sup, *subs):
for sub in subs:
if sup.find(sub) != -1:
return True
return False
def chance(prob):
return random.random() < prob
def liufengReply(post):
if find(post, "lq", "猎奇", "文游"):
pass
elif find(post, "新人", "萌新") and find(post, "报道", "报到"):
return "欢迎…新人" + random.choice([ "记得", "要", "请" ]) + "看吧规哦…"
else:
reply = None
if find(post, "流枫"):
if find(post, "流枫是") and find(post, "呢", "吗", "?", "?"):
if not find(post, "机器人", "全自动", "AI") and chance(0.4):
reply = "不是"
else:
reply = "是"
if chance(0.5):
reply += "的"
if chance(0.5):
reply += "呢"
elif find(post, "好怪", "怪哦", "怪噢", "怪喔", "对胃口"):
reply = "还好吧"
elif find(post, "什么", "为啥", "怎么做", "呢?", "吗") and chance(0.6):
reply = "不知道呢"
if find(post, "做女生", "做女孩子", "当女孩子") and chance(0.2):
reply += "…不是女孩子"
elif find(post, "有没有"):
reply = "没有"
if chance(0.5):
reply += "呢"
if reply:
if len(reply) > 2 and chance(0.5):
reply = "唔…" + reply
if find(reply, "…") and chance(0.3):
reply += "#(小乖)"
else:
reply += "…"
return reply
try:
while True:
print("< %s" % liufengReply(input("> ")))
print()
except EOFError: pass