python 3<<2的值_Python 3-ValueError int()base必须为> = 2和<= 36 [关闭]

importrandomdefdrawBoard(board):# This function prints out the board that it was passed.# "board" is a list of 29 strings representing the board (ignore index 0)print('|---+---+---+---+---+---+---|')print('| | | | | | | |')print('| '+board[1]+' | '+board[2]+' | '+board[3]+' | '+board[4]+' | '+board[5]+' | '+board[6]+' | '+board[7]+' | ')print('| | | | | | | |')print('|---+---+---+---+---+---+---|')print('| | | | | | | |')print('| '+board[8]+' | '+board[9]+' | '+board[10]+' | '+board[11]+' | '+board[12]+' | '+board[13]+' | '+board[14]+' | ')print('| | | | | | | |')print('|---+---+---+---+---+---+---|')print('| | | | | | | |')print('| '+board[15]+' | '+board[16]+' | '+board[17]+' | '+board[18]+' | '+board[19]+' | '+board[20]+' | '+board[21]+' | ')print('| | | | | | | |')print('|---+---+---+---+---+---+---|')print('| | | | | | | |')print('| '+board[22]+' | '+board[23]+' | '+board[24]+' | '+board[25]+' | '+board[26]+' | '+board[27]+' | '+board[28]+' | ')print('| | | | | | | |')print('|---+---+---+---+---+---+---|')defwhoGoesFirst():ifrandom.randint(0,1)==0:# coin flip 50/50 who starts combatfirstToSpawn=enemy

lastToSpawn=playerelse:firstToSpawn=player

lastToSpawn=enemy# following chunk works out the spawn points of the first to enter#and the last to enter, respectively. It then places them on the#board in their respective spawn points, represented by their symbolwhilefirstToSpawnnotintheBoardandlastToSpawnnotintheBoard:boardSpawn='1 2 3 4 5 6 7 14 21 28 27 26 25 24 23 22 15 8'.split()boardSpawnResult=random.choice(boardSpawn)theBoard[int(boardSpawnResult)]=firstToSpawnprint(firstToSpawn+' has entered the room.')else:iffirstToSpawnintheBoardandlastToSpawnnotintheBoard:boardHalf=len(boardSpawn)/2boardHalf=int(boardHalf)lastToSpawnPosition=int(boardSpawnResult)+boardHalfiflastToSpawnPosition>len(boardSpawn):lastToSpawnPosition=lastToSpawnPosition-len(boardSpawn)lastToSpawnPosition=boardSpawn[lastToSpawnPosition]theBoard[int(lastToSpawnPosition)]=lastToSpawnprint(lastToSpawn+' has entered the room.')iffirstToSpawn==player:playerLocale=int(boardSpawnResult)globalplayerLocaleelse:playerLocale=int(lastToSpawnPosition)globalplayerLocaleprint(drawBoard(theBoard))defshoot():shotChance=int(playerStats[1])-int(gangerStats[3])didItHit=random.randint(int(shotChance),100)ifdidItHit<65:print(playerName+' Missed the shot!')elifdidItHit>=65:didItCrit=random.randint(int(playerStats[5],85))ifdidItCrit>=85:shotDamage=25+weaponsGlockprint('Critical hit! '+shotDamage)else:shotDamage=weaponsGlockprint(playerName+' Hit the enemy for '+shotDamage)gangerStats[0]-shotDamageifgangerStats[0]<1:print(playerName+' killed the Ganger!')#declaring globals and starting the programwhileTrue:theBoard=[' ']*29player=' 'enemy='!'print('What\'s your name, Droog?')playerName=input()player=playerName[0].upper()playerLocale=' 'playerStats='100 50 2 10 5 2'.split()gangerStats='65 20 1 5 3 5'.split()weaponsGlock=30whoGoesFirst()shoot()whileint(gangerStats[0])>0:command=input('Type shoot to attack again:').lowerifcommand=='shoot':shoot()else:ifint(gangerStats[0])<=0:command=input('Type "searchbody" to loot dead enemies:').lower

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值