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 S7 x( l9 F) b) {+ ~- K While(max Fitness(h) < Fitnessthreshold) do selection0 A. Y2 z N# {) u do crossover" S6 J5 M4 @; ^2 t do mutation update population For each h in population,compute Fitness(h) Return best Fitness |
![]() ![]() |
![]()
|
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) {4 Y+ _ F" C) _; s5 z F6 \7 B case 0: setTurnRight(Math.random()*90); break;7 e; M/ N, u' b) P* h case 1: setTurnLeft(Math.random()*90);3 i5 F+ }4 _6 A0 M4 C9 N break; }# Z: t& j) W0 {1 E7 y; Z0 y% X execute();" g. z# w8 d( K+ d% U |
ahead(200); setBack(200); |
setTurnRight(1000); setMaxVelocity(4);. ]. S# @* [3 W7 g. L6 T/ m ahead(1000); |
double forceX = 0;/ N4 |; g7 }$ W+ y. G double forceY = 0; for (int i=0; i |
public class MovePatteren implements Comparable {% _& @) W" c* T E5 G private int grad, input; private double range;# g5 [; O9 e5 u, E/ z1 ? protected double fitness=0;& R3 q- k5 u- g5 b: Y0 w& W protected double[] weightsX, weightsY; 6 N" o" G) t W7 m" M. O … } |
protected MovePatteren crossOver(MovePatteren mate, boolean[] maskx, boolean[] masky) {4 P- O8 {0 Q3 j2 D double[] wx= new double[weightsX.length]; double[] wy= new double[weightsX.length]; for(int mask=0; mask <="" pre="" mask++)="" for(int="" g="0;" g |
protected void mutate() {6 O) |" |, d$ O" r2 q- m weightsX[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range;2 ^. |5 `% ]# t weightsY[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range;) M8 H1 N: ~) t" Q } |
![]() ![]() |
![]() |
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 |