()
| 47 | } |
| 48 | |
| 49 | func (t *Triangle) Mutate() { |
| 50 | w := t.Worker.W |
| 51 | h := t.Worker.H |
| 52 | rnd := t.Worker.Rnd |
| 53 | const m = 16 |
| 54 | for { |
| 55 | switch rnd.Intn(3) { |
| 56 | case 0: |
| 57 | t.X1 = clampInt(t.X1+int(rnd.NormFloat64()*16), -m, w-1+m) |
| 58 | t.Y1 = clampInt(t.Y1+int(rnd.NormFloat64()*16), -m, h-1+m) |
| 59 | case 1: |
| 60 | t.X2 = clampInt(t.X2+int(rnd.NormFloat64()*16), -m, w-1+m) |
| 61 | t.Y2 = clampInt(t.Y2+int(rnd.NormFloat64()*16), -m, h-1+m) |
| 62 | case 2: |
| 63 | t.X3 = clampInt(t.X3+int(rnd.NormFloat64()*16), -m, w-1+m) |
| 64 | t.Y3 = clampInt(t.Y3+int(rnd.NormFloat64()*16), -m, h-1+m) |
| 65 | } |
| 66 | if t.Valid() { |
| 67 | break |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func (t *Triangle) Valid() bool { |
| 73 | const minDegrees = 15 |
no test coverage detected