Advertisement
Guest User

Untitled

a guest
May 20th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.39 KB | None | 0 0
  1. public void Play(int d) {
  2.         if(isFirstTurn) {
  3.             if(d > 650)
  4.                 Console.WriteLine($"{hero.CurrCp.X} {hero.CurrCp.Y} BOOST");
  5.             else
  6.                 Console.WriteLine($"{hero.CurrCp.X} {hero.CurrCp.Y} {speed}");
  7.  
  8.             isFirstTurn = false;
  9.            
  10.             return;
  11.         }
  12.  
  13.  
  14.         Move bm = null;
  15.         float scoreStrat1 = 0;
  16.         float bs = -100000.0f;
  17.  
  18.         Pod cPod = hero.GetCopyPod();
  19.  
  20.         bool checked1 = false;
  21.         for(int i = 0; i < 6; i++) {
  22.             cPod.Play(cPod.CurrCp, speed);
  23.  
  24.             float dist = cPod.Distance(cPod.CurrCp);
  25.             if(dist <= cPod.CurrCp.Radius) {
  26.                 int coef = 0;
  27.                 switch(i) {
  28.                     case 0:
  29.                         coef = 6;
  30.                         break;
  31.                     case 1:
  32.                         coef = 5;
  33.                         break;
  34.                     case 2:
  35.                         coef = 4;
  36.                         break;
  37.                     case 3:
  38.                         coef = 3;
  39.                         break;
  40.                     case 4:
  41.                         coef = 2;
  42.                         break;
  43.                     case 5:
  44.                         coef = 1;
  45.                         break;
  46.                     default:
  47.                         break;
  48.                 }
  49.                 scoreStrat1 = 10000 * coef;
  50.                 checked1 = true;
  51.                 break;
  52.             }
  53.         }
  54.         if(!checked1)
  55.             scoreStrat1 = Evaluate(cPod, 6);
  56.  
  57.         int count = 0;
  58.         while(SW.ElapsedMilliseconds<49) {
  59.             count++;
  60.             Solution sol = new Solution();
  61.             sol.Randomize();
  62.  
  63.             Pod pga = hero.GetCopyPod();
  64.  
  65.             float temp = -100000;
  66.             bool checked2 = false;
  67.             for(int i = 0; i < 6; i++) {
  68.                 pga.Apply(sol.Moves[i]);
  69.  
  70.                 float dist = pga.Distance(pga.CurrCp);
  71.                 if(dist <= pga.CurrCp.Radius) {
  72.                     int coef = 0;
  73.                     switch(i) {
  74.                         case 0:
  75.                             coef = 6;
  76.                             break;
  77.                         case 1:
  78.                             coef = 5;
  79.                             break;
  80.                         case 2:
  81.                             coef = 4;
  82.                             break;
  83.                         case 3:
  84.                             coef = 3;
  85.                             break;
  86.                         case 4:
  87.                             coef = 2;
  88.                             break;
  89.                         case 5:
  90.                             coef = 1;
  91.                             break;
  92.                         default:
  93.                             break;
  94.                     }
  95.                     temp = 10000 * coef;
  96.                     checked2 = true;
  97.                     break;
  98.                 }
  99.             }
  100.  
  101.             if(!checked2)
  102.                 temp = Evaluate(pga, 6);
  103.  
  104.             if(temp > bs) {
  105.                 bs = temp;
  106.                 bm = sol.Moves[0];
  107.             }
  108.         }
  109.  
  110.         Console.Error.WriteLine($"{count}: {scoreStrat1} / {bs} : {d}");
  111.  
  112.         if(scoreStrat1 > bs)
  113.             Console.WriteLine($"{hero.CurrCp.X} {hero.CurrCp.Y} {speed} strat1");
  114.         else
  115.             hero.Output(bm);
  116.        
  117.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement