Bugfix mutator and 0 len expr
This commit is contained in:
parent
9acb2b702d
commit
cb1b9531b4
2 changed files with 5 additions and 3 deletions
|
|
@ -112,6 +112,8 @@ if 'pool_size' in args:
|
|||
# for _ in range(args.pool_size)]
|
||||
else:
|
||||
prog = rpnlib.RpnExpr.from_string(args.prog)
|
||||
if len(prog) == 0:
|
||||
prog = rpnlib.RpnExpr([rpnlib.RpnSymbol.from_string('0')])
|
||||
progs = [prog]
|
||||
progs += [mutate(prog, force=True) for _ in range(args.pool_size-1)]
|
||||
|
||||
|
|
|
|||
|
|
@ -61,14 +61,14 @@ def mutadd(expr):
|
|||
return expr
|
||||
|
||||
def mutdel(expr):
|
||||
if len(expr) == 1:
|
||||
if len(expr) <= 1:
|
||||
return mutadd(expr)
|
||||
pos = randint(0, len(expr)-1)
|
||||
del(expr[pos])
|
||||
return expr
|
||||
|
||||
def mutupdtype(expr):
|
||||
if len(expr) == 1:
|
||||
if len(expr) <= 1:
|
||||
pos = 0
|
||||
else:
|
||||
pos = randint(0, len(expr) - 1)
|
||||
|
|
@ -78,7 +78,7 @@ def mutupdtype(expr):
|
|||
return expr
|
||||
|
||||
def mutupdval(expr):
|
||||
if len(expr) == 1:
|
||||
if len(expr) <= 1:
|
||||
pos = 0
|
||||
else:
|
||||
pos = randint(0, len(expr) - 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue