Release v3.0
This commit is contained in:
35
OGP1718-Worms/programs/program.txt
Executable file
35
OGP1718-Worms/programs/program.txt
Executable file
@@ -0,0 +1,35 @@
|
||||
// Worm that turns towards nearest worm, fires, and moves; or turns and tries to jump if no worm is in sight.
|
||||
|
||||
def updateNearestWorm: {
|
||||
delta := 0;
|
||||
nearestWorm := null;
|
||||
turnToNearest := 0;
|
||||
while delta < 6.28: {
|
||||
obj := searchobj delta;
|
||||
if (obj != null && isworm obj):
|
||||
if !sameteam obj:
|
||||
if (nearestWorm == null) || (distance obj < distance nearestWorm): {
|
||||
nearestWorm := obj;
|
||||
turnToNearest := delta;
|
||||
}
|
||||
delta := delta + 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
// main program
|
||||
|
||||
while true: {
|
||||
invoke updateNearestWorm;
|
||||
|
||||
if nearestWorm != null: {
|
||||
print nearestWorm;
|
||||
print distance nearestWorm;
|
||||
turn turnToNearest;
|
||||
fire;
|
||||
move;
|
||||
}
|
||||
else {
|
||||
turn 0.2;
|
||||
jump;
|
||||
}
|
||||
}
|
20
OGP1718-Worms/programs/program_example.txt
Executable file
20
OGP1718-Worms/programs/program_example.txt
Executable file
@@ -0,0 +1,20 @@
|
||||
def controlled_move:
|
||||
if getap self > 100.0:
|
||||
{ jump;
|
||||
print getx self;
|
||||
print gety self; }
|
||||
else move;
|
||||
|
||||
max_distance := 10.0;
|
||||
while true: {
|
||||
w := searchobj 0.0;
|
||||
if isworm w: {
|
||||
if sameteam w:
|
||||
invoke controlled_move;
|
||||
else if distance w < max_distance:
|
||||
fire;
|
||||
else
|
||||
{ turn d;
|
||||
max_distance := max_distance + 0.1; }
|
||||
}
|
||||
}
|
3
OGP1718-Worms/programs/program_simple.txt
Executable file
3
OGP1718-Worms/programs/program_simple.txt
Executable file
@@ -0,0 +1,3 @@
|
||||
turn 0.2;
|
||||
fire;
|
||||
move;
|
54
OGP1718-Worms/programs/syntax_test.txt
Executable file
54
OGP1718-Worms/programs/syntax_test.txt
Executable file
@@ -0,0 +1,54 @@
|
||||
// don't execute this :-)
|
||||
def test_proc: {
|
||||
x := +1;
|
||||
while true:
|
||||
print false;
|
||||
if x == 1: {
|
||||
print x * x;
|
||||
} else: {}
|
||||
invoke test_proc;
|
||||
break;
|
||||
if 0-x/y*z - y * z - 2*x + 3 == 2 && true != false: {}
|
||||
move;
|
||||
jump;
|
||||
eat;
|
||||
fire;
|
||||
}
|
||||
|
||||
def secondProc: {
|
||||
invoke test_proc;
|
||||
if getx self > 0:
|
||||
invoke secondProc;
|
||||
}
|
||||
|
||||
x := ( 3 * 4 ); // comment
|
||||
// comment
|
||||
y := (-33.5 * (+55 / 1.22));
|
||||
|
||||
jump;
|
||||
turn 5;
|
||||
turn 0.2;
|
||||
turn -0.2;
|
||||
fire;
|
||||
|
||||
if (x >= 5):
|
||||
{ }
|
||||
else
|
||||
fire;
|
||||
|
||||
while y:
|
||||
{ turn (0.01);
|
||||
y := (y - 1); }
|
||||
|
||||
while y:
|
||||
{ move;
|
||||
y := (y - 1);
|
||||
if (true): { turn y; }
|
||||
else {
|
||||
while (false):
|
||||
{print y;}
|
||||
}
|
||||
}
|
||||
|
||||
if (true): { } else { invoke test_proc; }
|
||||
|
Reference in New Issue
Block a user