update text format
This commit is contained in:
parent
f26b464ff9
commit
33beb61e27
|
@ -7,7 +7,7 @@
|
|||
struct STATE
|
||||
{
|
||||
double x, y, a;
|
||||
double s, life;
|
||||
double score, life;
|
||||
int tockens, boat, dsize, vlast;
|
||||
int dlist[10];
|
||||
};
|
||||
|
@ -111,7 +111,7 @@ void forward(struct STATE *state, double l)
|
|||
int c1, c2, i, k, xr, yr, in, ls;
|
||||
double a, d, destx, desty;
|
||||
|
||||
state->s -= 0.1;
|
||||
state->score -= 0.1;
|
||||
|
||||
a = state->a * M_PI / 180.0;
|
||||
destx = state->x + l * cos(a);
|
||||
|
@ -128,7 +128,7 @@ void forward(struct STATE *state, double l)
|
|||
if(c1 == 1 || c2 == 1 || ((c1 == 3 || c2 == 3) && !state->boat)) break;
|
||||
|
||||
d = hypot(lx[k] - state->x, ly[k] - state->y) * (0.2 + (c1 == 5) * 0.1 + (c1 == 4) * 0.2 + (c1 == 2) * 0.3);
|
||||
state->s -= d;
|
||||
state->score -= d;
|
||||
state->life -= d;
|
||||
|
||||
state->x = lx[k];
|
||||
|
@ -149,7 +149,7 @@ void forward(struct STATE *state, double l)
|
|||
if(!in && state->life >= 100)
|
||||
{
|
||||
state->life = MAX(state->life - 100, 0);
|
||||
state->s += 100;
|
||||
state->score += 100;
|
||||
state->tockens += 1;
|
||||
state->dlist[state->dsize] = xr;
|
||||
state->dsize += 1;
|
||||
|
@ -184,10 +184,10 @@ double score(double *steps, int size)
|
|||
double position[3];
|
||||
struct STATE state;
|
||||
|
||||
x = steps[2];
|
||||
a = steps[3];
|
||||
y = steps[4];
|
||||
b = steps[5];
|
||||
x = steps[4];
|
||||
a = steps[5];
|
||||
y = steps[6];
|
||||
b = steps[7];
|
||||
|
||||
position[0] = x + a * 1e-14;
|
||||
position[1] = y + b * 1e-14;
|
||||
|
@ -196,16 +196,16 @@ double score(double *steps, int size)
|
|||
state.x = x + a * 1e-14;
|
||||
state.y = y + b * 1e-14;
|
||||
state.a = 0;
|
||||
state.s = 0;
|
||||
state.life = 250;
|
||||
state.tockens = 1;
|
||||
state.boat = steps[0];
|
||||
state.dsize = steps[1];
|
||||
state.score = 0;
|
||||
state.life = steps[0];
|
||||
state.tockens = steps[1];
|
||||
state.boat = steps[2];
|
||||
state.dsize = steps[3];
|
||||
state.vlast = 0;
|
||||
|
||||
i = 0;
|
||||
|
||||
for(i = 6; i < size - 3; i += 4)
|
||||
for(i = 8; i < size - 3; i += 4)
|
||||
{
|
||||
x = steps[i + 0];
|
||||
a = steps[i + 1];
|
||||
|
@ -224,9 +224,9 @@ double score(double *steps, int size)
|
|||
if(state.dsize >= 10) break;
|
||||
}
|
||||
|
||||
state.s += 1000 * (state.dsize >= 10);
|
||||
state.score += 1000 * (state.dsize >= 10);
|
||||
|
||||
return state.s;
|
||||
return state.score;
|
||||
}
|
||||
|
||||
void input(FILE *fp, double *steps, int *size)
|
||||
|
@ -255,9 +255,9 @@ void input(FILE *fp, double *steps, int *size)
|
|||
void output(double *steps, int size)
|
||||
{
|
||||
int i;
|
||||
printf("%1d %1d\n", (int)steps[0], (int)steps[1]);
|
||||
for(i = 2; i < size - 3; i += 4)
|
||||
printf("%2d %d %d %d\n", (int)steps[0], (int)steps[1], (int)steps[2], (int)steps[3]);
|
||||
for(i = 4; i < size - 3; i += 4)
|
||||
{
|
||||
printf("%7.3f %2d %6.3f %2d\n", steps[i + 0], (int)steps[i + 1], steps[i + 2], (int)steps[i + 3]);
|
||||
printf("%8.4f %2d %7.4f %2d\n", steps[i + 0], (int)steps[i + 1], steps[i + 2], (int)steps[i + 3]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ def peut_aller(id):
|
|||
return id != 1 and (id != 3 or state[6])
|
||||
|
||||
def a_gagne():
|
||||
return len(state[7]) >= 10
|
||||
return state[9] >= 10
|
||||
|
||||
def en_avant(l, refresh=False):
|
||||
state[3] -= .1
|
||||
|
@ -74,26 +74,30 @@ def en_avant(l, refresh=False):
|
|||
state[3] -= d # score
|
||||
state[4] -= d # life
|
||||
state[0:2] = l[k][0:2]
|
||||
if c == 7 and not(xr in state[7]):
|
||||
if c == 7 and not(xr in state[8]):
|
||||
if state[4] >= 100:
|
||||
state[4] = max(state[4] - 100, 0)
|
||||
state[3] += 100
|
||||
state[5] += 1
|
||||
state[7].append(xr)
|
||||
if c == 6 and xr != state[8]:
|
||||
if not state[6] and len(state[7]) >= 9:
|
||||
state[8].append(xr)
|
||||
state[9] += 1
|
||||
if c == 6 and xr != state[7]:
|
||||
if not state[6] and state[9] >= 9:
|
||||
state[6] = 1
|
||||
elif state[5]:
|
||||
state[4] = min(250, state[4] + 120)
|
||||
state[5] -= 1
|
||||
state[8] = xr
|
||||
state[7] = xr
|
||||
|
||||
def a_droite(a): state[2] += a
|
||||
|
||||
def aller_selon(f):
|
||||
def aller_selon(f, start):
|
||||
global state
|
||||
# x y a score life tokens boat ldonj lvill
|
||||
state = [47.5, 43.5, 0, 0, 250, 1, 0, [], 0]
|
||||
x, a, y, b = start[4:8]
|
||||
x += a * 1e-14
|
||||
y += b * 1e-14
|
||||
state = [x, y, 0, 0, start[0], int(start[1]), int(start[2]), 0, [], int(start[3])]
|
||||
while f() and not(a_gagne()): pass
|
||||
state[3] += 1000 * a_gagne()
|
||||
return state[3]
|
||||
|
|
|
@ -22,9 +22,13 @@ for e in buffer.split():
|
|||
except:
|
||||
pass
|
||||
|
||||
position = [47.5, 43.5, 0]
|
||||
x, a, y, b = steps[4:8]
|
||||
x += a * 1e-14
|
||||
y += b * 1e-14
|
||||
|
||||
index = 6
|
||||
position = [x, y, 0]
|
||||
|
||||
index = 8
|
||||
|
||||
def mon_itineraire():
|
||||
global steps, position, index
|
||||
|
@ -41,4 +45,4 @@ def mon_itineraire():
|
|||
index += 4
|
||||
return index < len(steps) - 3
|
||||
|
||||
print(aller_selon(mon_itineraire))
|
||||
print(aller_selon(mon_itineraire, steps[0:8]))
|
||||
|
|
Loading…
Reference in New Issue