Browse Source

Bugfix in mutator when len(expr) == 1

Yann Weber 6 years ago
parent
commit
ec4e4a9951
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      gte/mutator.py

+ 4
- 1
gte/mutator.py View File

@@ -64,7 +64,10 @@ def mutdel(expr):
64 64
     return expr
65 65
 
66 66
 def mutupdtype(expr):
67
-    pos = randint(0, len(expr) - 1)
67
+    if len(expr) == 1:
68
+        pos = 0
69
+    else:
70
+        pos = randint(0, len(expr) - 1)
68 71
     optype = [RpnSymbol.OPERATION, RpnSymbol.VALUE, RpnSymbol.VARIABLE]
69 72
     del(optype[optype.index(expr[pos].optype)])
70 73
     expr[pos] = RpnSymbol.random(optype[randint(0,1)])

Loading…
Cancel
Save