Remove flag
This commit is contained in:
parent
b62202ccd2
commit
20fb79ef76
|
@ -1,23 +1,14 @@
|
||||||
from math import pow, sin, pi
|
from math import pow, sin, pi
|
||||||
from random import Random
|
from random import Random
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
rand = Random()
|
rand = Random()
|
||||||
|
|
||||||
|
|
||||||
class Flag(Enum):
|
|
||||||
UNSET = 1,
|
|
||||||
PARENT = 2,
|
|
||||||
ELITE = 3,
|
|
||||||
PERSIST = 4
|
|
||||||
|
|
||||||
|
|
||||||
class Individual(object):
|
class Individual(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.x = self.get_rand_param()
|
self.x = self.get_rand_param()
|
||||||
self.y = self.get_rand_param()
|
self.y = self.get_rand_param()
|
||||||
self.flag = Flag(Flag.UNSET)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_params(cls, x, y):
|
def from_params(cls, x, y):
|
||||||
|
@ -51,13 +42,3 @@ class Individual(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_rand_param():
|
def get_rand_param():
|
||||||
return rand.uniform(0, 1)
|
return rand.uniform(0, 1)
|
||||||
|
|
||||||
def set_flag(self, flag):
|
|
||||||
if self.flag is Flag.UNSET:
|
|
||||||
self.flag = flag
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def reset_flag(self):
|
|
||||||
self.flag = Flag.UNSET
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user