Fitness 值: | 2200 | 1800 | 1200 | 950 | 400 | 100 |
选择概率: | 3331 | 0.271 | 0.18 | 0.143 | 0.06 | 0.015 |
S1 1000 1111 S2 1110 1100 |
Crossover | 11110000 | Crossover | 11110000 |
S1 | 1000 1111 | S2 | 1110 1100 |
P1 | 1000 1100 | P2 | 1110 1111 |
1 1 1 0 1 1 0 0 |
1 1 0 0 1 1 0 0 |
choose an intial population For each h in population,compute Fitness(h)4 R" @4 ~0 ~' v* R4 e8 I. G While(max Fitness(h) < Fitnessthreshold) do selection/ C& f8 J3 U8 ^2 [4 N do crossover, J. [9 h1 q* M! T" u8 V do mutation update population9 |; |( @) g# Z7 d For each h in population,compute Fitness(h) Return best Fitness/ i$ i5 p+ `1 O0 `$ W0 l |
![]() ![]() |
![]() |
MS | BPS | RS | TS |
random | distance-based | always-turn | HeadOn |
Linear | light-fast | target-focus | Linear |
circular | Powerful-slow | target-scope-focus | Circular |
Perpendicular | Medium | nearest robot | |
arbitary | hit-rate based | Log | |
anti gravity | Statistic | ||
Stop | Angular | ||
Bullet avoid | wave | ||
wall avoid | |||
track | |||
Oscillators |
switch(Math.random()*2) {( Q$ I/ e4 Z g9 A9 Y case 0: setTurnRight(Math.random()*90);4 ]4 N2 F, b; x. X/ g1 d1 I break;* {9 T1 c' n5 u" \ case 1: setTurnLeft(Math.random()*90);- W; k8 e/ Q7 k# P6 p: g break; }, w9 b1 I+ L! l/ @ execute(); |
ahead(200);- J7 U4 N) j2 h$ r setBack(200);+ b/ Y4 |& q- n# @ |
setTurnRight(1000); setMaxVelocity(4); ahead(1000); |
double forceX = 0;; |* A* l, g. _: ^& J double forceY = 0; k& P+ ^7 h* }, v- o for (int i=0; i |
public class MovePatteren implements Comparable {% h2 ^' l. i: V% U private int grad, input;$ @* }7 T: v# }6 ]! E private double range; protected double fitness=0; protected double[] weightsX, weightsY; … } |
protected MovePatteren crossOver(MovePatteren mate, boolean[] maskx, boolean[] masky) { double[] wx= new double[weightsX.length]; double[] wy= new double[weightsX.length];+ X1 `. [$ ?# c) b. i7 y5 N( j# e for(int mask=0; mask <="" pre="" mask++)="" for(int="" g="0;" g |
protected void mutate() { weightsX[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range; weightsY[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range;) r8 _8 f$ {4 ~5 V( }2 ?# E' F } |
![]() ![]() |
![]()
|
Function | Input 1 | Input 2 | Output |
1. Random | ignore | ignore | 0,87 |
2. Divide | Const_1 | Const_2 | 0,5 |
3. Greater Than | Line 1 | Line 2 | 1 |
4. Normalize Angle | Enemy bearing | ignore | -50 |
5. Absolute Value | Line 4 | ignore | 50 |
6. Less Than | Line 4 | Const_90 | 1 |
7. And | Line 6 | Line 3 | 1 |
8. Multiply | Const_10 | Const_10 | 100 |
9. Less Than | Enemy distance | Line 8 | 0 |
10. And | Line 9 | Line 7 | 0 |
11. Multiply | Line 10 | Line 4 | 0 |
12 Output | Turn gun left | Line 11 | 0 |
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |