
| 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 |
: J/ @& {- L$ E% m( t( s4 W

| choose an intial population For each h in population,compute Fitness(h)9 ]2 e7 [ ]3 ] While(max Fitness(h) < Fitnessthreshold) do selection do crossover do mutation # B1 @) n& i* g3 m update population% q& d( U1 k* [" C 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) { case 0: setTurnRight(Math.random()*90);' k' z/ H# @2 T/ J/ t, N2 M7 p break; case 1: setTurnLeft(Math.random()*90); break; }/ a3 T7 i# w- s( X1 q! l0 m1 h execute();* I9 r% o) v! t' C! t |
| ahead(200);- Y3 `7 S8 }/ |" b setBack(200); |
| setTurnRight(1000); h2 W9 n& d5 ?& m: g( l; X! X6 D setMaxVelocity(4); ahead(1000); |
| double forceX = 0;+ Z" b" S l, K4 b1 g# } Z( u double forceY = 0;0 e3 N& l1 Z' G* T for (int i=0; i |
| public class MovePatteren implements Comparable { private int grad, input;4 P. C' ~: ]$ [6 Y L) \' e7 w; q( @ private double range;( _& ?) H# z+ v4 P+ F2 b2 a! w5 E protected double fitness=0;5 z3 `. C4 a/ D9 H) x5 } protected double[] weightsX, weightsY; 9 D4 Z7 f9 \) I! Q3 f … } |
| protected MovePatteren crossOver(MovePatteren mate, boolean[] maskx, boolean[] masky) {6 y. U+ b9 X1 i" P# A! N 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() { weightsX[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range;% x2 e+ N C9 r* t weightsY[(int)(Math.random()*weightsX.length)]=Math.random()*range*2-range; } |
|
| 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 |





谢谢分享

O(∩_∩)O谢谢楼主,mark~


| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |