Make AI smarter
This commit is contained in:
@@ -115,11 +115,14 @@ class AI:
|
|||||||
return
|
return
|
||||||
|
|
||||||
target = self.target
|
target = self.target
|
||||||
if random.random() * 100 < 10:
|
if (target and target.size > self.man.size) or random.random() * 100 < 10:
|
||||||
target = None
|
target = None
|
||||||
|
|
||||||
if target is None:
|
if target is None:
|
||||||
if targets := [e for e in self.enemies or [] if e.size < self.man.size]:
|
targets = [
|
||||||
|
e for e in self.enemies or [] if e.alive and e.size < self.man.size
|
||||||
|
]
|
||||||
|
if targets:
|
||||||
target = random.choice(targets)
|
target = random.choice(targets)
|
||||||
|
|
||||||
if target is None:
|
if target is None:
|
||||||
@@ -235,6 +238,7 @@ while running:
|
|||||||
for p in players:
|
for p in players:
|
||||||
for op in players:
|
for op in players:
|
||||||
if p != op and p.can_eat(op):
|
if p != op and p.can_eat(op):
|
||||||
|
op.alive = False
|
||||||
players.remove(op)
|
players.remove(op)
|
||||||
|
|
||||||
if p.can_eat(food):
|
if p.can_eat(food):
|
||||||
|
Reference in New Issue
Block a user