Question: I need help programming something in Python. Here is all the context - Movement - Did you call all the functions? ( lookAtSpace ( )

I need help programming something in Python. Here is all the context - Movement
- Did you call all the functions? (lookAtSpace() is optional)
- Do any movement functions get called when they shouldn't, e.g. does your bot try to move forward into a wall?
- Does your bot move appropriately as if a human is controlling it?
- Non-Movement
- Did you call at least four of the eight non-movement functions including the required attack() function?
- Do any of the functions get called when they shouldn't, e.g. an ability is called without enough energy or an attack is called when the enemy is in the wrong spot?
Are the non-movement abilities used logically and do they vary depending on the situation?
- Elegance
- Does your code go beyond basic movement and attacking?
- Did you add attributes to your own Al class for various reasons?
- Did you add in your own extra functions?
- Did you write your code like a chess match, i.e. you anticipate how your opponent will behave?
- Al Opponents -
- Does your code beat randombot?
- Does your code beat hunterbot?
```
class AI:
def __init__(self):
self.isFirstTurn = True
def turn(self):
if self.robot.lookInFront()== "bot":
self.robot.attack()
else:
self.goTowards(self.robot.locateEnemy()
[0])
def checkDelta(self,enemyLocation):
myLocation = self.robot.position
delta =(enemyLocation[0]-
myLocation[0],enemyLocation[1]-myLocation[1])
return delta
def goTowards(self,enemyLocation):
myLocation = self.robot.position
delta =(enemyLocation[0]-
myLocation[0],enemyLocation[1]-myLocation[1])
if abs(delta[0])> abs(delta[1]):
if delta[0]0:
targetOrientation =3 #face left
else:
targetOrientation =1 #face right
else:
if delta[1]0:
targetOrientation =0 #face up
else:
targetOrientation =2 #face down
if self.robot.rotation == targetOrientation:
self.robot.goForth()
else:
leftTurnsNeeded =(self.robot.rotation -
targetOrientation)%4
if leftTurnsNeeded =2:
self.robot.turnLeft()
else:
self.robot.turnRight()
```
```
import random
class AI:
def __init__(self):
#Anything the AI needs to do before the game
starts goes here.
pass
def turn(self):
if self.robot.lookInFront()== "bot":
self.robot.attack()
return
else:
random.choice([self.robot.turnLeft,self.robot.turnRigh
t,self.robot.goForth,self.robot.goForth,self.robot.esc
ape,self.robot.luckyshot,self.robot.repair,self.robot.
toss,self.robot.charge,self.robot.teleport])()
```
I need help programming something in Python. Here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!