Removed old CBot-related files
parent
aa0946f4ba
commit
9e19d8433c
|
@ -1,42 +0,0 @@
|
|||
|
||||
for managing instances of a class.
|
||||
|
||||
the object being created with CBotVar :: Create (name, pClasse)
|
||||
is to keep as is, outside the vars on the stack
|
||||
|
||||
we need another type of variable to keep the pointers
|
||||
For example CBotTypPtClass
|
||||
|
||||
The instance of the class must have a usage count
|
||||
which is the number of class object to which they refer CBotTypPtClass.
|
||||
The counter is decremented when the pointer is destroyed,
|
||||
be deleted when there is more pointers.
|
||||
|
||||
|
||||
In the case of robots, Daniel creates an instance of class "Object"
|
||||
and can return pointers to this proceeding by routines such FindRobot ()
|
||||
|
||||
Object FindRobot (int n) {}
|
||||
|
||||
pResult in this case is a pointer CBotTypPtClass
|
||||
when he found the robot concerned, it must make
|
||||
|
||||
pResult-> SetPointeur (InstanceDeLaClassObject);
|
||||
|
||||
this operation increments the reference
|
||||
|
||||
-
|
||||
|
||||
when the robot is destroyed, the instance of the Object class corresponding
|
||||
is also destroyed.
|
||||
if there are pointers to that object, and we planted the risk
|
||||
|
||||
Solution 1:
|
||||
not keep the pointer to the object directly, but
|
||||
an index into a table of pointers
|
||||
|
||||
Solution 2:
|
||||
not destroy the object when there imédiatement pointers
|
||||
but marked as virtually destroyed
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
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 );
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
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 ) ;
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
|
||||
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 ) ;
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
class MaClass
|
||||
{
|
||||
int t = 12;
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
Voici encore du texte
|
||||
et une seconde ligne
|
|
@ -1,4 +0,0 @@
|
|||
public extern void Nop()
|
||||
{
|
||||
while ( true ) {}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
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 ( ) ;
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
public extern int T ( float n )
|
||||
{
|
||||
return n * 1.1;
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
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 );
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
|
||||
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);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
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 ) ;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
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() ) ;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,312 +0,0 @@
|
|||
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 );
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
extern public void main()
|
||||
{
|
||||
show(fact(30)) ;
|
||||
}
|
||||
|
||||
public int fact(int n)
|
||||
{
|
||||
return (fact(n-1)*n) ;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
public extern void ccc()
|
||||
{
|
||||
int a;
|
||||
a = 0 ;
|
||||
|
||||
if ( a == 0 );
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
enum JourDeLaSemaine {
|
||||
lundi = 1,
|
||||
mardi,
|
||||
mercredi,
|
||||
jeudi,
|
||||
vendredi,
|
||||
samedi,
|
||||
dimanche = 0 }
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
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
|
|
@ -1,70 +0,0 @@
|
|||
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( );
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
void tf()
|
||||
{
|
||||
file h;
|
||||
h.handle += 1 ;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
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 );
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
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 ; }
|
||||
*/
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
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 ;
|
||||
}
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
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);
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
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);
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
extern public void main()
|
||||
{
|
||||
// goto( 3, 4 );
|
||||
|
||||
while( true )
|
||||
{
|
||||
try { goto (12) ; }
|
||||
catch( FF( ) )
|
||||
{ show( "ko"); }
|
||||
}
|
||||
}
|
||||
|
||||
boolean FF()
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
extern public void xxx ()
|
||||
{
|
||||
CPoint test = null ;
|
||||
if ( test == null ) show ( "NULL" );
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
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 );
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
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 );
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
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 );
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
extern public void X()
|
||||
{
|
||||
point A [ ] ;
|
||||
A[5] = new point (2,3);
|
||||
int val = A[5].x++ + --A[5].y;
|
||||
show ( A, val );
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
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 ) ;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
extern public void x()
|
||||
{
|
||||
float a= 1, b = 2;
|
||||
a = b * ( 2 + 2 );
|
||||
print (a);
|
||||
a += 4;
|
||||
print (a);
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
extern public void object::TEST23()
|
||||
{
|
||||
CLASS22 T;
|
||||
T.T22( ) ;
|
||||
|
||||
show( position );
|
||||
show( this.position );
|
||||
|
||||
// T22();
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
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 " );
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
extern void object :: TEST22 ( )
|
||||
{
|
||||
show( position );
|
||||
show( this.position );
|
||||
|
||||
T();
|
||||
}
|
||||
|
||||
public void object :: T22()
|
||||
{
|
||||
show( position );
|
||||
show( this.position );
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
extern public void T() { T1(); }
|
||||
|
||||
public void T1()
|
||||
{
|
||||
show( "T1" );
|
||||
T2();
|
||||
}
|
||||
|
||||
public void T2()
|
||||
{
|
||||
show( "T2" );
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
extern public void TT()
|
||||
{
|
||||
T1();
|
||||
T2();
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
extern public void zz()
|
||||
{
|
||||
MaClass TOTO ();
|
||||
|
||||
show (TOTO);
|
||||
}
|
Loading…
Reference in New Issue