-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
64 lines (52 loc) · 1.54 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from operator import itemgetter
import Course
import State
#from gui_main import *
from util import *
from initial import *
from login import *
credit_limit = 25
#======== Preparing and parsing data =======
class_stars,teacher_stars = readStars()
courses = readSweetList(class_stars,teacher_stars)
#======== Login, init states ========
'''
gui = GUI()
gui.initVar()
gui.createTable()
'''
#bi_show, fu_shuan_bi_show = gui.bi_show, gui.fu_shuan_bi_show
#takenCourses = Login(user, password)
#======== State Algorithm ======
EmptyState = State.State()
#======== +bi show Initial State ======
InitialState = EmptyState
#Greedy Algorithm
(nextState,score,class_stars,GPA) = max([(InitialState.generateSuccessor(course,credit_limit),\
(course.class_stars/5.0*3.66)+course.GPA,course.class_stars,course.GPA)\
for course in courses if InitialState.generateSuccessor(course,credit_limit) != None],key=itemgetter(1))
print nextState
print score
print class_stars
print GPA
while True:
try:
(nextState,score,class_stars,GPA) = max([(nextState.generateSuccessor(course,credit_limit),\
(course.class_stars/5.0*3.66)+course.GPA,course.class_stars,course.GPA)\
for course in courses if nextState.generateSuccessor(course,credit_limit) != None],key=itemgetter(1))
print nextState
print score
print class_stars
print GPA
except:
print "Greedy finished!!!"
break
for c in nextState.taken:
print c
'''
nextState = max([EmptyState.generateSuccessor(courses[0]),course.])
if nextState:
print nextState.free, nextState.credit
else:
print nextState
'''