micro/p.r

001/******************************************************************************
002  CRobot DEFENDER.R
003 
004  Creato nel Novembre 1999 per il Torneo del Millennio
005 
006  *********Potendo partecipare un solo Robot preferisco questo **********
007 
008        DEFENDER - Manowar
009 
010        Orson Wells
011 
012        "WHEN YOU ARE OLD ENAUGH"
013        "TO READ THIS WORDS"
014        "THEIR MEANINGS WILL UNFOLD"
015 
016        "THIS WORDS ARE ALL THAT LEFT"
017        "AND THOUGH WE'VE NEVER MET, MY ONLY SON"
018        "I HOPE YOU KNOW"
019 
020 
021  Massimo Paradisi
022 
023 
024  Il Robot si posiziona nell'angolo pi� vicino e si muove rapidamente in
025  oscillazione orizzontale.
026  Ogni 1500 cicli circa, fa uno scan per vedere quanti nemici sono rimasti.
027  Se ne � rimasto solo uno, attacca disegnando un quadrilatero casuale (routine
028  di kill!) in base alla posizione che ha al momento dirigendosi per 45�, 135�, 225� 315�,
029  sparando con la routine di goblin in movimento.
030*****************************************************************************/
031int deg,odeg,deg2     ;      /* gradi dove fa lo scan*/
032int range2,range,orange       ;  /* distanza del target */
033int dir;           /* direzione su cui si muove il robot*/
034int corr;
035main()
036{
037deg=0;
038deg2=175;
039    /*
040    "THAT I WOULD HAVE BEEN THERE"
041    "TO WATCH YOU GROW           "
042    "BUT MY CALLS WAS HEARD      "
043    "AND I DID GO                "
044    "NOW YOUR MISSION            "
045    "LIES AHEAD OF YOU           "
046    "AS IT DID MINE              "
047    "SO LONG AGO                 "
048    "TO HELP THE HELPLESS ONES   "
049    "WHO ALL LOOK UP TO YOU      "
050    "AND TO DEFEND THEM          "
051    "SO THE END                  "
052    */
053 
054    /*
055    il robot si muove oscillando eseguendo in continuazione la routine
056    di fuoco
057    Se � rimasto un solo nemico, lancia la fase ONLYONE
058    */
059 
060    if(loc_x()>500) {while(loc_x()<900){dir=0;shoot();} corr=799;}
061    else            while(loc_x()>100){dir=180;shoot();}
062    drive(0,0);
063 
064    if(loc_y()>500) while(loc_y()<900) {dir=90;shoot();}
065    else            while(loc_y()>100) {dir=270;shoot();}
066 
067    drive(0,0);
068 
069    deg=1;
070    while (1)
071    {
072 
073        /* vai verso sinistra e spara*/
074        dir = 180;
075        while (loc_x() > 100+corr) shoot();
076        drive(dir,0);
077 
078        /* vai verso destra e spara*/
079        dir = 0;
080        while (loc_x() < 101+corr) shoot();
081        drive(dir,0);
082 
083    }
084}
085 
086 
087/* scanna per due giri l'arena per verificare quanti nemici ci sono
088   ritorna 1, se c'e' un solo nemico */
089 
090shoot()
091{
092    /*
093    DEFENDER
094    RIDE LIKE THE WING
095    FIGHT PROUD MY SON
096    YOU'RE THE DEFENDER
097    GOD HAS SENT
098    */
099 
100    drive(dir,100);
101    if ((range=scan(deg,10)))
102        {
103        if(range>800) range=800;
104        cannon(deg,range);
105        }
106        else deg+=10;
107    if ((range2=scan(deg2,10)))
108        {
109        if(range2>800) range2=800;
110        cannon(deg2,range2);
111        }
112        else deg2+=10;
113}