New model and data input
This commit is contained in:
parent
0c87e6de66
commit
ab69d0d986
@ -120,7 +120,7 @@ class GC(Cell):
|
||||
def run_vw(self):
|
||||
print("VOWPAL WABBIT")
|
||||
x, y = self.x, self.y
|
||||
for i in range(20):
|
||||
for i in range(1):
|
||||
action, position = get_predicted_move([x, y])
|
||||
if(action != "pick_garbage"):
|
||||
x, y = position
|
||||
|
@ -1 +1 @@
|
||||
0 1.0 map20190605103058832675_auto|GC_Position 4,1 |GC_Area G(2,0) R(2,1) E(2,2) E(2,3) R(3,0) R(3,1) R(3,2) R(3,3) H(4,0) E(4,2) H(4,3)
|
||||
1 | F00:0 F01:5 F02:1 F03:0 F10:1 F11:1 F12:1 F13:1 F20:4 F21:0 F23:2
|
@ -1 +1 @@
|
||||
2.412344 map20190605103058832675_auto
|
||||
2.731161
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
VowpalWabbit/VowpalModels/teraz.model
Normal file
BIN
VowpalWabbit/VowpalModels/teraz.model
Normal file
Binary file not shown.
@ -18,7 +18,7 @@ def generate_dataset(run_count, clear, model_name, learn):
|
||||
filename = "./VowpalWabbit/VowpalInputData/input_dataset" + str(datetime.datetime.now().strftime("%m%d%H%M")) + model_name
|
||||
print("Creating input file " + filename + ".txt... ", end = '')
|
||||
|
||||
input_file = open(filename,"w+")
|
||||
input_file = open(filename,"a+")
|
||||
for pfile in glob.glob('./VowpalWabbit/VowpalInputData/input_map*.txt'):
|
||||
#print(pfile)
|
||||
partial_input = open(pfile, "r+")
|
||||
@ -35,4 +35,4 @@ def generate_dataset(run_count, clear, model_name, learn):
|
||||
wrap_ex("vw " + filename + ".txt -c --passes 2 -f " + model_file)
|
||||
print("Learning process complete, model saved to " + model_file)
|
||||
|
||||
generate_dataset(6, True, "3k_001", True)
|
||||
generate_dataset(200, True, "teraz", True)
|
@ -1,9 +1,9 @@
|
||||
import re
|
||||
import re, os
|
||||
from config import MAP_NAME, GRID_WIDTH, GRID_HEIGHT, GC_X, GC_Y
|
||||
from VowpalWabbit.VowpalWrapper import wrapper
|
||||
|
||||
#const
|
||||
RADIUS = 1
|
||||
RADIUS = 2
|
||||
##
|
||||
|
||||
COORDINATES_LIST = []
|
||||
@ -55,10 +55,10 @@ def parse_list(whole_result,current_x,current_y):
|
||||
moves.append(parser[f"[{x_subtraction},{y_subtraction}]"])
|
||||
#print(moves)
|
||||
MOVES_LIST = moves.copy()
|
||||
generate_input(1.0)
|
||||
generate_input()
|
||||
return moves
|
||||
|
||||
def generate_input(importance):
|
||||
def generate_input():
|
||||
i = 1 #we'll use it to map coords to moves
|
||||
input_file_content = []
|
||||
for position in COORDINATES_LIST[:len(COORDINATES_LIST)-1]:
|
||||
@ -66,9 +66,13 @@ def generate_input(importance):
|
||||
coords = check_position(position, i) #set valid gc position
|
||||
|
||||
#vowpal config goes here
|
||||
importance = 1.0
|
||||
label = moves_mapping[MOVES_LIST[i]]
|
||||
#" " + str(importance) +
|
||||
input_line = str(label) + " | "
|
||||
if(label == 4 or label == 5):
|
||||
importance = 3.0
|
||||
elif(label == 1):
|
||||
importance = 15.0
|
||||
input_line = str(label) + " " + str(importance) + " | "
|
||||
|
||||
area = get_gc_area(coords, RADIUS)
|
||||
for a in area:
|
||||
@ -80,15 +84,13 @@ def generate_input(importance):
|
||||
#save to file
|
||||
tag = re.findall("(map_[0-9]+|map[0-9]+_auto)", MAP_NAME)[0]
|
||||
filename = "./VowpalWabbit/VowpalInputData/input_" + str(tag) + ".txt"
|
||||
input_file = open(filename,"w+")
|
||||
input_file = open(filename,"a+")
|
||||
for line in input_file_content:
|
||||
input_file.write(line+"\n")
|
||||
input_file.close()
|
||||
|
||||
def pass_input(position):
|
||||
label = 0
|
||||
gc_position = "|GC_Position "+str(position[0])+","+str(position[1])
|
||||
input_line = str(label) + " 1.0 " + tag + gc_position+" | "
|
||||
input_line = "1 | "
|
||||
area = get_gc_area(position, RADIUS)
|
||||
for a in area:
|
||||
input_line += a + " "
|
||||
@ -128,7 +130,7 @@ def check_position(position, i):
|
||||
def get_predicted_move(position):
|
||||
input_filename = pass_input(position)
|
||||
output_filename = "./VowpalWabbit/VowpalDataCache/constant_output.txt"
|
||||
wrapper.wrap_ex("vw -i ./VowpalWabbit/VowpalModels/25k_002.model -t "+input_filename+" -p "+output_filename+" --quiet")
|
||||
wrapper.wrap_ex("vw -i ./VowpalWabbit/VowpalModels/teraz.model -t "+input_filename+" -p "+output_filename+" ")
|
||||
with open( output_filename, 'r' ) as fout:
|
||||
prediction = float(list(fout.readline().split())[0])
|
||||
move = make_move_from_prediction(prediction)
|
||||
|
Loading…
Reference in New Issue
Block a user