Refactored
This commit is contained in:
@@ -2,14 +2,6 @@ import numpy as np
|
||||
from numpy.random import uniform
|
||||
|
||||
|
||||
def create_test_state() -> np.array:
|
||||
return np.array([['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']])
|
||||
|
||||
|
||||
def create_empty_state() -> np.array:
|
||||
return np.array([['-', '-', '-'], ['-', '-', '-'], ['-', '-', '-']])
|
||||
|
||||
|
||||
def softmax(values: np.array, eps=1.0E-6) -> np.array:
|
||||
result = (values + eps) / (sum(values + eps))
|
||||
return result
|
||||
@@ -46,36 +38,6 @@ def test_sample(data):
|
||||
print(c)
|
||||
|
||||
|
||||
def to_state_string(state, state_nex=None):
|
||||
sp = ' '
|
||||
sp_arrow = ' => '
|
||||
sp_ = [sp, sp_arrow, sp]
|
||||
|
||||
def col(str_in, state):
|
||||
str_out = str_in
|
||||
for c in range(0, 3):
|
||||
char = state[r][c]
|
||||
if char == '-':
|
||||
char = ' '
|
||||
str_out += "|" + char
|
||||
str_out += '|'
|
||||
return str_out
|
||||
|
||||
state_str = ''
|
||||
for r in range(0, 3):
|
||||
if state is not None:
|
||||
state_str = col(state_str, state)
|
||||
|
||||
if state_nex is not None:
|
||||
state_str += sp_[r]
|
||||
state_str = col(state_str, state_nex)
|
||||
|
||||
if r != 2:
|
||||
state_str += '\x0A'
|
||||
|
||||
return state_str
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Testing sample()")
|
||||
test_sample([0.7, 0.1, 0.1, 0.1])
|
||||
|
||||
Reference in New Issue
Block a user