modify output format

This commit is contained in:
ZHANG Jie 2023-01-13 11:28:57 +01:00
parent b0eb9a40db
commit 8eb2e55057

View File

@ -16,7 +16,7 @@ import numpy as np
import os import os
import math import math
File_Directory = 'drive/MyDrive/Ecole/PolyHash2022/DataSet/' File_Directory = 'drive/MyDrive/polyhash/DataSet/'
File_Name = 'f_festive_flyover.in.txt' File_Name = 'f_festive_flyover.in.txt'
File_Path = File_Directory+File_Name File_Path = File_Directory+File_Name
@ -138,7 +138,7 @@ class Santa:
assert self.isAllowedBySpeedLimit(s) assert self.isAllowedBySpeedLimit(s)
self.speed[1] += s self.speed[1] += s
self.consumeCarrot() self.consumeCarrot()
print("AccUp:",s) print("AccUp",int(s))
else: else:
pass pass
def AccDown(self, s): def AccDown(self, s):
@ -146,7 +146,7 @@ class Santa:
assert self.isAllowedBySpeedLimit(s) assert self.isAllowedBySpeedLimit(s)
self.speed[1] -= s self.speed[1] -= s
self.consumeCarrot() self.consumeCarrot()
print("AccLeft:",s) print("AccDown",int(s))
else: else:
pass pass
def AccRight(self, s): def AccRight(self, s):
@ -154,7 +154,7 @@ class Santa:
assert self.isAllowedBySpeedLimit(s) assert self.isAllowedBySpeedLimit(s)
self.speed[0] += s self.speed[0] += s
self.consumeCarrot() self.consumeCarrot()
print("AccRight:",s) print("AccRight",int(s))
else: else:
pass pass
def AccLeft(self, s): def AccLeft(self, s):
@ -162,7 +162,7 @@ class Santa:
assert self.isAllowedBySpeedLimit(s) assert self.isAllowedBySpeedLimit(s)
self.speed[0] -= s self.speed[0] -= s
self.consumeCarrot() self.consumeCarrot()
print("AccLeft:",s) print("AccLeft",int(s))
else: else:
pass pass
@ -177,7 +177,7 @@ class Santa:
self.weightOfGift -= p.weightOfGift self.weightOfGift -= p.weightOfGift
assert self.weightOfGift >= 0 assert self.weightOfGift >= 0
p.getScore() p.getScore()
print("Delivert gift to",p.name) print("DeliverGift",p.name)
else: else:
pass pass
@ -186,9 +186,9 @@ class Santa:
self.position[0] += self.speed[0] * t self.position[0] += self.speed[0] * t
self.position[1] += self.speed[1] * t self.position[1] += self.speed[1] * t
self.timeLimit -= t self.timeLimit -= t
print("Float:",t) print("Float",int(t))
else: else:
pass self.timeLimit -= self.timeLimit
def getSituation(self): def getSituation(self):
print("Now position is:",self.position) print("Now position is:",self.position)
@ -214,6 +214,7 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
t = x/v t = x/v
self.AccDown(v) self.AccDown(v)
@ -230,6 +231,7 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
t = abs(x)/v t = abs(x)/v
self.AccUp(v) self.AccUp(v)
@ -245,6 +247,7 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
v = x v = x
self.AccDown(v) self.AccDown(v)
@ -260,8 +263,9 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
v = x v = abs(x)
self.AccUp(v) self.AccUp(v)
self.Float(1) self.Float(1)
self.AccDown(v) self.AccDown(v)
@ -278,6 +282,7 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
t = x//v t = x//v
v1 = v - (x - t*v) v1 = v - (x - t*v)
@ -299,6 +304,7 @@ class Santa:
self.Float(1) self.Float(1)
self.DiliveryGift(p) self.DiliveryGift(p)
v = self.nowSpeedLimit()
t = abs(x)//v t = abs(x)//v
v1 = v - (abs(x) - t*v) v1 = v - (abs(x) - t*v)
@ -308,14 +314,15 @@ class Santa:
self.Float(1) self.Float(1)
self.AccDown(v - v1) self.AccDown(v - v1)
self.Float(1) self.Float(1)
else:
self.DiliveryGift(p)
def oneWay(self, p:Person): def oneWay(self, p:Person):
if self.timeLimit >0: if self.timeLimit >0:
self.LoadCarrots(12) self.LoadCarrots(12)
print("LoarCarrots:12") print("LoadCarrots 12")
self.LoadGift(p.weightOfGift) self.LoadGift(p.weightOfGift)
print("LoarGift:",p.weightOfGift) print("LoadGift",p.name)
v = self.nowSpeedLimit() v = self.nowSpeedLimit()
if isinstance(p.x_position/v,int) and p.x_position > 0 : if isinstance(p.x_position/v,int) and p.x_position > 0 :
t = p.x_position/v t = p.x_position/v
@ -330,7 +337,7 @@ class Santa:
self.AccLeft(v) self.AccLeft(v)
self.Float(t) self.Float(t)
self.AccRight(v) self.AccRight(v)
self.Float() self.Float(1)
elif isinstance(p.x_position/v,int) and p.x_position < 0: elif isinstance(p.x_position/v,int) and p.x_position < 0:
@ -372,7 +379,7 @@ class Santa:
self.kidoneWay(p.y_position,p) self.kidoneWay(p.y_position,p)
v = p.x_position v = abs(p.x_position)
self.AccRight(v) self.AccRight(v)
self.Float(1) self.Float(1)
self.AccLeft(v) self.AccLeft(v)
@ -421,7 +428,6 @@ class Santa:
self.Float(1) self.Float(1)
elif p.x_position == 0 : elif p.x_position == 0 :
self.kidoneWay(p.y_position,p) self.kidoneWay(p.y_position,p)
print("Get score:",Score)
s = Santa() s = Santa()