Advertisement
EditorRUS

Untitled

Jan 13th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. import math
  2.  
  3. print "START X: "
  4. #sx = int(raw_input())
  5. print "START Y: "
  6. #sy = int(raw_input())
  7.  
  8. sx = 66
  9. sy = 81
  10.  
  11. rot = 0
  12. ang = 0
  13. power = 0
  14. powers = [5, 10, 20, 25, 30, 40, 50, 80, 100]
  15.  
  16. def HigherPower(X):
  17.     for result in powers:
  18.         if result > X:
  19.             return result
  20. def RequestPower():
  21.     key = 0
  22.     while (len(powers) < key) or (key-1<0):
  23.         for indx in range(len(powers)):
  24.             print (str(indx+1) + ": " + str(powers[indx]))
  25.         key = int(raw_input())
  26.     return powers[key-1]
  27.  
  28. calibrated = 0
  29. rot_off = 0
  30. power_off = 0
  31. tg45 = 2**0.5
  32.  
  33. print "\
  34. Captains office:\n\
  35. Captain laser: 48, 47, 1\n\
  36. Captain ID card: 46, 47, 1\n\
  37. Captain closet: 44, 47, 1\n\
  38. "
  39. print "POWER:"
  40. power = RequestPower()
  41. while 1:
  42.     if not calibrated:
  43.         print "Not calibrated"
  44.         print "POWER: " + str(power)
  45.         print "ANG: 45"
  46.         print "ROT: 0"
  47.         print "EX, EY, TIME"
  48.         ex = int(raw_input())
  49.         ey = int(raw_input())
  50.         time = float(raw_input())
  51.         py = time*5
  52.         # 2 * 4 = 8
  53.         power_off = math.trunc(py * tg45 - power)
  54.         print "P_OFF: " + str(power_off)
  55.         dist = ((ex - sx)**2 + (ey - sy)**2)**0.5
  56.         cos_res = (ex-sx)/dist
  57.         rot_off = math.trunc(math.degrees(math.asin(cos_res)))
  58.         #10 = 2 + 2*4 --2
  59.         #8 = 2*4 //2
  60.         #4 = 4
  61.         print "R_OFF: " + str(rot_off)
  62.         power = power + power_off
  63.         calibrated = 1
  64.     print "Where to go?"
  65.     print "DX, DY"
  66.     dx = int(raw_input())
  67.     dy = int(raw_input())
  68.     dst = ((dx - sx)**2 + (dy - sy)**2)**0.5
  69.     rot = math.degrees(math.acos((dx-sx)/dst)) - rot_off
  70.     print "ROT: " + str(rot)
  71.     print "POWER: " + str(power-power_off)
  72.     if ((10*dst) / power**2) >= 1:
  73.         print "TOO FAR, NOT ENOUGH POWER"
  74.         need_power = round((10*dst)**0.5 - power_off)
  75.         print "NEED AT LEAST " + str(HigherPower(need_power)) + " POWER"
  76.         print "ENTER NEW POWER:"
  77.         power = RequestPower()
  78.         power += power_off
  79.         continue
  80.     ang = round(math.degrees(math.asin((10 * dst) / power**2)) / 2)
  81.     print "ANG: " + str(ang)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement