|
本帖最后由 squall122 于 2012-8-10 11:43 编辑
关于为什么写这个脚本,大家可以看下这个帖子——
http://www.txdx.net/forum.php?mod=viewthread&tid=548881&highlight=%CD%E6%B7%A8
昨天闲来无事,就写了下,今早调试了下,目前应该没啥问题了。源码如下:
- #!/usr/bin/env python
- import random
- import copy
- import os
- #fei.xue.lian.tian.she.bai.lu, xiao.shu.shen.xia.yi.bi.yuan
- #j=justice; e=evil; n=neutral; ee=tian_e & shen_e
- nakama_list=\
- [
- ['hu.fei','fei','j'],['chen.linsu','fei','j'],['tian.guinong','fei','e'],['yan.ji','fei','e'],\
- ['hua.tiegan','lian','n'],['di.yun','lian','j'],\
- ['duan.yu','tian','j'],['xue.muhua','tian','j'],['murong.fu','tian','e'],['a.zi','tian','ee'],['you.tanzhi','tian','ee'],['zhong.lin','tian','n'],['wang.yuyan','tian','n'],['xu.zhu','tian','n'],['yue.laosan','tian','n'],\
- ['guo.jing','she','n'],['huang.rong','she','n'],['mei.chaofeng','she','e'],['chen.yin','she','n'],\
- ['su.quan','lu','n'],['a.ke','lu','n'],\
- ['linhu.chong','xiao','j'],['ren.yinyin','xiao','j'],['lan.fenghuang','xiao','j'],['lin.pinzhi','xiao','e'],['yue.linshan','xiao','e'],['ping.yizhi','xiao','n'],['tian.boguang','xiao','n'],['zu.qianqiu','xiao','n'],\
- ['chen.jialuo','shu','j'],['huo.qintong','shu','j'],['zhang.zhaozhong','shu','e'],\
- ['yang.guo','shen','j'],['xiao.longnv','shen','j'],['huo.du','shen','ee'],['ren.chuzi','shen','n'],\
- ['shi.potian','xia','j'],['bei.haishi','xia','e'],\
- ['zhang.wuji','yi','j'],['xiao.zhao','yi','j'],['zhu.jiuzhen','yi','e'],['song.qinshu','yi','e'],['hu.qinniu','yi','n'],['wang.nangu','yi','n'],\
- ['wen.qinqin','bi','j'],['yuan.chengzhi','bi','j'],['he.tieshou','bi','e'],\
- ['xiao.zhonghui','yuan','j']\
- ]
- tian_shen_ee_list=[['a.zi','tian','ee'],['you.tanzhi','tian','ee'],['huo.du','shen','ee']]
- tian_shen_j_list=[['duan.yu','tian','j'],['xue.muhua','tian','j'],['yang.guo','shen','j'],['xiao.longnv','shen','j']]
- def main():
- cur_num=0
- while cur_num<5:
- cur_num+=1
- i=int(random.randint(0,len(nakama_list)-1))
- cur_nakama=nakama_list[i]
- print cur_nakama[0]
- cur_nakama_book=cur_nakama[1]
- cur_nakama_char=cur_nakama[2]
- nakama_list.remove(cur_nakama)
- if (cur_nakama_char=='ee'):
- for each_tian_shen_nakama in tian_shen_j_list:
- if nakama_list.count(each_tian_shen_nakama)>0:
- nakama_list.remove(each_tian_shen_nakama)
- continue
- elif ((cur_nakama_char=='j') & (cur_nakama_book=='tian')) or ((cur_nakama_char=='j') & (cur_nakama_book=='shen')):
- for each_tian_shen_nakama in tian_shen_ee_list:
- if nakama_list.count(each_tian_shen_nakama)>0:
- nakama_list.remove(each_tian_shen_nakama)
- tmp_nakama_list=copy.deepcopy(nakama_list)
- for s_nakama in tmp_nakama_list:
- if ((s_nakama[1]==cur_nakama_book) & (s_nakama[2]=='e') & (cur_nakama_char=='j')) or ((s_nakama[1]==cur_nakama_book) & (s_nakama[2]=='j') & (cur_nakama_char=='e')):
- #print str(s_nakama)+" should be deleted."
- nakama_list.remove(s_nakama)
- if __name__ == '__main__':
- main()
- os.system("pause")
复制代码
大家直接下载附件吧,解压后里面就是脚本。
然后到python官网下个Python 2.7.3 Windows Installer (Windows binary -- does not include source),安装完就能双击运行这个脚本了。官网的下载网址是——http://www.python.org/getit/
虽然我是用2.7.2版版本写的,不过没啥关系的。
|
|