Advertisement
Guest User

dsf

a guest
Nov 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. import adjudicator
  2. import constants
  3.  
  4. class Debug_Dice:
  5. def __init__(self):
  6.  
  7. self.value_list = [[4,5]]
  8.  
  9. self.die_1 = None
  10. self.die_2 = None
  11. self.double = False
  12. self.double_counter = 0
  13.  
  14. def roll(self,ignore=False):
  15.  
  16. if len(self.value_list)!=0:
  17. [self.die_1,self.die_2] = self.value_list.pop()
  18.  
  19. self.double = self.die_1 == self.die_2
  20. if not ignore:
  21. self.double_counter += self.double
  22.  
  23. print('Roll a {die_1} and a {die_2}'.format(die_1=self.die_1, die_2=self.die_2))
  24.  
  25. class Agent_1:
  26. def __init__(self, id):
  27. self.id = id
  28.  
  29. def getBMSTDecision(self, state):
  30. return None
  31.  
  32. def buyProperty(self, state):
  33. return False
  34.  
  35. def auctionProperty(self, state):
  36. return 180
  37.  
  38. def receiveState(self, state):
  39. pass
  40.  
  41. class Agent_2:
  42. def __init__(self, id):
  43. self.id = id
  44. self.PLAYER_TURN_INDEX = 0
  45. self.PROPERTY_STATUS_INDEX = 1
  46. self.PLAYER_POSITION_INDEX = 2
  47. self.PLAYER_CASH_INDEX = 3
  48. self.PHASE_NUMBER_INDEX = 4
  49. self.PHASE_PAYLOAD_INDEX = 5
  50.  
  51. self.ST_CHARLES = 11
  52. self.STATES_AVENUE = 13
  53.  
  54. def getBMSTDecision(self, state):
  55.  
  56. stcharles = constants.space_to_property_map[self.ST_CHARLES]
  57. states_avenue = constants.space_to_property_map[self.STATES_AVENUE]
  58.  
  59. stcharles_propertyValue = state[self.PROPERTY_STATUS_INDEX][stcharles]
  60. states_avenue_propertyValue = state[self.PROPERTY_STATUS_INDEX][states_avenue]
  61.  
  62. payload = state[self.PHASE_PAYLOAD_INDEX]
  63.  
  64. if (stcharles_propertyValue != -2) and (states_avenue_propertyValue != -3):
  65. return ("B", [(13,1),(11,1)])
  66.  
  67. return None
  68.  
  69. def buyProperty(self, state):
  70. return False
  71.  
  72. def auctionProperty(self, state):
  73. return 200
  74.  
  75. def receiveState(self, state):
  76. pass
  77.  
  78. def compare_states(state1,state2):
  79.  
  80. if not isinstance(state1,type(state2)) or (len(state1)!=len(state2)):
  81. print("Inconsistent type or length detected for First argument")
  82. return false
  83. else:
  84. count = 0
  85.  
  86. if (state1[0] == state2[0]): count+=1
  87.  
  88. flag = True
  89. for property,property2 in zip(state1[1],state2[1]):
  90. if property != property2:
  91. flag = False
  92. if flag: count+=1
  93.  
  94. if (state1[2][0] == state2[2][0]) and (state1[2][1] == state2[2][1]): count+=1
  95. if (state1[3][0] == state2[3][0]) and (state1[3][1] == state2[3][1]): count+=1
  96. if (state1[4] == state2[4]): count+=1
  97.  
  98. if len(state1[5]) == len(state2[5]):
  99. flag = True
  100. for key,key2 in zip(state1[5],state2[5]):
  101. if state1[5][key] != state2[5][key]:
  102. flag = False
  103. if flag: count+=1
  104.  
  105. if count == 6:
  106. return True
  107. else:
  108. print( str(count)+"/"+str(len(state2))+" arguments are correct." )
  109. return False
  110.  
  111. def testcase_4(Adjudicator,AgentOne,AgentTwo):
  112. print("Test #4 Description:")
  113. print("AgentTwo will fall on Jail(Just Visting)(Position 10).")
  114. print("He wants to buy one house each on St. Charles Place(Position 11) and States Avenue(Position 13).")
  115.  
  116. input_state = [11, [ 0, 1, 0, 1, 0, 0, -1, 0, -2, -2, 1, 0, 0, 0, -1, 0, 0,
  117. 0, 1, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0], [3, 1], [580, 350], 4, {}]
  118.  
  119. output_state = [12, [ 0, 1, 0, 1, 0, 0, -2, 0, -3, -2, 1, 0, 0, 0, -1, 0, 0,
  120. 0, 1, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0], [3, 10], [580, 150], 0, {}]
  121.  
  122.  
  123. no_of_turns = 12
  124.  
  125. adjudicator = Adjudicator(AgentOne,AgentTwo,input_state,Debug_Dice,no_of_turns)
  126. adjudicator.runGame()
  127.  
  128. final_state = adjudicator.state
  129.  
  130. result = compare_states(final_state,output_state)
  131.  
  132. if result: print("Pass")
  133. else:
  134. print("Fail")
  135. print("Received Output:")
  136. print(final_state)
  137.  
  138. print("")
  139.  
  140. return result
  141.  
  142.  
  143. #Execution
  144. testcase_4(adjudicator.Adjudicator,Agent_1,Agent_2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement