Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.63 KB | None | 0 0
  1. def process_Data():
  2.             arr = []
  3.             def processUnit(obj):
  4.                 arr.append(obj.health)
  5.                 arr.append(obj.position.x)
  6.                 arr.append(obj.position.y)
  7.                 arr.append(obj.size.x)
  8.                 arr.append(obj.size.y)
  9.                 if obj.jump_state.can_cancel == False:
  10.                     arr.append(0)
  11.                 else:
  12.                     arr.append(1)
  13.                 if obj.jump_state.can_jump == False:
  14.                     arr.append(0)
  15.                 else:
  16.                     arr.append(1)
  17.                 arr.append(obj.jump_state.max_time)
  18.                 arr.append(obj.jump_state.speed)
  19.                 if obj.walked_right == False:
  20.                     arr.append(0)
  21.                 else:
  22.                     arr.append(1)
  23.                 if obj.stand == False:
  24.                     arr.append(0)
  25.                 else:
  26.                     arr.append(1)
  27.                 if obj.on_ground == False:
  28.                     arr.append(0)
  29.                 else:
  30.                     arr.append(1)
  31.                 if obj.on_ladder == False:
  32.                     arr.append(0)
  33.                 else:
  34.                     arr.append(1)
  35.                 arr.append(obj.mines)
  36.                 if obj.weapon != None:
  37.                     arr.append(obj.weapon.params.fire_rate)
  38.                     arr.append(obj.weapon.params.reload_time)
  39.                     arr.append(obj.weapon.params.min_spread)
  40.                     arr.append(obj.weapon.params.max_spread)
  41.                     arr.append(obj.weapon.params.aim_speed)
  42.                     arr.append(obj.weapon.params.bullet.speed)
  43.                     arr.append(obj.weapon.params.bullet.size)
  44.                     arr.append(obj.weapon.params.bullet.damage)
  45.                 else:
  46.                     arr.append(0)
  47.                     arr.append(0)
  48.                     arr.append(0)
  49.                     arr.append(0)
  50.                     arr.append(0)
  51.                     arr.append(0)
  52.                     arr.append(0)
  53.                     arr.append(0)
  54.             posX = int(game.units[0].position.x)
  55.             posY = int(game.units[0].position.y)
  56.             leftX = -1
  57.             leftY = -1
  58.             if posX - 5 < 0:
  59.                 leftX = posX
  60.             elif posX + 5 >= 40:
  61.                 leftX = posX - 10
  62.             else:
  63.                 leftX = posX - 5
  64.             if posY - 5 < 0:
  65.                 leftY = posY
  66.             elif posY + 5 >= 30:
  67.                 leftY = posY - 10
  68.             else:
  69.                 leftY = posY - 5
  70.             for i in range(leftX,leftX+10):
  71.                 for j in range(leftY,leftY+10):
  72.                     arr.append(game.level.tiles[i][j].value)
  73.             processUnit(game.units[0])
  74.             processUnit(game.units[1])
  75.             arr_l = len(arr)
  76.             if game.bullets != []:
  77.                 for i in game.bullets:
  78.                     if (game.units[0].position.x < game.units[1].position.y and i.velocity.x < 0) or (game.units[0].position.y < game.units[1].position.y and i.velocity.y < 0) or (game.units[0].position.x > game.units[1].position.x and i.velocity.x > 0) or (game.units[0].position.y > game.units[1].position.y and i.velocity.y > 0):
  79.                         arr.append(i.position.x)
  80.                         arr.append(i.position.y)
  81.                         arr.append(i.velocity.x)
  82.                         arr.append(i.velocity.y)
  83.                         arr.append(i.damage)
  84.                         arr.append(i.size)
  85.                         arr.append(i.explosion_params.damage)
  86.                         arr.append(i.explosion_params.radius)
  87.                         arr_l += 1
  88.             for i in range(len(arr) - arr_l,20):
  89.                 arr.append(0)
  90.                 arr.append(0)
  91.                 arr.append(0)
  92.                 arr.append(0)
  93.                 arr.append(0)
  94.                 arr.append(0)
  95.                 arr.append(0)
  96.                 arr.append(0)
  97.             diff = []
  98.             for i in game.mines:
  99.                 if game.units[0].position.x - i.position.x < 0:
  100.                     diff.append((game.units[0].position.x - i.position.x)*(-1))
  101.                 else:
  102.                     diff.append(game.units[0].position.x - i.position.x)
  103.             diff.sort()
  104.             nr = 0
  105.             for i in range(0,len(diff)):
  106.                 if nr == 2:
  107.                     break
  108.                 for j in game.mines:
  109.                     d = 0
  110.                     if game.units[0].position.x - j.position.x < 0:
  111.                         d = (game.units[0].position.x - j.position.x)*(-1)
  112.                     if d == diff[i]:
  113.                         arr.append(j.position.x)
  114.                         arr.append(j.position.y)
  115.                         arr.append(j.size.x)
  116.                         arr.append(j.size.y)
  117.                         arr.append(j.state)
  118.                         nr += 1
  119.             while nr < 2:
  120.                 arr.append(0)
  121.                 arr.append(0)
  122.                 arr.append(0)
  123.                 arr.append(0)
  124.                 arr.append(0)
  125.                 nr += 1
  126.             nr = 0
  127.             diff = []
  128.             for i in game.loot_boxes:
  129.                 if game.units[0].position.x - i.position.x < 0:
  130.                     diff.append((game.units[0].position.x - i.position.x)*(-1))
  131.                 else:
  132.                     diff.append(game.units[0].position.x - i.position.x)
  133.             diff.sort()
  134.             nr = 0
  135.             for i in range(0,len(diff)):
  136.                 if nr == 6:
  137.                     break
  138.                 for j in game.loot_boxes:
  139.                     d = 0
  140.                     if game.units[0].position.x - j.position.x < 0:
  141.                         d = (game.units[0].position.x - j.position.x)*(-1)
  142.                     if d == diff[i]:
  143.                         arr.append(j.position.x)
  144.                         arr.append(j.position.y)
  145.                         arr.append(j.size.x)
  146.                         arr.append(j.size.y)
  147.                         if str(type(j.item)) == "<class 'model.item.Weapon'>":
  148.                             arr.append(j.item.weapon_type + 1)
  149.                         elif str(type(j.item)) == "<class 'model.item.Mine'>":
  150.                             arr.append(4)
  151.                         elif str(type(j.item)) == "<class 'model.item.HealthPack'>":
  152.                             arr.append(5)
  153.                         nr += 1
  154.             while nr < 6:
  155.                 arr.append(0)
  156.                 arr.append(0)
  157.                 arr.append(0)
  158.                 arr.append(0)
  159.                 arr.append(0)
  160.                 nr+=1
  161.             return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement