/
test.py
executable file
·123 lines (100 loc) · 2.79 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/python2
import time
import sys
from random import random
import datetime
print """
S 1234 HOLE=`
S 4567 X=250 Y=250 BANK=0 MAP=4568 HOLE=`
S 999800 X=101 Y=101 BANK=0 MAP=99910 CELLWIDTH=7 BG=0 FG=0xFFFF00FF
S 9999 X=101 Y=101 BANK=0 MAP=99910 CELLWIDTH=7 BG=0x01000001
M 99910
_,--=--._
,' _ `.
- _(_)_o -
____' /_ _/] `____
-=====::(+):::::::::::::::::(+)::=====-
(+).""x""xx""x"",(+)
. ,
` -=- '
M 99911
+
P 0
"""
print "X 0 Test program starting."
sys.stdout.flush() #For the sake of java's too-stupid-to-live IO
sids = 0;
def getSid():
global sids
sids = sids+1
return sids
class Thing:
def __init__(self, x, y, r, dx, dy, dr, bank, map):
self.sid = getSid()
self.x = x
self.y = y
self.r = r
self.dx = dx
self.dy = dy
self.dr = dr
print "S "+str(self.sid)+" BG=0x01000001 BANK="+str(bank)+" MAP="+str(map)+"\n"
def move(self):
self.x = self.x+self.dx
self.y = self.y+self.dy
self.r = self.r+self.dr
if self.x > 500:
self.x = 0
if self.y > 500:
self.y = 0
if self.x < 0:
self.x = 500
if self.y < 0:
self.y = 500
def draw(self):
return "S " + str(self.sid) + " X="+str(self.x)+" Y="+str(self.y)+" ROT="+str(self.r)+"\n"
stars = []
for i in range(1000):
stars.append(Thing(random()*500, random()*500, 0, random()-0.5, random()-0.5, (random()-0.5)*0.05, 0, 99911))
x=100;
y=100;
r=0;
s=1;
dx=0;
dy=0;
dr=0;
ds=0;
while True:
while True:
line = raw_input()
#print "X 0 " + datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S.%f') + ":" + line
parts = line.split()
if len(parts)==0 or parts[0] == "P":
break
if len(parts)>2 and parts[0] == "KS":
#print "X 0 "+line
for part in parts[2:]:
c = part[0]
#print "X 0 ", c
if c=='A':
x=x+5
elif c=='D':
x=x-5
elif c=='W':
y=y+5
elif c=='S':
y=y-5
elif c=='Q':
r=r-0.01
elif c=='E':
r=r+0.01
elif c=='R':
s=s-0.01
elif c=='F':
s=s+0.01
for star in stars:
star.move()
print star.draw()
print "C 999800 Y="+str(y)+" X="+str(x)+" ROT="+str(r)+" SX="+str(s)+" SY="+str(s)+" VIEWWIDTH=512 VIEWHEIGHT=512 CELLWIDTH=4"
print "P 16"
sys.stdout.flush() #For the sake of java's too-stupid-to-live IO
# time.sleep(1.0/60.0)