summaryrefslogtreecommitdiffstats
path: root/test/cbot/scenarios
diff options
context:
space:
mode:
Diffstat (limited to 'test/cbot/scenarios')
-rw-r--r--test/cbot/scenarios/B.txt18
-rw-r--r--test/cbot/scenarios/BUG2.txt107
-rw-r--r--test/cbot/scenarios/Deleted.txt23
-rw-r--r--test/cbot/scenarios/MaClass.txt16
-rw-r--r--test/cbot/scenarios/Mc2.txt4
-rw-r--r--test/cbot/scenarios/Mon fichier.txt2
-rw-r--r--test/cbot/scenarios/Nop.txt4
-rw-r--r--test/cbot/scenarios/POS.txt14
-rw-r--r--test/cbot/scenarios/T.txt4
-rw-r--r--test/cbot/scenarios/TESTALL.txt161
-rw-r--r--test/cbot/scenarios/TestCB1.txt18
-rw-r--r--test/cbot/scenarios/TestCBot1.txt27
-rw-r--r--test/cbot/scenarios/TestCBot3.txt24
-rw-r--r--test/cbot/scenarios/TestNull.txt15
-rw-r--r--test/cbot/scenarios/TestRestoreState.txt67
-rw-r--r--test/cbot/scenarios/TestStatic.txt31
-rw-r--r--test/cbot/scenarios/TestStr.txt17
-rw-r--r--test/cbot/scenarios/Z.txt14
-rw-r--r--test/cbot/scenarios/a.txt312
-rw-r--r--test/cbot/scenarios/bug.txt12
-rw-r--r--test/cbot/scenarios/bugmw.txt9
-rw-r--r--test/cbot/scenarios/ccc.txt8
-rw-r--r--test/cbot/scenarios/enum.txt9
-rw-r--r--test/cbot/scenarios/fibo.txt25
-rw-r--r--test/cbot/scenarios/file.txt70
-rw-r--r--test/cbot/scenarios/h.txt5
-rw-r--r--test/cbot/scenarios/include.txt27
-rw-r--r--test/cbot/scenarios/intrinsic.txt16
-rw-r--r--test/cbot/scenarios/methode1.txt57
-rw-r--r--test/cbot/scenarios/methode2.txt50
-rw-r--r--test/cbot/scenarios/mp1.txt25
-rw-r--r--test/cbot/scenarios/mp2.txt28
-rw-r--r--test/cbot/scenarios/mw.txt16
-rw-r--r--test/cbot/scenarios/null.txt5
-rw-r--r--test/cbot/scenarios/opnew.txt20
-rw-r--r--test/cbot/scenarios/plante.txt25
-rw-r--r--test/cbot/scenarios/pointer.txt41
-rw-r--r--test/cbot/scenarios/postinc.txt7
-rw-r--r--test/cbot/scenarios/radar.txt39
-rw-r--r--test/cbot/scenarios/solution.txt13
-rw-r--r--test/cbot/scenarios/test.txt8
-rw-r--r--test/cbot/scenarios/test23.txt10
-rw-r--r--test/cbot/scenarios/testmw.txt14
-rw-r--r--test/cbot/scenarios/this.txt13
-rw-r--r--test/cbot/scenarios/tt.txt12
-rw-r--r--test/cbot/scenarios/tt2.txt5
-rw-r--r--test/cbot/scenarios/vide.txt0
-rw-r--r--test/cbot/scenarios/zz.txt6
48 files changed, 1453 insertions, 0 deletions
diff --git a/test/cbot/scenarios/B.txt b/test/cbot/scenarios/B.txt
new file mode 100644
index 0000000..53715f8
--- /dev/null
+++ b/test/cbot/scenarios/B.txt
@@ -0,0 +1,18 @@
+
+ float [ ] TEST2 ( int [ ] param )
+ {
+ float [ ] z;
+ for ( int i = 0 ; i < sizeof( param ) ; i++ ) try { z [i] = param [i] / 3; }
+ return z;
+ }
+
+extern public void T()
+{
+ int a [4];
+ for ( int i = 0 ; i < 3 ; i++ ) a[i] = 4*i;
+ a [2] = 22;
+
+ float [] b ;
+ b = TEST2 ( a ) ;
+ show ( a, b );
+}
diff --git a/test/cbot/scenarios/BUG2.txt b/test/cbot/scenarios/BUG2.txt
new file mode 100644
index 0000000..44de05a
--- /dev/null
+++ b/test/cbot/scenarios/BUG2.txt
@@ -0,0 +1,107 @@
+object object :: TT ( int n )
+{
+ object XX = radar();
+ if ( n == 0 ) return null;
+
+ while ( null == XX ) XX = radar();
+ return XX;
+}
+
+extern void object::Attack( )
+{
+ show ( TT ( 0 ) ) ;
+ show ( TT ( 1 ) ) ;
+ return;
+
+ int list[];
+ int i;
+ object p;
+ float dist, prox;
+ point dest;
+ boolean advance = true;
+
+ TEST(0); // ne stoppe pas si erreur
+// while ( F () != 0 ) F(1);
+
+ i = 0;
+ list[i++] = WingedGrabber;
+ list[i++] = TrackedGrabber;
+ list[i++] = WheeledGrabber;
+ list[i++] = LeggedGrabber;
+ list[i++] = WingedShooter;
+ list[i++] = TrackedShooter;
+ list[i++] = WheeledShooter;
+ list[i++] = LeggedShooter;
+ list[i++] = WingedOrgaShooter;
+ list[i++] = TrackedOrgaShooter;
+ list[i++] = WheeledOrgaShooter;
+ list[i++] = LeggedOrgaShooter;
+ list[i++] = WingedSniffer;
+ list[i++] = TrackedSniffer;
+ list[i++] = WheeledSniffer;
+ list[i++] = LeggedSniffer;
+ list[i++] = Thumper;
+ list[i++] = PhazerShooter;
+ list[i++] = Recycler;
+ list[i++] = Shielder;
+ list[i++] = Subber;
+ list[i++] = Me;
+ list[i++] = 3333;
+ list[i++] = 3334;
+ list[i++] = 3335;
+ list[i++] = 3336;
+ list[i++] = 3337;
+ list[i++] = 3338;
+ list[i++] = 3339;
+ list[i++] = 3331;
+ list[i++] = 3332;
+ list[i++] = 3330;
+ list[i++] = 1111;
+ list[i++] = 1112;
+
+ F(F(0));
+
+ while ( true )
+ {
+ p = radar(list, 0, 360, 0, 1000);
+ if ( p == null )
+ {
+ F(2);
+ }
+ else
+ {
+ dist = F(p.position, position);
+ if ( dist <= 40 && !advance )
+ {
+ fire(p.position);
+ advance = true;
+ }
+ else
+ {
+//? if ( RetBaseDistance() > 20 )
+ {
+ prox = dist-(5+F()*5);
+ if ( prox < 5 ) prox = 5;
+ dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
+ dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
+ dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
+ goto(dest);
+ advance = false;
+ }
+ }
+ }
+ }
+}
+
+// Calcule la distance jusqu'à la base.
+
+float object::RetBaseDistance()
+{
+ object p;
+ float dist;
+
+ p = radar(4444, 0, 360, 0, 1000);
+ if ( p == null ) return 1000;
+ dist = F(p.position, position);
+ return dist;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/Deleted.txt b/test/cbot/scenarios/Deleted.txt
new file mode 100644
index 0000000..469a624
--- /dev/null
+++ b/test/cbot/scenarios/Deleted.txt
@@ -0,0 +1,23 @@
+public extern void object :: ESSAI()
+{
+ while(true)
+ {
+ if ( true )
+ {
+ goto(12);
+ break;
+ }
+ }
+ object x = null ;
+
+ while ( x == null ) x = radar();
+
+ show ( x.position ) ;
+
+ TEST(5, x);
+
+ if ( x == null ) show ( "DELETED" );
+
+ show ( x.position ) ;
+
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/MaClass.txt b/test/cbot/scenarios/MaClass.txt
new file mode 100644
index 0000000..ac472b4
--- /dev/null
+++ b/test/cbot/scenarios/MaClass.txt
@@ -0,0 +1,16 @@
+
+class MaClass
+{
+ int a = 1 ;
+ MaClass pointeur ;
+ MaClass next = null ;
+ CPoint autre = new CPoint( 1 , 1 ) ;
+}
+
+extern public void Test ( )
+{
+ MaClass x () ;
+ x.next = new MaClass ( ) ;
+ println ( x ) ;
+}
+
diff --git a/test/cbot/scenarios/Mc2.txt b/test/cbot/scenarios/Mc2.txt
new file mode 100644
index 0000000..172c259
--- /dev/null
+++ b/test/cbot/scenarios/Mc2.txt
@@ -0,0 +1,4 @@
+class MaClass
+{
+ int t = 12;
+}
diff --git a/test/cbot/scenarios/Mon fichier.txt b/test/cbot/scenarios/Mon fichier.txt
new file mode 100644
index 0000000..6b35bf8
--- /dev/null
+++ b/test/cbot/scenarios/Mon fichier.txt
@@ -0,0 +1,2 @@
+Voici encore du texte
+et une seconde ligne
diff --git a/test/cbot/scenarios/Nop.txt b/test/cbot/scenarios/Nop.txt
new file mode 100644
index 0000000..6a66f6f
--- /dev/null
+++ b/test/cbot/scenarios/Nop.txt
@@ -0,0 +1,4 @@
+public extern void Nop()
+{
+ while ( true ) {}
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/POS.txt b/test/cbot/scenarios/POS.txt
new file mode 100644
index 0000000..688e4fb
--- /dev/null
+++ b/test/cbot/scenarios/POS.txt
@@ -0,0 +1,14 @@
+void object :: T ( )
+{
+ show ( position ) ;
+}
+
+public extern void object :: POS()
+{
+ for ( int i = 0; i < 10 ; i++ )
+ {
+ if ( i == 2 ) TEST ( 12 ) ;
+// show ( position );
+ T ( ) ;
+ }
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/T.txt b/test/cbot/scenarios/T.txt
new file mode 100644
index 0000000..50a792b
--- /dev/null
+++ b/test/cbot/scenarios/T.txt
@@ -0,0 +1,4 @@
+public extern int T ( float n )
+{
+ return n * 1.1;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/TESTALL.txt b/test/cbot/scenarios/TESTALL.txt
new file mode 100644
index 0000000..82247a0
--- /dev/null
+++ b/test/cbot/scenarios/TESTALL.txt
@@ -0,0 +1,161 @@
+int T ( int z )
+{
+ return 45 + z ;
+}
+
+class toto
+{
+ int val = 3 ;
+ int x = 3 * 3 ;
+ void toto( int n )
+ { val = n + 3 ; }
+ int retval ( int param )
+ { int r = val + param + x ;
+ val = param ;
+ return r ; }
+}
+
+public extern void object :: Chose( )
+{
+ int z [ 6 ];
+ for ( int i = 0 ; i < 6 ; ) z [ i++ ] = 3 - i ;
+ show ( z ) ;
+ return;
+
+ // test des tableaux
+ int [ ] a [ 3 ] ;
+// a = null;
+ if ( a == null ) show ( "NULL" );
+
+ a [ 2 / 2 ] [ 2 ]= 5 ;
+ int [ ] b ; b = a [1] ;
+ b [ 0 ] = -4;
+ a [ 4 / 2 ] [ 1 ]= 1 ;
+ show ( a , b ) ;
+ return ;
+ {
+ toto chose = new toto (5 ) ;
+ toto truc = chose ;
+ show ( chose, chose.retval( 100 ) ,
+ truc, truc.retval (40 ) ) ;
+
+ return;
+ }
+ {
+ point A = new
+ point ( 4 * 4 , 2 ) ;
+ show ( A ) ;
+ return;
+ }
+ {
+ show ( T ( 1 ) , T ( 3.7 ) ) ;
+ return;
+ }
+
+ {
+ point A ( 3, 4 ) ,
+ B = A ;
+
+ int n = -4;
+ show ( n );
+
+ show ( A, B ) ;
+
+ boolean a = false;
+ boolean b = a or true;
+ if ( not a and b ) ;
+ return;
+ }
+ {
+ // test try
+ float x = nan ; int z = 0 ;
+ try {
+// throw ( 3 * 4 + 33 ) ;
+ int zz ; goto ( 12 ) ; z = 1 ; z = 0 / 0 ; z = 2 ;
+ }
+ catch ( 45 + 0 * 6000 )
+ {
+ show( "Exception 6000", z ) ;
+ }
+ catch ( x == 0 ) { show( "x nul" ) ; }
+ finally { show ( "fini" ) ; }
+ show ( "continue" );
+ return;
+ }
+ {
+ // test des if
+ int a = 3;
+ if ( a == 3 ) show ( "33");
+ else show ( "44");
+ if ( a != 3 ) show ( "333");
+ else show ( "444");
+ return;
+ }
+ {
+ int a = 0;
+ // test break
+un:
+ while ( true )
+ {
+deux:
+ while ( true )
+ {
+ a++;
+ if ( a == 2 ) continue;
+ if ( a == 3 ) break deux;
+ show ( a ) ;
+ if ( a == 5 ) break un;
+ }
+ show ( "DEUX" );
+ }
+ return;
+ }
+ {
+ // test switch
+ int a = 0;
+
+ switch ( a )
+ {
+ case 1 : show( "un" ) ; break;
+ case 2 : show( "deux" ) ; // break;
+ case 3 : show( "trois" ) ; break;
+ case 4 : show( "quatre" ) ; // break;
+ default : show( "par défaut" ) ;
+ }
+ return;
+ }
+ {
+ // test boucle while
+ float z = 3.3;
+ while ( z > 0 )
+ { show ( z-- ) ; }
+ return;
+ }
+
+ {
+ // test boucle do
+ float y = 3.3;
+ do { int x = 0; show(y); y++; } while ( y < 7 ) ;
+ return;
+ }
+ // test boucle for
+ int j = -7; show ( j );
+ for ( int ii = 3, j = 31; ii < 6 ; ++ii, j = j -3 )
+ {
+ j = 10 * j;
+ show ( ii, j );
+ }
+ return;
+{
+ // déclarations de variables
+ int a; int b = 3; int c = 4*b, d = 1, e;
+ float x; float y = 3.3; float z = y / 2, u = 1, v;
+ boolean t; boolean tt = true or false; boolean ttt = false, tttt = true, t5;
+ string s; string ss = "hello"; string s2 = ss + " plus", s3 = "s3", s4;
+
+ show( b, c, d );
+ show( y, z, u );
+ show( tt, ttt, tttt );
+ show( ss, s2, s3 );
+}
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/TestCB1.txt b/test/cbot/scenarios/TestCB1.txt
new file mode 100644
index 0000000..516db47
--- /dev/null
+++ b/test/cbot/scenarios/TestCB1.txt
@@ -0,0 +1,18 @@
+extern public void toto()
+{
+ print( "hello" ) ;
+ print( fac(5) );
+ print( t() ) ;
+}
+
+public int fac(int n)
+{
+ if ( n<2 ) return 1;
+ return n * fac(n-1);
+}
+
+point t()
+{
+ point a(1,2);
+ return a;
+}
diff --git a/test/cbot/scenarios/TestCBot1.txt b/test/cbot/scenarios/TestCBot1.txt
new file mode 100644
index 0000000..d27b4f8
--- /dev/null
+++ b/test/cbot/scenarios/TestCBot1.txt
@@ -0,0 +1,27 @@
+
+class CPoint2
+{
+ float x, y;
+ void CPoint2(float x, float y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+}
+
+public extern void T ( )
+{
+ CPoint2 X( 12, 33 ), Y ( -4, 4/3 );
+ print ( X, Y ) ;
+}
+
+public extern void Hello ( )
+
+{
+ println ( "Hello" );
+}
+
+public extern void test ( int n )
+{
+ for ( int i = n; i>0 ; i--) print (i);
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/TestCBot3.txt b/test/cbot/scenarios/TestCBot3.txt
new file mode 100644
index 0000000..b915f96
--- /dev/null
+++ b/test/cbot/scenarios/TestCBot3.txt
@@ -0,0 +1,24 @@
+public extern void Test ()
+{
+ for ( int x = 100000; x>0 ; x-- ) { }
+}
+
+float MaRoutine( CPoint A, CPoint B )
+{
+ A.x -= B.x ; // distance en x
+ A.y -= B.y ; // distance en y
+ A.x *= A.x; // carré de la distance
+ A.y += A.y; // carré de la distance
+ println ( A, B ) ;
+ return ( A.x + A.y ) ;
+}
+
+public extern void TestAB ( )
+{
+ CPoint A(3, 5) ;
+ CPoint B(4, -2);
+ println ( A, B ) ;
+ MaRoutine( A, B ) ;
+ println ( A, B ) ;
+}
+
diff --git a/test/cbot/scenarios/TestNull.txt b/test/cbot/scenarios/TestNull.txt
new file mode 100644
index 0000000..f447245
--- /dev/null
+++ b/test/cbot/scenarios/TestNull.txt
@@ -0,0 +1,15 @@
+extern public void TestNull ()
+{
+ CPoint pointeur = null;
+
+ try {
+ pointeur.x = 4; }
+ catch ( 6007 ) {}
+
+ pointeur = new CPoint(1,2);
+
+ print ( pointeur.x, pointeur.y,
+ pointeur );
+
+ pointeur.x = 5;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/TestRestoreState.txt b/test/cbot/scenarios/TestRestoreState.txt
new file mode 100644
index 0000000..1e49e37
--- /dev/null
+++ b/test/cbot/scenarios/TestRestoreState.txt
@@ -0,0 +1,67 @@
+// routine de Daniel qui plante après RestoreState
+
+extern void object::Attack( )
+{
+ int list[], i;
+ object p;
+ float dist, prox;
+ point nav1, nav2, dest;
+ boolean advance = true;
+
+ i = 0;
+ list[i++] = WingedGrabber;
+ list[i++] = TrackedGrabber;
+ list[i++] = WheeledGrabber;
+ list[i++] = LeggedGrabber;
+ list[i++] = WingedShooter;
+ list[i++] = TrackedShooter;
+ list[i++] = WheeledShooter;
+ list[i++] = LeggedShooter;
+ list[i++] = WingedOrgaShooter;
+ list[i++] = TrackedOrgaShooter;
+ list[i++] = WheeledOrgaShooter;
+ list[i++] = LeggedOrgaShooter;
+ list[i++] = WingedSniffer;
+ list[i++] = TrackedSniffer;
+ list[i++] = WheeledSniffer;
+ list[i++] = LeggedSniffer;
+ list[i++] = Thumper;
+ list[i++] = PhazerShooter;
+ list[i++] = Recycler;
+ list[i++] = Shielder;
+ list[i++] = Subber;
+ list[i++] = Me;
+
+ nav1.x = 1;//cmdline(0);
+ nav1.y = 1;//cmdline(1);
+ nav2.x = 2;//cmdline(2);
+ nav2.y = 2;//cmdline(3);
+
+ while ( true )
+ {
+ while ( true )
+ {
+ // ennemi à proximité ?
+ p = radar(list, 0, 360, 0, 40);
+ if ( p == null ) break;
+ // lui tire dessus
+ fire(p.position);
+ }
+
+ // se promène vers le point A
+ goto(nav1);
+
+ while ( true )
+ {
+ // ennemi à proximité ?
+ p = radar(list, 0, 360, 0, 40);
+ if ( p == null ) break;
+ // lui tire dessus
+ fire(p.position);
+ }
+
+ // se promène vers le point B
+ goto(nav2);
+ }
+}
+
diff --git a/test/cbot/scenarios/TestStatic.txt b/test/cbot/scenarios/TestStatic.txt
new file mode 100644
index 0000000..f501aa5
--- /dev/null
+++ b/test/cbot/scenarios/TestStatic.txt
@@ -0,0 +1,31 @@
+class ESSAI
+{
+ int x = 0;
+ static int nb = 3;
+ static int [ ] array ;
+
+ void Put( int val)
+ {
+show(nb);
+ array[ nb ] = val;
+// this.nb++;
+ this.nb = this.nb + 1;
+show(nb, array);
+ }
+ int Get( )
+ {
+ nb--;
+show("out", nb, array);
+ return array[ nb ] ;
+ }
+}
+
+extern public void T()
+{
+ ESSAI t1 ( ) ;
+ ESSAI t2 ( ) ;
+ t1.nb++;
+ t1.Put( 11 ); t1.Put( 12 ); t2.Put( 13 );
+
+ show ( t1.Get(), t2.Get(), t2.Get() ) ;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/TestStr.txt b/test/cbot/scenarios/TestStr.txt
new file mode 100644
index 0000000..683ec1b
--- /dev/null
+++ b/test/cbot/scenarios/TestStr.txt
@@ -0,0 +1,17 @@
+extern public void TSTR()
+{
+ string s = "C'est un essai";
+
+ print ( s, strlen(s), strleft(s, 3), strright(s,3), strmid(s, 2), strmid(s,2,3), strfind(s, "un"), strfind(s, "sdgfld") );
+
+ show ( strupper(s), strlower(s) );
+
+ s = "123.45" ;
+ print ( strval(s) );
+
+
+ string sub = strright("abcdef", 2); // sub vaut "ef###", # étant un caractère bizarre quelconque
+ show (sub);
+ int pos = strfind("abcdef", "xy"); // pos vaut -1. Pourquoi pas nan ?
+ show(pos);
+}
diff --git a/test/cbot/scenarios/Z.txt b/test/cbot/scenarios/Z.txt
new file mode 100644
index 0000000..714119b
--- /dev/null
+++ b/test/cbot/scenarios/Z.txt
@@ -0,0 +1,14 @@
+public extern void tp()
+{
+ int a [4], b[];
+ a [ 0 ] = 8 ;
+
+ b = T ( a ) ;
+ show ( a, b );
+}
+
+int[] T ( int[] Z )
+{
+ for ( int i = 0; i < 4 ; i++ ) Z[ i ] = i * i ;
+ return Z;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/a.txt b/test/cbot/scenarios/a.txt
new file mode 100644
index 0000000..6107342
--- /dev/null
+++ b/test/cbot/scenarios/a.txt
@@ -0,0 +1,312 @@
+object radarGuepe(point orig, float dist)
+{
+ int i;
+ object pr, r;
+ float mindist;
+
+ i = 0;
+ mindist = 1000;
+ while (i<30)
+ {
+ pr = radar(i);
+ if (pr != null)
+ {
+
+ if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
+ {
+ mindist = distance(orig, pr.position);
+ r = pr;
+ }
+ }
+ i = i+1;
+ }
+ if (mindist < dist) return(r); else return(null);
+}
+
+
+class Guepe
+{
+
+ point pos;
+
+
+ void cherche(point orig, float dist)
+ {
+ object p;
+ point o;
+
+ p = radarGuepe(orig, dist);
+ while (p == null)
+ {
+ wait(0.1);
+ p = radarGuepe(orig, dist);
+ }
+
+ pos.x = p.position.x;
+ pos.y = p.position.y;
+ pos.z = p.position.z;
+
+ //o = p.position;
+ //wait(0.1);
+
+ //vitessex = (p.position.x - o.x)/0.1;
+ //vitessey = (p.position.y - o.y)/0.1;
+ //vitessez = (p.position.z - o.z)/0.1;
+
+ }
+
+
+ void tire(point orig, float orient)
+ {
+ //float t = 3; //temps d'anticipation
+ float angle;
+ point cible;
+
+ cible.x = pos.x;// + t*vitessex;
+ cible.y = pos.y;// + t*vitessey;
+ cible.z = pos.z;// + t*vitessez;
+
+ if (cible.x == 0) angle = 90; else
+ angle = atan(cible.y / cible.x);
+ if (cible.x < 0) angle = angle + 180;
+ angle = angle - orient;
+ if (angle > 180) angle = angle - 360;
+ if (angle < -180) angle = angle + 360;
+ turn(angle);
+
+ angle = atan((cible.z-orig.z) / distance2d(orig, cible));
+ aim(angle);
+
+ fire(0.1);
+
+ }
+}
+
+extern void object::Fourmi6()
+{
+ //fps(1000);
+ Guepe guepe = new Guepe();
+
+ while (true)
+ {
+ guepe.cherche(position, 50);
+
+ guepe.tire(position, orientation);
+ }
+}
+object radarGuepe(point orig, float dist)
+{
+ int i;
+ object pr, r;
+ float mindist;
+
+ i = 0;
+ mindist = 1000;
+ while (i<30)
+ {
+ pr = radar(i);
+ if (pr != null)
+ {
+
+ if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
+ {
+ mindist = distance(orig, pr.position);
+ r = pr;
+ }
+ }
+ i = i+1;
+ }
+ if (mindist < dist) return(r); else return(null);
+}
+
+
+class Guepe
+{
+
+ point pos;
+
+
+ void cherche(point orig, float dist)
+ {
+ object p;
+ point o;
+
+ p = radarGuepe(orig, dist);
+ while (p == null)
+ {
+ wait(0.1);
+ p = radarGuepe(orig, dist);
+ }
+
+ pos.x = p.position.x;
+ pos.y = p.position.y;
+ pos.z = p.position.z;
+
+ //o = p.position;
+ //wait(0.1);
+
+ //vitessex = (p.position.x - o.x)/0.1;
+ //vitessey = (p.position.y - o.y)/0.1;
+ //vitessez = (p.position.z - o.z)/0.1;
+
+ }
+
+
+ void tire(point orig, float orient)
+ {
+ //float t = 3; //temps d'anticipation
+ float angle;
+ point cible;
+
+ cible.x = pos.x;// + t*vitessex;
+ cible.y = pos.y;// + t*vitessey;
+ cible.z = pos.z;// + t*vitessez;
+
+ if (cible.x == 0) angle = 90; else
+ angle = atan(cible.y / cible.x);
+ if (cible.x < 0) angle = angle + 180;
+ angle = angle - orient;
+ if (angle > 180) angle = angle - 360;
+ if (angle < -180) angle = angle + 360;
+ turn(angle);
+
+ angle = atan((cible.z-orig.z) / distance2d(orig, cible));
+ aim(angle);
+
+ fire(0.1);
+
+ }
+}
+
+extern void object::Fourmi6()
+{
+ //fps(1000);
+ Guepe guepe = new Guepe();
+
+ while (true)
+ {
+ guepe.cherche(position, 50);
+
+ guepe.tire(position, orientation);
+ }
+}
+object radarGuepe(point orig, float dist)
+{
+ int i;
+ object pr, r;
+ float mindist;
+
+ i = 0;
+ mindist = 1000;
+ while (i<30)
+ {
+ pr = radar(i);
+ if (pr != null)
+ {
+
+ if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
+ {
+ mindist = distance(orig, pr.position);
+ r = pr;
+ }
+ }
+ i = i+1;
+ }
+ if (mindist < dist) return(r); else return(null);
+}
+
+
+class Guepe
+{
+
+ point pos;
+
+
+ void cherche(point orig, float dist)
+ {
+ object p;
+ point o;
+
+ p = radarGuepe(orig, dist);
+ while (p == null)
+ {
+ wait(0.1);
+ p = radarGuepe(orig, dist);
+ }
+
+ pos.x = p.position.x;
+ pos.y = p.position.y;
+ pos.z = p.position.z;
+
+ //o = p.position;
+ //wait(0.1);
+
+ //vitessex = (p.position.x - o.x)/0.1;
+ //vitessey = (p.position.y - o.y)/0.1;
+ //vitessez = (p.position.z - o.z)/0.1;
+
+ }
+
+
+ void tire(point orig, float orient)
+ {
+ //float t = 3; //temps d'anticipation
+ float angle;
+ point cible;
+
+ cible.x = pos.x;// + t*vitessex;
+ cible.y = pos.y;// + t*vitessey;
+ cible.z = pos.z;// + t*vitessez;
+
+ if (cible.x == 0) angle = 90; else
+ angle = atan(cible.y / cible.x);
+ if (cible.x < 0) angle = angle + 180;
+ angle = angle - orient;
+ if (angle > 180) angle = angle - 360;
+ if (angle < -180) angle = angle + 360;
+ turn(angle);
+
+ angle = atan((cible.z-orig.z) / distance2d(orig, cible));
+ aim(angle);
+
+ fire(0.1);
+
+ }
+}
+
+extern void object::Fourmi6()
+{
+ //fps(1000);
+ Guepe guepe = new Guepe();
+
+ while (true)
+ {
+ guepe.cherche(position, 50);
+
+ guepe.tire(position, orientation);
+ }
+}
+
+public extern void TestTableau ()
+{
+ int tableau [ 12 ] ;
+
+ point array[ 12 ] [ 14 ] ;
+
+ point zéro ( 1, 2 ) ;
+ point a = zéro ;
+
+ for ( int i = 0 ; i < 10 ; i++ ) array[ i ] [ i ]= zéro ;
+
+ array[ 5 ] [3 ] . x =1.5 ;
+
+ array[ 2 ] [ 2 ] . y = array[ 5 ] [ 5 ] . x ;
+
+ array[ 4 ] = array [ 2 ] ;
+
+ for ( int i = 0 ; i < 10 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) println ( i, j, array [ i ] [ j ] ) ;
+
+ show( zéro, a, array );
+
+}
+
diff --git a/test/cbot/scenarios/bug.txt b/test/cbot/scenarios/bug.txt
new file mode 100644
index 0000000..4ec6eb3
--- /dev/null
+++ b/test/cbot/scenarios/bug.txt
@@ -0,0 +1,12 @@
+public extern void object::Bug()
+{
+ point a;
+ a = position;
+ TEST();
+ float d=dist(a, position);
+}
+
+float dist(point a, point b)
+{
+ return a.x-b.x;
+}
diff --git a/test/cbot/scenarios/bugmw.txt b/test/cbot/scenarios/bugmw.txt
new file mode 100644
index 0000000..284ee43
--- /dev/null
+++ b/test/cbot/scenarios/bugmw.txt
@@ -0,0 +1,9 @@
+extern public void main()
+{
+ show(fact(30)) ;
+}
+
+public int fact(int n)
+{
+ return (fact(n-1)*n) ;
+}
diff --git a/test/cbot/scenarios/ccc.txt b/test/cbot/scenarios/ccc.txt
new file mode 100644
index 0000000..dbcd1d5
--- /dev/null
+++ b/test/cbot/scenarios/ccc.txt
@@ -0,0 +1,8 @@
+public extern void ccc()
+{
+ int a;
+ a = 0 ;
+
+ if ( a == 0 );
+
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/enum.txt b/test/cbot/scenarios/enum.txt
new file mode 100644
index 0000000..a592a7f
--- /dev/null
+++ b/test/cbot/scenarios/enum.txt
@@ -0,0 +1,9 @@
+
+enum JourDeLaSemaine {
+ lundi = 1,
+ mardi,
+ mercredi,
+ jeudi,
+ vendredi,
+ samedi,
+ dimanche = 0 } \ No newline at end of file
diff --git a/test/cbot/scenarios/fibo.txt b/test/cbot/scenarios/fibo.txt
new file mode 100644
index 0000000..88f5357
--- /dev/null
+++ b/test/cbot/scenarios/fibo.txt
@@ -0,0 +1,25 @@
+
+extern public int Fibo( int n, boolean b )
+{
+ if ( n < 2 ) return n;
+ int a = Fibo(n-1, b) + Fibo(n-2, false);
+ if ( b ) print (n + "=" + a);
+ return a;
+}
+
+extern public void t()
+{
+ Fibo( 23, true);
+}
+
+extern public void tt()
+{
+ t();
+}
+
+// cette routine n'est évidemment pas du tout obtimisée
+// c'est même un très mauvais exemple de programmation récursive
+
+// pour un test de durée, Fibo(23, true) prend
+// en mode Debug 67 secondes
+// en mode Release 8 secondes
diff --git a/test/cbot/scenarios/file.txt b/test/cbot/scenarios/file.txt
new file mode 100644
index 0000000..2a22dd9
--- /dev/null
+++ b/test/cbot/scenarios/file.txt
@@ -0,0 +1,70 @@
+class CLASS22
+{
+ static int nb = 2;
+ void T22 ( ) { nb = nb / 0 ; }
+}
+
+public extern void object :: TEST()
+{
+ switch ( 1 )
+ {
+ case 1:
+ {
+ file h();
+ h.open("Mon Fichier.txt", "r");
+show ( h.filename, h.handle );
+h.filename = "xx";
+h.handle = 1 ;
+ h.readln();
+ h.close();
+ }
+ case 2:
+ {
+ file h("Mon Fichier.txt");
+ h.open("r");
+ h.readln();
+ h.close();
+ }
+ case 3:
+ {
+ file h("Mon Fichier.txt", "r");
+ h.readln();
+ h.close();
+ }
+ case 4:
+ {
+ file h();
+ h.filename = "Mon Fichier.txt";
+ h.open("r");
+ h.readln();
+ h.close();
+ }
+ case 5:
+ {
+ file h = fileopen( "Mon 2Fichier.txt", "r" );
+ h.readln();
+ h.close();
+ }
+ }
+{
+ file h( ) ;
+ h.filename = "Test.h";
+ h.open ( "r" );
+
+
+ file pf ( "Mon Fichier.txt" ) ;
+ pf . open ( "w" ) ;
+ pf . writeln ( "Voici encore du texte" ) ;
+ pf . writeln ( "et une seconde ligne" ) ;
+ pf . close( );
+
+ pf . open ( "r" ) ;
+
+ while ( not pf . eof( ) )
+ {
+ string s = pf . readln ( );
+ show ( s );
+ }
+ pf.close( );
+}
+}
diff --git a/test/cbot/scenarios/h.txt b/test/cbot/scenarios/h.txt
new file mode 100644
index 0000000..c395319
--- /dev/null
+++ b/test/cbot/scenarios/h.txt
@@ -0,0 +1,5 @@
+void tf()
+{
+ file h;
+ h.handle += 1 ;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/include.txt b/test/cbot/scenarios/include.txt
new file mode 100644
index 0000000..e8f8cc9
--- /dev/null
+++ b/test/cbot/scenarios/include.txt
@@ -0,0 +1,27 @@
+class Z
+{
+ static int x = 0;
+ private int y;
+
+ void T( )
+ {
+ // autorisé ici
+ y = x ;
+ this.y = this.x ;
+ x = y ;
+ this.x = this.y ;
+ }
+}
+
+extern public void test()
+{
+ Z a();
+ 3 * a.x; // autorisé
+//vu 3 * a.y; // interdit
+//vu a.y = 3; // interdit ici
+ a.x = 1; // autorisé
+
+ show ( a );
+ a.T();
+ show ( a );
+}
diff --git a/test/cbot/scenarios/intrinsic.txt b/test/cbot/scenarios/intrinsic.txt
new file mode 100644
index 0000000..f215791
--- /dev/null
+++ b/test/cbot/scenarios/intrinsic.txt
@@ -0,0 +1,16 @@
+public extern void TestIntrinsic()
+{
+ point a ( 1, 2 );
+ print (a);
+
+ a.x = 3;
+ a.y = 4;
+
+ point b = a;
+
+ println ( b.x, b.y, b ) ;
+ if ( b == a ) b.y = 0;
+ println (a,b);
+ if ( b != a ) b.y = a.y;
+ println(a,b);
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/methode1.txt b/test/cbot/scenarios/methode1.txt
new file mode 100644
index 0000000..080bba2
--- /dev/null
+++ b/test/cbot/scenarios/methode1.txt
@@ -0,0 +1,57 @@
+class t {
+ point p;
+}
+
+void object :: toto()
+{
+ show ( Position ) ;
+}
+
+extern public void object :: XX()
+{
+ int test [];
+ test [ 9999 ] = 3;
+
+ toto () ;
+/*
+ Radar();
+
+ object test ;
+ test = this. Radar();
+
+ do {
+ test = this.Radar();
+ } while ( test == null );
+
+/*
+ t test [ 4 ];
+ for ( int i = 0 ; i < 4 ; i++ ) test [ i ] = new t();
+ test [ 3 ] .p.x = 2;
+ show ( test );
+/*
+ int a = nan;
+ show ( a ) ;
+
+ a = TypeMarkPath;
+ show ( a, a++, --a ) ;
+
+ if ( a != nan ) a += 1 ;
+
+ a = TypeMarkPath;
+ float q = a ;
+ show ( a, q ) ;
+
+return;
+
+ a += ++a;
+ show ( a ) ;
+
+ boolean i = false;
+
+ if ( i == true ) {}
+
+ object p;
+ if ( p == null) { p = p ; }
+*/
+}
+
diff --git a/test/cbot/scenarios/methode2.txt b/test/cbot/scenarios/methode2.txt
new file mode 100644
index 0000000..76ce7f4
--- /dev/null
+++ b/test/cbot/scenarios/methode2.txt
@@ -0,0 +1,50 @@
+
+extern void Toto()
+{
+ TEST(12);
+
+ for ( int i = 0 ; i<1000; i++)
+ {
+ int j = 1;
+ if (i==55) TEST(12);
+ }
+
+ TEST(2);
+
+
+// Nouveau();
+ int toto[4];
+ point Z[3];
+
+ Z[1].x = 11; Z[1].y = 12;
+
+ toto[2] = 12;
+ toto[1] = nan;
+
+// point test, autre(2,3) ;
+// object titi = Radar();
+
+ TEST ( 1 ) ;
+
+ toto[0] = 11;
+
+ TEST ( 2 ) ;
+
+ toto[6] = 0;
+}
+
+extern void object::Nouveau()
+{
+ point a;
+ a = np(Position);
+}
+
+point np(point b)
+{
+ point c;
+ c.x = b.y;
+ c.y = b.x;
+ return c ;
+}
+
+
diff --git a/test/cbot/scenarios/mp1.txt b/test/cbot/scenarios/mp1.txt
new file mode 100644
index 0000000..599cfc4
--- /dev/null
+++ b/test/cbot/scenarios/mp1.txt
@@ -0,0 +1,25 @@
+class Guepet
+{
+
+ float a;
+ float b;
+
+ void init()
+ {
+ a = 12.34;
+ b = 56.78;
+ }
+
+
+}
+
+extern void object::Fourmi6()
+{
+ Guepet guepe =new Guepet();
+
+ guepe.init();
+
+
+ show("test "+guepe.a+" "+guepe.b);
+
+}
diff --git a/test/cbot/scenarios/mp2.txt b/test/cbot/scenarios/mp2.txt
new file mode 100644
index 0000000..1c2972c
--- /dev/null
+++ b/test/cbot/scenarios/mp2.txt
@@ -0,0 +1,28 @@
+class Guepet
+{
+
+ float a;
+ float b;
+
+ void init()
+ {
+ a = 12.34;
+ b = 56.78;
+
+ object x = radar(123);
+ show("radar "+x.position.x);
+ show("C'est fait");
+ }
+
+
+}
+
+extern void object::Fourmi6()
+{
+ Guepet guepe=new Guepet();
+
+ guepe.init();
+
+ show("test "+guepe.a+" "+guepe.b);
+
+}
diff --git a/test/cbot/scenarios/mw.txt b/test/cbot/scenarios/mw.txt
new file mode 100644
index 0000000..c237670
--- /dev/null
+++ b/test/cbot/scenarios/mw.txt
@@ -0,0 +1,16 @@
+extern public void main()
+{
+// goto( 3, 4 );
+
+ while( true )
+ {
+ try { goto (12) ; }
+ catch( FF( ) )
+ { show( "ko"); }
+ }
+}
+
+boolean FF()
+{
+ return false;
+}
diff --git a/test/cbot/scenarios/null.txt b/test/cbot/scenarios/null.txt
new file mode 100644
index 0000000..ae76b74
--- /dev/null
+++ b/test/cbot/scenarios/null.txt
@@ -0,0 +1,5 @@
+extern public void xxx ()
+{
+ CPoint test = null ;
+ if ( test == null ) show ( "NULL" );
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/opnew.txt b/test/cbot/scenarios/opnew.txt
new file mode 100644
index 0000000..7d6838c
--- /dev/null
+++ b/test/cbot/scenarios/opnew.txt
@@ -0,0 +1,20 @@
+extern public void xx ()
+{
+ CPoint pointeur, test = null ;
+ pointeur = new CPoint ( 3, 4 );
+
+ if ( test == null ) show ( "NULL" );
+
+ CPoint pp = pointeur;
+
+show( pointeur , pp );
+
+ pp.x = 33.3;
+ if ( pointeur.x != pp.x ) 0/0;
+
+ pp = new CPoint();
+// pointeur = pp;
+
+show( pointeur , pp );
+
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/plante.txt b/test/cbot/scenarios/plante.txt
new file mode 100644
index 0000000..363461b
--- /dev/null
+++ b/test/cbot/scenarios/plante.txt
@@ -0,0 +1,25 @@
+class Guepet
+{
+
+ point pos;
+ float t = 0.1;
+
+ void init()
+ {
+ pos.x = 12.123;
+ pos.y = 34.345;
+
+ F(t);
+ }
+
+
+}
+
+extern void object::Fourmi6()
+{
+ Guepet guepe=new Guepet();
+
+ guepe.init();
+
+ show ( guepe );
+}
diff --git a/test/cbot/scenarios/pointer.txt b/test/cbot/scenarios/pointer.txt
new file mode 100644
index 0000000..2d4d907
--- /dev/null
+++ b/test/cbot/scenarios/pointer.txt
@@ -0,0 +1,41 @@
+extern public void x ()
+{
+ show ( 3 ** 4 );
+ float z = 1e-3;
+ show ( z );
+
+ CPoint b ( 4,5 );
+ show ( b );
+
+ CPoint a ( ) ;
+ a.x = 21; a.y = 12;
+ show ( a ) ;
+
+ CPoint test = new CPoint ( 1,1 );
+ test = new CPoint ( 2, 2 );
+ show ( test );
+}
+
+// crée un objet et retourne son pointeur
+CPoint newcpoint()
+{
+ CPoint p = new CPoint ( 3, 3 );
+ return p;
+}
+
+extern public void y ()
+{
+ CPoint test = newcpoint();
+ println ( test );
+ dontmodif( test );
+ println ( test );
+}
+
+// ne doit pas modifier l'objet en paramètre
+void dontmodif ( CPoint pp )
+{
+ pp.x = 5;
+ pp.y = 2;
+ println ( pp, pp.x, pp.y );
+}
+
diff --git a/test/cbot/scenarios/postinc.txt b/test/cbot/scenarios/postinc.txt
new file mode 100644
index 0000000..cdf6ab5
--- /dev/null
+++ b/test/cbot/scenarios/postinc.txt
@@ -0,0 +1,7 @@
+extern public void X()
+{
+ point A [ ] ;
+ A[5] = new point (2,3);
+ int val = A[5].x++ + --A[5].y;
+ show ( A, val );
+}
diff --git a/test/cbot/scenarios/radar.txt b/test/cbot/scenarios/radar.txt
new file mode 100644
index 0000000..09d84a2
--- /dev/null
+++ b/test/cbot/scenarios/radar.txt
@@ -0,0 +1,39 @@
+extern void object::Bug( )
+{
+ try{ int a = 44 ; a = 12 / 0 ; }
+ catch(6000) { int b = 4 ; }
+ finally { int z = 1 ; }
+
+// tp ( A, B );
+
+/* int a = 4, b = 2, c = nan;
+ float x, y = 3/2, z = nan;
+ boolean i, j = false, k = true;
+
+ string s, ss = "xyz";
+
+ while ( false )
+ {
+ object left, right;
+
+ left = Radar(TypeMarkPath, -45, 120, 100);
+ right = Radar(TypeMarkPath, 45, 120, 100);
+
+ if ( left == null && right == null )
+ {
+ }
+ }
+ int t = fact ( 4 ) ;*/
+}
+
+void tp( point a , point b )
+{
+ a.x += b.x;
+}
+
+
+int fact( int n )
+{
+ if ( n < 2 ) return n;
+ return n * fact ( n - 1 ) ;
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/solution.txt b/test/cbot/scenarios/solution.txt
new file mode 100644
index 0000000..f78cf12
--- /dev/null
+++ b/test/cbot/scenarios/solution.txt
@@ -0,0 +1,13 @@
+extern void object::Solution( )
+{
+show ( "Solution " + Position );
+ Carré(15);
+ Carré(25);
+}
+
+void object::Carré(float côté)
+{
+show ( "Carré " + Position );
+ Move(côté);
+ Turn(-90);
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/test.txt b/test/cbot/scenarios/test.txt
new file mode 100644
index 0000000..0693994
--- /dev/null
+++ b/test/cbot/scenarios/test.txt
@@ -0,0 +1,8 @@
+extern public void x()
+{
+ float a= 1, b = 2;
+ a = b * ( 2 + 2 );
+ print (a);
+ a += 4;
+ print (a);
+}
diff --git a/test/cbot/scenarios/test23.txt b/test/cbot/scenarios/test23.txt
new file mode 100644
index 0000000..d6e1ddd
--- /dev/null
+++ b/test/cbot/scenarios/test23.txt
@@ -0,0 +1,10 @@
+extern public void object::TEST23()
+{
+ CLASS22 T;
+ T.T22( ) ;
+
+ show( position );
+ show( this.position );
+
+// T22();
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/testmw.txt b/test/cbot/scenarios/testmw.txt
new file mode 100644
index 0000000..6570f6d
--- /dev/null
+++ b/test/cbot/scenarios/testmw.txt
@@ -0,0 +1,14 @@
+extern public int testmw( int a)
+{
+ boolean b = true ;
+
+ if (b)
+ return 1 ;
+ else
+ return a ; 0 * testmw(a-1) ;
+}
+
+public int Fibo2 ( int n )
+{
+ print ( " bof " );
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/this.txt b/test/cbot/scenarios/this.txt
new file mode 100644
index 0000000..b8a9e04
--- /dev/null
+++ b/test/cbot/scenarios/this.txt
@@ -0,0 +1,13 @@
+extern void object :: TEST22 ( )
+{
+ show( position );
+ show( this.position );
+
+ T();
+}
+
+public void object :: T22()
+{
+ show( position );
+ show( this.position );
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/tt.txt b/test/cbot/scenarios/tt.txt
new file mode 100644
index 0000000..cd13c9d
--- /dev/null
+++ b/test/cbot/scenarios/tt.txt
@@ -0,0 +1,12 @@
+extern public void T() { T1(); }
+
+public void T1()
+{
+ show( "T1" );
+ T2();
+}
+
+public void T2()
+{
+ show( "T2" );
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/tt2.txt b/test/cbot/scenarios/tt2.txt
new file mode 100644
index 0000000..ad9dc1d
--- /dev/null
+++ b/test/cbot/scenarios/tt2.txt
@@ -0,0 +1,5 @@
+extern public void TT()
+{
+ T1();
+ T2();
+} \ No newline at end of file
diff --git a/test/cbot/scenarios/vide.txt b/test/cbot/scenarios/vide.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/cbot/scenarios/vide.txt
diff --git a/test/cbot/scenarios/zz.txt b/test/cbot/scenarios/zz.txt
new file mode 100644
index 0000000..da764ac
--- /dev/null
+++ b/test/cbot/scenarios/zz.txt
@@ -0,0 +1,6 @@
+extern public void zz()
+{
+ MaClass TOTO ();
+
+ show (TOTO);
+} \ No newline at end of file