-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhill.py
23 lines (20 loc) · 777 Bytes
/
hill.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from board import Board
if __name__ == '__main__':
numberOfGames = 25
board = Board(8,8)
board.add8Queens()
listOfStats = []
for i in range(0,numberOfGames):
moveCount,randomRestartCount,elapsed = board.solveWithHillClimbing()
listOfStats.append((moveCount,randomRestartCount,elapsed))
print("Moves =",moveCount,"Random Restart =",randomRestartCount,"Time spent =",elapsed)
sumOfMoves = 0
sumOfRestart = 0
sumOfElapsed = 0
for i in listOfStats:
sumOfMoves += i[0]
sumOfRestart += i[1]
sumOfElapsed += i[2]
print("Average Moves =",sumOfMoves/numberOfGames,
"\nAverage Random Restart =",sumOfRestart/numberOfGames,
"\nAverage Time spent =",sumOfElapsed/numberOfGames)