-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsolve_hardest_problem.py
32 lines (20 loc) · 1.07 KB
/
solve_hardest_problem.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
import batch_weighted_a_star
import tensorflow as tf
from game import *
from time import *
def main():
model = tf.keras.models.load_model('model/cost.h5')
question = "U U F U U R' L F F U F' B' R L U U R U D' R L' D R' L' D D".split(' ') # 26手問題
# question = "U U F U U R' L F F U F' B' R L U U R U D' R L' D R' L' D'".split(' ') # 25手問題
# question = "U F U U R' L F F U F' B' R L U U L U D' R' L D R' L' U U".split(' ') # 25手問題
state = GOAL_STATE
for action in question:
state = get_next_state(state, action)
starting_time = time()
answer = batch_weighted_a_star.get_answer(state, model, 10000, 0.6) # 論文だと、最適解を出す場合はn=10000でl=0.6が良いらしい。
print(f'{len(answer)} steps, {time() - starting_time:6.3f} seconds')
print(' '.join(map(lambda action: action if len(action) == 2 else action + ' ', question)))
print(' '.join(map(lambda action: action if len(action) == 2 else action + ' ', answer )))
tf.keras.backend.clear_session()
if __name__ == '__main__':
main()