Agents (ตัวแทน)
ต่อไปเราต้องการ agents นี่คือนิยามของคลาส:
class Agent:
def __init__(self, loc, fit_land):
self.loc = loc
self.fit_land = fit_land
self.fitness = fit_land.fitness(self.loc)
def copy(self):
return Agent(self.loc, self.fit_land)
คุณสมบัติ (attribute) ของ Agent มีดังนี้:
loc
ตำแหน่งของ Agent ใน fitness landscape
fit_land
reference (การอ้างอิง) ไปยัง object ของ FitnessLandscape
fitness
fitness ของ Agent ตัวนี้ใน FitnessLandscape แทนด้วยตัวเลขระหว่าง 0 ถึง 1
Agent มีเมธอด copy ซึ่งคัดลอก genotype มาอย่างถูกต้องทุกหลัก ต่อมาเราจะเห็นเวอร์ชันที่คัดลอกพร้อมกับ mutation แต่ mutation ไม่จำเป็นต่อการเกิดวิวัฒนาการ