Talvieno

Untitled

Jan 18th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.06 KB | None | 0 0
  1. import random
  2. from random import randint
  3. import math
  4.  
  5. toughness = [50.0, 50.0, 50.0, 50.0, 50.0]
  6. friendliness = [50.0, 50.0, 50.0, 50.0, 50.0]
  7. caution = [50.0, 50.0, 50.0, 50.0, 50.0]
  8. diligence = [50.0, 50.0, 50.0, 50.0, 50.0]
  9. ambition = [50.0, 50.0, 50.0, 50.0, 50.0]
  10.  
  11. combat = [0.0, 0.0, 0.0, 0.0, 0.0]
  12. fitness = [50.0, 50.0, 50.0, 50.0, 50.0]
  13. happiness = [50.0, 50.0, 50.0, 50.0, 50.0]
  14. friendship = [[50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0],
  15. [50.0, 50.0, 50.0, 50.0, 50.0]]
  16. debt = [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]]
  17. defense = [0.0, 0.0, 0.0, 0.0, 0.0]
  18. discreetness = [[50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0],
  19. [50.0, 50.0, 50.0, 50.0, 50.0]]
  20. money = [0.0, 0.0, 0.0, 0.0, 0.0]
  21. job = [0.0, 0.0, 0.0, 0.0, 0.0]
  22. popularFame = [0.0, 0.0, 0.0, 0.0, 0.0]
  23. criminalFame = [0.0, 0.0, 0.0, 0.0, 0.0]
  24. crimeLevel = [0.0, 0.0, 0.0, 0.0, 0.0]
  25. connections = [0.0, 0.0, 0.0, 0.0, 0.0]
  26. possessions = [0.0, 0.0, 0.0, 0.0, 0.0]
  27.  
  28. lost = [False, False, False, False, False]
  29. winner = -1
  30.  
  31. lastFiveA = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]
  32. lastFiveB = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]
  33. lastFiveC = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]
  34.  
  35.  
  36. def makePositive():
  37. for i in range(0,5):
  38. combat[i] = max(1,min(100,combat[i]))
  39. fitness[i] = max(1,min(100,fitness[i]))
  40. happiness[i] = max(1,min(100,happiness[i]))
  41. for j in range(0,5):
  42. friendship[i][j] = max(1,min(100,friendship[i][j]))
  43. debt[i][j] = max(1,min(100,debt[i][j]))
  44. discreetness[i][j] = max(1,min(100,discreetness[i][j]))
  45. defense[i] = max(1,min(100,defense[i]))
  46. money[i] = max(1,min(100,money[i]))
  47. job[i] = max(1,min(100,job[i]))
  48. popularFame[i] = max(1,min(100,popularFame[i]))
  49. criminalFame[i] = max(1,min(100,criminalFame[i]))
  50. crimeLevel[i] = max(1,min(100,crimeLevel[i]))
  51. connections[i] = max(1,min(100,connections[i]))
  52. possessions[i] = max(1,min(100,possessions[i]))
  53.  
  54. pops = [[],[],[],[],[]]
  55. def restart():
  56. global toughness
  57. global friendliness
  58. global caution
  59. global diligence
  60. global ambition
  61. global combat
  62. global fitness
  63. global happiness
  64. global friendship
  65. global debt
  66. global defense
  67. global discreetness
  68. global money
  69. global job
  70. global popularFame
  71. global criminalFame
  72. global crimeLevel
  73. global connections
  74. global possessions
  75. global lost
  76. global winner
  77. global lastFiveA
  78. global lastFiveB
  79. global lastFiveC
  80. global pops
  81. pops = [[],[],[],[],[]]
  82. toughness = [50.0, 50.0, 50.0, 50.0, 50.0]
  83. friendliness = [50.0, 50.0, 50.0, 50.0, 50.0]
  84. caution = [50.0, 50.0, 50.0, 50.0, 50.0]
  85. diligence = [50.0, 50.0, 50.0, 50.0, 50.0]
  86. ambition = [50.0, 50.0, 50.0, 50.0, 50.0]
  87.  
  88. combat = [0.0, 0.0, 0.0, 0.0, 0.0]
  89. fitness = [50.0, 50.0, 50.0, 50.0, 50.0]
  90. happiness = [50.0, 50.0, 50.0, 50.0, 50.0]
  91. friendship = [[50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0],
  92. [50.0, 50.0, 50.0, 50.0, 50.0],
  93. [50.0, 50.0, 50.0, 50.0, 50.0]]
  94. debt = [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0],
  95. [0.0, 0.0, 0.0, 0.0, 0.0]]
  96. defense = [0.0, 0.0, 0.0, 0.0, 0.0]
  97. discreetness = [[50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0], [50.0, 50.0, 50.0, 50.0, 50.0],
  98. [50.0, 50.0, 50.0, 50.0, 50.0],
  99. [50.0, 50.0, 50.0, 50.0, 50.0]]
  100. money = [0.0, 0.0, 0.0, 0.0, 0.0]
  101. job = [0.0, 0.0, 0.0, 0.0, 0.0]
  102. popularFame = [0.0, 0.0, 0.0, 0.0, 0.0]
  103. criminalFame = [0.0, 0.0, 0.0, 0.0, 0.0]
  104. crimeLevel = [0.0, 0.0, 0.0, 0.0, 0.0]
  105. connections = [0.0, 0.0, 0.0, 0.0, 0.0]
  106. possessions = [0.0, 0.0, 0.0, 0.0, 0.0]
  107.  
  108. lost = [False, False, False, False, False]
  109. winner = -1
  110.  
  111. lastFiveA = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1],
  112. [-1, -1, -1, -1, -1]]
  113. lastFiveB = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1],
  114. [-1, -1, -1, -1, -1]]
  115. lastFiveC = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1],
  116. [-1, -1, -1, -1, -1]]
  117.  
  118.  
  119. def init():
  120. for i in range (0,5):
  121. toughness[i] = randint(1,100)
  122. friendliness[i] = randint(1,100)
  123. caution[i] = randint(1,100)
  124. diligence[i] = randint(1,100)
  125. ambition[i] = randint(1,100)
  126. okay = False
  127. while okay == False:
  128. okay = True
  129. total = toughness[i] + friendliness[i] + caution[i] + diligence[i] + ambition[i]
  130. ratio = 250 / total
  131. toughness[i] *= ratio
  132. friendliness[i] *= ratio
  133. caution[i] *= ratio
  134. diligence[i] *= ratio
  135. ambition[i] *= ratio
  136. if toughness[i] > 100 or toughness[i] < 1 or friendliness[i] > 100 or friendliness[i] < 1:
  137. okay = False
  138. if caution[i] > 100 or caution[i] < 1 or diligence[i] > 100 or diligence[i] < 1:
  139. okay = False
  140. if ambition[i] > 100 or ambition[i] < 1:
  141. okay = False
  142. toughness[i] = max(min(toughness[i],95),51)
  143. friendliness[i] = max(min(friendliness[i],95),5)
  144. caution[i] = max(min(caution[i],95),5)
  145. diligence[i] = max(min(diligence[i],95),5)
  146. ambition[i] = max(min(ambition[i],95),5)
  147.  
  148.  
  149. lossReason = [0,0,0]
  150. winReason = [0,0,0,0,0,0]
  151. totalTurns = 0
  152. totalTicks = [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  153. [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  154. [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
  155.  
  156.  
  157. def checkForLoss():
  158. for i in range(0, 5):
  159. if (lost[i] == False):
  160. if (crimeLevel[i] > randint(1, 100)): # the cops getcha
  161. lost[i] = True # current level = 2405
  162. lossReason[0] += 1
  163. elif (fitness[i] < 1): # Dead.
  164. lost[i] = True # current level = 804
  165. lossReason[1] += 1
  166. elif (happiness[i] < 1): # suicide.
  167. lost[i] = True # current level = 62
  168. lossReason[2] += 1
  169.  
  170.  
  171. turnMultiplier = 1.0
  172. crimeLevelMultiplier = 1.0
  173. fitnessMultiplier = 1.0
  174. happinessMultiplier = 1.0
  175. popularFameMultiplier = 1.0
  176. criminalFameMultiplier = 1.0
  177. moneyMultiplier = 1.0
  178. friendshipMultiplier = 1.0
  179.  
  180.  
  181. def checkForWin():
  182. global winner
  183. if dead() == 5:
  184. winner=10
  185. for i in range(0, 5):
  186. if (lost[i] == False):
  187. if (popularFame[i] > 100): # won by fame
  188. winner = i # 6
  189. winReason[0] += 1
  190. elif (criminalFame[i] > 100): # won by criminal fame
  191. winner = i # 16
  192. winReason[1] += 1
  193. elif (money[i] > 100): # won by cash
  194. winner = i # 20
  195. winReason[2] += 1
  196. elif (job[i] > 100): # won by CEO
  197. winner = i # 6
  198. winReason[3] += 1
  199. elif dead() == 4: # 51
  200. winner = i
  201. winReason[4] += 1
  202. elif friends(i) == 4:
  203. winner = i # 0
  204. winReason[5] += 1
  205.  
  206. def friends(i):
  207. count = 0
  208. for j in range (0,5):
  209. if friendship[j][i] > 95 and i != j:
  210. count+= 1
  211. return count
  212.  
  213. def dead():
  214. count = 0
  215. for i in range(0,5):
  216. if lost[i] == True:
  217. count += 1
  218. return count
  219.  
  220.  
  221.  
  222.  
  223. # ACTION VS: Results posted in the main chat and seen by all. Can happen completely on their own, but may be chosen.
  224. # ACTION VS: attacks carry with them a risk of failure, but can have big impacts if successful
  225. # ACTION VS: helping always succeeds, but with slightly less outcome
  226. # ACTION VS: These all have dynamic values that change based on the people
  227. # ACTION WITH: Results MAY be posted in the main chat. Must be chosen and confirmed by both parties to occur.
  228. # ACTION WITH: challenges have a positive effect for one member, and a negative effect for another member.
  229. # ACTION WITH: helping actions have positive effects for both parties involved, but do not have as big of impacts
  230. # ACTION WITH: These all have dynamic values that change based on the people
  231. # ACTION SELF: Results posted privately. Only you know these changes and their results unless you repeat them yourself
  232. # ACTION SELF: all actions positive and typically boost stats.
  233. # ACTION SELF: Everyone MUST get at least one ACTION SELF per turn, and also either one VS or WITH
  234. # ACTION EVENT: Happens once every three turns. Each player gets an "event" that happens, and must choose how to
  235. # resolve it. Events may be positive or negative, and the outcome may vary based on your choice of how to resolve it.
  236. # Events can also potentially involve other people, and can potentially let you change your stats in small amounts
  237. # PEOPLE THAT CHOOSE TO WATCH THE GAME BUT NOT PLAY: these people get to see everything that goes on, but only via PM
  238.  
  239. def lastFive(a,index,player):
  240. if a == 0:
  241. for i in range (0,5):
  242. if lastFiveA[player][i] == index:
  243. return True
  244. elif a == 1:
  245. for i in range (0,5):
  246. if lastFiveB[player][i] == index:
  247. return True
  248. elif a == 2:
  249. for i in range (0,5):
  250. if lastFiveC[player][i] == index:
  251. return True
  252. return False
  253.  
  254.  
  255. def turn():
  256. actions()
  257. checkForLoss()
  258. checkForWin()
  259. if winner != -1:
  260. print("winner: " + str(winner))
  261.  
  262. def actions():
  263. for i in range(0, 5): # for each player
  264. if lost[i] == False:
  265. makePositive()
  266. if i > -1:
  267. # first, do an actionSelf
  268. likelyS = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  269. likelyS[0] += toughness[i] + randint(-50, 50)
  270. likelyS[1] += toughness[i] * randint(-50, 50)
  271. likelyS[2] += friendliness[i] + randint(-50, 50)
  272. likelyS[3] += friendliness[i] + randint(-50, 50)
  273. likelyS[4] += caution[i] + randint(-50, 50)
  274. likelyS[5] += caution[i] + randint(-50, 50)
  275. likelyS[6] += diligence[i] + randint(-50, 50)
  276. likelyS[7] += diligence[i] + randint(-50, 50)
  277. likelyS[8] += ambition[i] + randint(-50, 50)
  278. likelyS[9] += ambition[i] + randint(-50, 50)
  279. likelyS[10] += ambition[i] + randint(-50, 50)
  280. likelyS[11] += ambition[i] + randint(-50, 50)
  281. likelyS[12] += diligence[i] + randint(-50, 50)
  282. tops = -100
  283. topIndex = 0
  284. for j in range(0, 13):
  285. if likelyS[j] > tops and lastFive(0, j, i) == False and canExecute(2, j, i, 0):
  286. topIndex = j
  287. tops = likelyS[j]
  288. actionSelf(topIndex, i)
  289. # next, do an actionVS OR an actionWith
  290.  
  291. makePositive()
  292. if randint(0, 1) == 0:
  293. likelyS = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  294. likelyS[0] += ((101 - friendliness[i]) + toughness[i]) + randint(-100, 100)
  295. likelyS[1] += ((101 - friendliness[i]) + caution[i]) * randint(-100, 100)
  296. likelyS[2] += ((101 - friendliness[i]) + diligence[i]) + randint(-100, 100)
  297. likelyS[3] += ((101 - friendliness[i]) + diligence[i]) + randint(-100, 100)
  298. likelyS[4] += ((101 - friendliness[i]) + ambition[i]) + randint(-100, 100)
  299. likelyS[5] += (friendliness[i] + toughness[i]) + randint(-100, 100)
  300. likelyS[6] += friendliness[i] + randint(-50, 50)
  301. likelyS[7] += (friendliness[i] + caution[i]) + randint(-50, 50)
  302. likelyS[8] += (friendliness[i] + caution[i]) + randint(-50, 50)
  303. likelyS[9] += (friendliness[i] + diligence[i]) + randint(-50, 50)
  304. likelyS[10] += (friendliness[i] + diligence[i]) + randint(-50, 50)
  305. likelyS[11] += (friendliness[i] + ambition[i]) + randint(-50, 50)
  306. likelyS[12] += ((101 - friendliness[i]) + ambition[i]) + randint(-50, 50)
  307. tops = -100
  308. topIndex = 0
  309. k = i
  310. for j in range(0, 13):
  311. while k == i or lost[k] == True:
  312. k = randint(0, 4)
  313. if likelyS[j] > tops and lastFive(1, j, i) == False and canExecute(2, j, i, k):
  314. topIndex = j
  315. tops = likelyS[j]
  316. actionVS(topIndex, i, k)
  317. else:
  318. likelyS = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  319. likelyS[0] += toughness[i] + randint(-50, 50)
  320. likelyS[1] += toughness[i] + randint(-50, 50)
  321. likelyS[2] += toughness[i] + randint(-50, 50)
  322. likelyS[3] += toughness[i] + randint(-50, 50)
  323. likelyS[4] += friendliness[i] + randint(-50, 50)
  324. likelyS[5] += friendliness[i] + randint(-50, 50)
  325. likelyS[6] += friendliness[i] + randint(-50, 50)
  326. likelyS[7] += friendliness[i] + randint(-50, 50)
  327. likelyS[8] += friendliness[i] + randint(-50, 50)
  328. likelyS[9] += caution[i] + randint(-50, 50)
  329. likelyS[10] += caution[i] + randint(-50, 50)
  330. likelyS[11] += caution[i] + randint(-50, 50)
  331. likelyS[12] += diligence[i] + randint(-50, 50)
  332. likelyS[13] += diligence[i] + randint(-50, 50)
  333. likelyS[14] += diligence[i] + randint(-50, 50)
  334. likelyS[15] += ambition[i] + randint(-50, 50)
  335. likelyS[16] += ambition[i] + randint(-50, 50)
  336. likelyS[17] += ambition[i] + randint(-50, 50)
  337. tops = -100
  338. topIndex = 0
  339. k = i
  340. for j in range(0, 18):
  341. while k == i or lost[k] == True:
  342. k = randint(0, 4)
  343. if likelyS[j] > tops and lastFive(2, j, i) == False and canExecute(2, j, i, k):
  344. if randint(0, 1) == 1:
  345. topIndex = j
  346. tops = likelyS[j]
  347. actionWith(topIndex, i, k)
  348.  
  349. def canExecute(a,index,p1,p2):
  350. if a == 0:
  351. if index == 6:
  352. if job[p1] > 1:
  353. return True
  354. elif index == 8 or index == 10:
  355. if connections[p1] > 1:
  356. return True
  357. elif index == 12:
  358. if money[p1] > 20:
  359. return True
  360. else:
  361. return True
  362. elif a == 1:
  363. if index == 0:
  364. if happiness[p1] > 10 and fitness[p1] > 10 and randint(1,100) > friendship[p1][p2]:
  365. return True
  366. elif index == 1:
  367. if happiness[p1] > 10 and randint(1,100) > friendship[p1][p2]:
  368. return True
  369. elif index == 2 or index == 3:
  370. if happiness[p1] > 10 and job[p2] > 10 and popularFame[p1] > 10 and randint(1,100) > friendship[p1][p2]:
  371. return True
  372. elif index == 4:
  373. if popularFame[p1] > 10 and happiness[p1] > 10 and connections[p1] > 10 and randint(1,100) > friendship[p1][p2]:
  374. return True
  375. elif index == 5:
  376. if fitness[p2] < 100:
  377. return True
  378. elif index == 6:
  379. if money[p1] > 20:
  380. return True
  381. elif index == 9 or index == 11:
  382. if popularFame[p1] > 10:
  383. return True
  384. elif index == 10:
  385. if debt[p1] > 0 and money[p1] > 10:
  386. return True
  387. elif index == 12:
  388. if popularFame[p1] > 10 and happiness[p1] > 10 and randint(1,100) > friendship[p1][p2]:
  389. return True
  390. else:
  391. return True
  392. elif a == 2:
  393. if index == 1:
  394. if fitness[p1] < 100:
  395. return True
  396. elif index == 2:
  397. if fitness[p1] > 10:
  398. return True
  399. elif index == 4:
  400. if happiness[p1] < 100:
  401. return True
  402. elif index == 5:
  403. if money[p1] > 10 and money[p2] > 10:
  404. return True
  405. elif index == 6:
  406. if happiness[p1] > 10:
  407. return True
  408. elif index == 12:
  409. if money[p1] > 20:
  410. return True
  411. elif index == 13:
  412. if money[p1] > 10 and money[p2] > 10:
  413. return True
  414. elif index == 15:
  415. if criminalFame[p1] > 20:
  416. return True
  417. elif index == 16:
  418. if happiness[p1] > 10 and popularFame[p1] > 10 and money[p1] > 10:
  419. return True
  420. elif index == 17:
  421. if connections[p1] > 10:
  422. return True
  423. else:
  424. return True
  425. return False
  426.  
  427.  
  428. def actionVS(index, p1, p2):
  429. # negative actions
  430. if math.sqrt(randint(1, 100) * diligence[p1]) > (discreetness[p2][p1] / 2):
  431. if (defense[p2] / 2) < math.sqrt(randint(1, 100) * caution[p1]):
  432. if index == 0: # fight
  433. pops[p1].append("1 " + str(index))
  434. combatDiff = ((combat[p1] - combat[p2]) * random.uniform(0.8, 1.25)) / 2.5
  435. amount = math.sqrt((101 -friendliness[p1]) * toughness[p1]) / 5
  436. friendship[p1][p2] -= (amount / 2)
  437. friendship[p2][p1] -= (amount / 2)
  438. if combatDiff > 10:
  439. fitness[p2] -= combatDiff
  440. happiness[p1] += (combatDiff / 2)
  441. elif combatDiff > -10:
  442. happiness[p1] -= (amount / 2)
  443. happiness[p2] -= (amount / 2)
  444. else:
  445. fitness[p1] -= combatDiff
  446. happiness[p2] += (combatDiff / 4)
  447. elif index == 1: # prank
  448. pops[p1].append("1 " + str(index))
  449. intelligenceDiff = (((ambition[p1]) - ambition[p2]) * random.uniform(0.8, 1.25)) / 2.5
  450. amount = math.sqrt((101 - friendliness[p1]) * caution[p1]) / 5
  451. friendship[p2][p1] -= (amount / 2)
  452. if intelligenceDiff > 10:
  453. happiness[p2] -= (intelligenceDiff / 2)
  454. happiness[p1] += (intelligenceDiff / 4)
  455. elif intelligenceDiff > -10:
  456. happiness[p1] -= (amount / 2)
  457. happiness[p2] -= (amount / 2)
  458. else:
  459. happiness[p1] -= (intelligenceDiff / 2)
  460. happiness[p2] += (intelligenceDiff / 8)
  461. elif index == 2: # get someone demoted
  462. pops[p1].append("1 " + str(index))
  463. amount = math.sqrt((101 - friendliness[p1]) * diligence[p1]) / 5
  464. successChance = (((popularFame[p1]) - popularFame[p2]) * random.uniform(0.8, 1.25)) / 2.5
  465. friendship[p1][p2] -= (amount / 2)
  466. friendship[p2][p1] -= (amount / 2)
  467. if successChance > 10:
  468. happiness[p2] -= (amount / 2)
  469. job[p2] -= amount
  470. elif successChance > -10:
  471. happiness[p2] -= (amount / 4)
  472. happiness[p1] -= (amount / 4)
  473. else: # get in trouble for causing problems
  474. happiness[p1] -= (amount / 2)
  475. crimeLevel[p1] += (amount / 4)
  476. elif index == 3: # steal someone's job, business rivalry, etc
  477. pops[p1].append("1 " + str(index))
  478. successChance = (((popularFame[p1]) - popularFame[p2]) * random.uniform(0.8, 1.25)) / 2.5
  479. amount = math.sqrt((101 - friendliness[p1]) * ambition[p1]) / 5
  480. friendship[p1][p2] -= (amount / 2)
  481. friendship[p2][p1] -= (amount / 2)
  482. if successChance > 10:
  483. happiness[p2] -= (amount / 2)
  484. job[p2] -= (amount / 2)
  485. job[p1] += (amount / 2)
  486. elif successChance > -10:
  487. happiness[p1] -= (amount / 4)
  488. happiness[p2] -= (amount / 4)
  489. else:
  490. discreetness[p2][p1] += amount
  491. happiness[p2] -= (amount / 2)
  492. elif index == 4: # say something negative about them on TV
  493. pops[p1].append("1 " + str(index))
  494. successChance = (((popularFame[p1]) - popularFame[p2]) * random.uniform(0.8, 1.25)) / 2.5
  495. amount = (101 -friendliness[p1]) / 5
  496. friendship[p1][p2] -= (amount / 2)
  497. friendship[p2][p1] -= (amount / 2)
  498. if successChance > 10:
  499. popularFame[p2] -= amount
  500. criminalFame[p2] -= (amount * 2)
  501. connections[p2] -= amount
  502. happiness[p2] -= (amount / 2)
  503. elif successChance > -10:
  504. happiness[p1] -= (amount / 4)
  505. happiness[p2] -= (amount / 4)
  506. else:
  507. popularFame[p1] -= amount
  508. criminalFame[p1] -= amount
  509. connections[p1] -= amount
  510. happiness[p1] -= (amount / 2)
  511. elif index == 12: # try to frame someone
  512. pops[p1].append("1 " + str(index))
  513. amount = math.sqrt(toughness[p1] * popularFame[p1]) / 5
  514. rnd = math.sqrt(randint(1, 100) * popularFame[p2])
  515. if rnd > criminalFame[p1]: # successfully framed them
  516. happiness[p2] -= (amount / 2)
  517. friendship[p1][p2] -= (amount / 2)
  518. friendship[p2][p1] -= (amount / 2)
  519. crimeLevel[p2] += amount
  520. elif rnd > criminalFame[p1] / 2: # the cops didn't quite buy it
  521. happiness[p2] -= (amount / 8)
  522. friendship[p1][p2] -= (amount / 8)
  523. friendship[p2][p1] -= (amount / 8)
  524. crimeLevel[p2] += amount / 4
  525. else: # the cops think you're up to something
  526. happiness[p1] -= (amount / 4)
  527. crimeLevel[p1] += amount / 2
  528. # positive or neutral actions
  529. if index == 5: # heal
  530. pops[p1].append("1 " + str(index))
  531. amount = math.sqrt(fitness[p1] * friendliness[p1]) / 5
  532. friendship[p1][p2] += (amount / 2)
  533. friendship[p2][p1] += (amount / 2)
  534. fitness[p2] += amount
  535. elif index == 6: # gift money
  536. pops[p1].append("1 " + str(index))
  537. friendship[p1][p2] += friendliness[p1] / 2.5
  538. friendship[p2][p1] += friendliness[p1] / 2.5
  539. money[p1] -= friendliness[p1] / 2.5
  540. money[p2] += friendliness[p1] / 2.5
  541. elif index == 7: # targeted discreetness, tricking someone into not knowing where you are
  542. pops[p1].append("1 " + str(index))
  543. amount = math.sqrt(caution[p1] * (101 -friendliness[p1])) / 5
  544. discreetness[p1][p2] += amount
  545. elif index == 8: # figure out where someone lives
  546. pops[p1].append("1 " + str(index))
  547. amount = math.sqrt(ambition[p1] * diligence[p1]) / 5
  548. discreetness[p2][p1] -= amount
  549. elif index == 9: # get someone promoted
  550. pops[p1].append("1 " + str(index))
  551. amount = math.sqrt(friendliness[p1] * popularFame[p1]) / 5
  552. friendship[p1][p2] += (amount / 2)
  553. friendship[p2][p1] += (amount / 2)
  554. happiness[p2] += (amount / 2)
  555. job[p2] += amount
  556. elif index == 10: # paying someone back, ONLY if you owe something
  557. pops[p1].append("1 " + str(index))
  558. happiness[p2] += (min(debt[p1][p2], money[p1]) / 2)
  559. friendship[p2][p1] += (min(debt[p1][p2], money[p1]) / 2)
  560. money[p2] += min(debt[p1][p2], money[p1])
  561. money[p1] -= min(debt[p1][p2], money[p1])
  562. debt[p1][p2] -= min(debt[p1][p2], money[p1])
  563. elif index == 11: # saying something positive about them on TV
  564. pops[p1].append("1 " + str(index))
  565. amount = math.sqrt(friendliness[p1] * popularFame[p1]) / 5
  566. friendship[p1][p2] += (amount / 2)
  567. friendship[p2][p1] += (amount / 2)
  568. happiness[p2] += (amount / 2)
  569. popularFame[p2] += amount
  570. criminalFame[p2] += amount
  571. connections[p2] += amount
  572.  
  573.  
  574. def actionWith(index, p1, p2):
  575. if willParticipate(index, p1, p2):
  576. if index == 0: # training for combat together
  577. pops[p1].append("2 " + str(index))
  578. combat[p1] += 10
  579. combat[p2] += 10
  580. friendship[p1][p2] += 5
  581. friendship[p2][p1] += 5
  582. elif index == 1: # training fitness together
  583. pops[p1].append("2 " + str(index))
  584. fitness[p1] += 10
  585. fitness[p2] += 10
  586. friendship[p1][p2] += 5
  587. friendship[p2][p1] += 5
  588. elif index == 2: # duel together
  589. pops[p1].append("2 " + str(index))
  590. if math.sqrt(toughness[p1] * combat[p1]) > math.sqrt(toughness[p2] * combat[p2]):
  591. fitness[p2] = 0
  592. fitness[p1] = fitness[p1] - ((fitness[p1] / 100) * combat[p2])
  593. else:
  594. fitness[p1] = 0
  595. fitness[p2] = fitness[p2] - ((fitness[p2] / 100) * combat[p1])
  596. elif index == 3: # armwrestle/other cheap combat
  597. pops[p1].append("2 " + str(index))
  598. if math.sqrt(toughness[p1] * fitness[p1]) > math.sqrt(toughness[p2] * fitness[p2]):
  599. happiness[p1] += 5
  600. money[p1] += 10
  601. else:
  602. happiness[p2] += 5
  603. money[p2] += 10
  604. elif index == 4: # have fun together
  605. pops[p1].append("2 " + str(index))
  606. friendship[p1][p2] += 10
  607. friendship[p2][p1] += 10
  608. happiness[p1] += 10
  609. happiness[p1] += 10
  610. elif index == 5: # friendly competition
  611. pops[p1].append("2 " + str(index))
  612. friendship[p1][p2] += 5
  613. friendship[p2][p1] += 5
  614. if math.sqrt(diligence[p1] * caution[p1]) > math.sqrt(diligence[p2] * caution[p2]):
  615. happiness[p1] += 5
  616. money[p2] -= 5
  617. money[p1] += 5
  618. else:
  619. happiness[p2] += 5
  620. money[p1] -= 5
  621. money[p2] += 5
  622. elif index == 6: # debate with each other
  623. pops[p1].append("2 " + str(index))
  624. outcome = abs(toughness[p1] - toughness[p2]) + abs(diligence[p1] - diligence[p2]) + abs(ambition[p1] - ambition[p2])
  625. outcome = outcome / 3
  626. if outcome < 33:
  627. friendship[p1][p2] += 5
  628. friendship[p2][p1] += 5
  629. happiness[p2] += 5
  630. happiness[p1] += 5
  631. elif outcome < 67:
  632. friendship[p1][p2] += 5
  633. friendship[p2][p1] += 5
  634. else:
  635. friendship[p1][p2] -= 5
  636. friendship[p2][p1] -= 5
  637. happiness[p2] -= 5
  638. happiness[p1] -= 5
  639. elif index == 7: # have a long friendly talk
  640. pops[p1].append("2 " + str(index))
  641. friendship[p1][p2] += 10
  642. friendship[p2][p1] += 10
  643. elif index == 8: # have a long unfriendly talk
  644. pops[p1].append("2 " + str(index))
  645. friendship[p1][p2] -= 10
  646. friendship[p2][p1] -= 10
  647. elif index == 9: # trade stealth tips
  648. pops[p1].append("2 " + str(index))
  649. friendship[p1][p2] += 5
  650. friendship[p2][p1] += 5
  651. discreetness[p1][0] += 2.5
  652. discreetness[p1][1] += 2.5
  653. discreetness[p1][2] += 2.5
  654. discreetness[p1][3] += 2.5
  655. discreetness[p1][4] += 2.5
  656. discreetness[p2][0] += 2.5
  657. discreetness[p2][1] += 2.5
  658. discreetness[p2][2] += 2.5
  659. discreetness[p2][3] += 2.5
  660. discreetness[p2][4] += 2.5
  661. elif index == 10: # trade stealth tips
  662. pops[p1].append("2 " + str(index))
  663. friendship[p1][p2] += 5
  664. friendship[p2][p1] += 5
  665. defense[p1] += 10
  666. defense[p2] += 10
  667. elif index == 11: # remove stealth from each other
  668. pops[p1].append("2 " + str(index))
  669. friendship[p1][p2] += 5
  670. friendship[p2][p1] += 5
  671. discreetness[p1][p2] -= 10
  672. discreetness[p2][p1] -= 10
  673. elif index == 12: #lend them money so they owe you
  674. pops[p1].append("2 " + str(index))
  675. friendship[p2][p1] += 5
  676. debt[p2][p1] += 20
  677. money[p2] += 20
  678. money[p1]-= 20
  679. elif index == 13: # random function: betting
  680. pops[p1].append("2 " + str(index))
  681. if randint(1, 2) == 1:
  682. money[p2] += 10
  683. money[p1] -= 10
  684. else:
  685. money[p1] += 10
  686. money[p2] -= 10
  687. elif index == 14: # give job tips
  688. pops[p1].append("2 " + str(index))
  689. friendship[p1][p2] += 5
  690. friendship[p2][p1] += 5
  691. job[p1] += 10
  692. job[p2] += 10
  693. elif index == 15: #try to pull off a heist
  694. pops[p1].append("2 " + str(index))
  695. successChance = math.sqrt(connections[p1] + connections[p2])
  696. amount = math.sqrt(caution[p1] * caution[p2])
  697. if successChance > 67:
  698. money[p1] += 5
  699. money[p2] += 5
  700. crimeLevel[p1] += 5
  701. crimeLevel[p2] += 5
  702. criminalFame[p1] += connections[p1]
  703. criminalFame[p2] += connections[p2]
  704. elif successChance > 33:
  705. friendship[p1][p2] -= 5
  706. friendship[p2][p1] -= 5
  707. discreetness[p2][p1] += 2.5
  708. discreetness[p1][p2] += 2.5
  709. else:
  710. friendship[p1][p2] -= 5
  711. friendship[p2][p1] -= 5
  712. crimeLevel[p1] += 10
  713. crimeLevel[p2] += 10
  714. criminalFame[p1] -= connections[p2] / 2
  715. criminalFame[p2] -= connections[p1] / 2
  716. elif index == 16: # be famous together
  717. pops[p1].append("2 " + str(index))
  718. successChance = math.sqrt(connections[p1] + connections[p2])
  719. amount = math.sqrt(diligence[p1] * diligence[p2])
  720. if successChance > 67:
  721. popularFame[p1] += connections[p1] / 2
  722. popularFame[p2] += connections[p2] / 2
  723. friendship[p1][p2] += 5
  724. friendship[p2][p1] += 5
  725. elif successChance > 33:
  726. money[p1] -= 10
  727. money[p2] -= 10
  728. happiness[p1] -= 5
  729. happiness[p2] -= 5
  730. else:
  731. friendship[p1][p2] -= 5
  732. friendship[p2][p1] -= 5
  733. happiness[p1] -= 5
  734. happiness[p2] -= 5
  735. popularFame[p1] -= connections[p2] / 4
  736. popularFame[p2] -= connections[p1] / 4
  737. elif index == 17: # make each other famous
  738. pops[p1].append("2 " + str(index))
  739. popularFame[p1] += connections[p2] / 2
  740. popularFame[p2] += connections[p1] / 2
  741. friendship[p1][p2] += 5
  742. friendship[p2][p1] += 5
  743.  
  744.  
  745.  
  746.  
  747. def willParticipate(index, p1, p2):
  748. willDo = True
  749. return willDo
  750.  
  751.  
  752. def actionSelf(index, p1):
  753. if index == 0: # learnmartial
  754. pops[p1].append("0 " + str(index))
  755. combat[p1] += 20
  756. elif index == 1: # train
  757. pops[p1].append("0 " + str(index))
  758. fitness[p1] += 20
  759. elif index == 2: # try to make self happy
  760. pops[p1].append("0 " + str(index))
  761. happiness[p1] += 20
  762. elif index == 3: # try to make friends
  763. pops[p1].append("0 " + str(index))
  764. friendship[p1][0] += 5
  765. friendship[p1][1] += 5
  766. friendship[p1][2] += 5
  767. friendship[p1][3] += 5
  768. friendship[p1][4] += 5
  769. friendship[0][p1] += 5
  770. friendship[1][p1] += 5
  771. friendship[2][p1] += 5
  772. friendship[3][p1] += 5
  773. friendship[4][p1] += 5
  774. elif index == 4: # defenses
  775. pops[p1].append("0 " + str(index))
  776. defense[p1] += 20
  777. elif index == 5: # discreetness
  778. pops[p1].append("0 " + str(index))
  779. discreetness[p1][0] += 5
  780. discreetness[p1][1] += 5
  781. discreetness[p1][2] += 5
  782. discreetness[p1][3] += 5
  783. discreetness[p1][4] += 5
  784. elif index == 6: # work
  785. pops[p1].append("0 " + str(index))
  786. money[p1] += job[p1]
  787. elif index == 7: # promotion
  788. pops[p1].append("0 " + str(index))
  789. job[p1] += 20
  790. elif index == 8: # criminal activities
  791. pops[p1].append("0 " + str(index))
  792. criminalFame[p1] += (connections[p1] * 2)
  793. crimeLevel[p1] += 10
  794. elif index == 9: # hide from cops, ONLY if you have a positive crime level
  795. pops[p1].append("0 " + str(index))
  796. crimeLevel[p1] -= 20
  797. elif index == 10: # charity
  798. pops[p1].append("0 " + str(index))
  799. popularFame[p1] += connections[p1]
  800. elif index == 11: # connections
  801. pops[p1].append("0 " + str(index))
  802. connections[p1] += 20
  803. elif index == 12: # buy something for self ONLY IF YOU HAVE THE MONEY
  804. pops[p1].append("0 " + str(index))
  805. money[p1] -= 20
  806. happiness[p1] += 20
  807. possessions[p1] += 1
  808.  
  809. init()
  810. loops = 0
  811. while loops < 100:
  812. loops += 1
  813. restart()
  814. while winner == -1:
  815. turn()
  816. totalTurns += 1
  817. if winner < 6:
  818. for i in range(0,pops.__len__()):
  819. temp = pops[winner][i]
  820. totalTicks[int(temp.split()[0])][int((temp.split())[1])] += 1
  821.  
  822.  
  823. print(totalTicks)
  824. print(lossReason)
  825. print(winReason)
  826. print(totalTurns)
  827.  
  828. # [[11.0, 140.0, 17.0, 21.0, 23.0, 0.0, 12.0, 9.0, 11.0, 14.0, 15.0, 20.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  829. # [6.0, 45.0, 3.0, 18.0, 5.0, 0.0, 0.0, 2.0, 3.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
  830. # [6.0, 10.0, 8.0, 5.0, 10.0, 0.0, 7.0, 14.0, 8.0, 12.0, 10.0, 9.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0]]
  831. # [220, 96, 8]
  832. # [10, 10, 16, 5, 55, 1]
  833. # 1959
Advertisement
Add Comment
Please, Sign In to add comment