fork download
  1. from AI.base import *
  2. class TeamAI( BaseAI ):
  3. def __init__( self , helper ):
  4. self.effect = EF_NONE
  5. self.skill = {
  6. HIDE:0,
  7. DEMENTOR:0,
  8. STUNALL:0,
  9. SPECIAL:0,
  10. }
  11. self.helper = helper
  12. # def dist( self ):
  13. # helper = self.helper
  14. # EnyId
  15. # return (helper.getMyPos()[0] - )
  16.  
  17. def steal( self , limitN ):
  18. limitN = 70
  19. enyId = helper.getNearPlayer()
  20. for i in range(0,3):
  21. if enyId[i] == None:
  22. continue
  23. else:
  24. enyPos = helper.getPlayerPos(enyId[i])
  25. myPos = helper.getMyPos()
  26. disa = (myPos[0]-enyPos[0])**2
  27. disb = (myPos[1]-enyPos[1])**2
  28. if (disa+disb) < limitN**2 and helper.checkPlayerHold(enyId[i]) == 1 and helper.getPlayerMode(enyId[i]) != 0:
  29. return helper.getPlayerPos(enyId[i])
  30. else:
  31. break
  32.  
  33. def decide( self ):
  34. helper = self.helper
  35. # 沒持球
  36. if not helper.checkMeHold():
  37. # 改成防禦模式
  38. if helper.getMyMode() == 0 and helper.checkMeModeChange():
  39. return AI_MODECHANGE
  40. # 預截取(min)
  41. limitN = 70
  42. enyId = helper.getNearPlayer()
  43. for i in range(0,3):
  44. if enyId[i] == None:
  45. continue
  46. else:
  47. enyPos = helper.getPlayerPos(enyId[i])
  48. myPos = helper.getMyPos()
  49. disa = (myPos[0]-enyPos[0])**2
  50. disb = (myPos[1]-enyPos[1])**2
  51. if (disa+disb) < limitN**2 and helper.checkPlayerHold(enyId[i]) == 1 and helper.getPlayerMode(enyId[i]) != 0:
  52. return helper.getPlayerPos(enyId[i])
  53. else:
  54. break
  55. # 追球
  56. mapMidPos = (370,370)
  57. fbpos = helper.getFreeBallPos()
  58. if bool(fbpos):
  59. return helper.getCaptureDir(fbpos[0])
  60. # 回到場中間
  61. elif helper.getMyPos() != mapMidPos:
  62. return helper.getCaptureDir(mapMidPos)
  63. # 持球
  64. else:
  65. # 改成攻擊模式
  66. if helper.getMyMode() == 1 and helper.checkMeModeChange():
  67. return AI_MODECHANGE
  68.  
  69. # 判斷最近的球門
  70. goalPos = helper.getNearGoal(helper.getMyPos())
  71. if goalPos[0] == helper.getMyIndex():
  72. shotgoal = goalPos[1]
  73. else:
  74. shotgoal = goalPos[0]
  75. # 判斷丟哪方向會進
  76. for i in range(1,9):
  77. if helper.checkScoring(shotgoal, i):
  78. # 會進方向 == 目前方向
  79. if helper.getMyDir() == i:
  80. return AI_THROWBALL
  81. # !會進方向 -> 轉方向
  82. else:
  83. return i
  84. # 目前方向都不會進
  85. NearGoalDir = helper.getScoringDir(shotgoal)
  86. return NearGoalDir
  87.  
Runtime error #stdin #stdout #stderr 0.01s 28384KB
stdin
Standard input is empty
stdout

Standard output is empty

stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'AI'