Author: oracle
Date: Mon Jun 30 19:55:49 2008
New Revision: 27618
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27618&view=rev
Log:
Bug fix for both scripts.
Modified:
trunk/data/ais/bruteforce.py
trunk/data/ais/bruteforce_unsafe.py
Modified: trunk/data/ais/bruteforce.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ais/bruteforce.py?rev=27618&r1=27617&r2=27618&view=diff
==============================================================================
--- trunk/data/ais/bruteforce.py (original)
+++ trunk/data/ais/bruteforce.py Mon Jun 30 19:55:49 2008
@@ -1,5 +1,6 @@
#!WPY
+import time
import wesnoth, random
## Copyright 2006 by Michael Schmahl
@@ -302,9 +303,9 @@
for y in range(m.y):
loc = wesnoth.get_location(x,y)
speed += 1.0 / recruit.movement_cost(loc)
- rdm = recruit.defense_modifier(loc)
- if rdm and rdm != 1:
- defense += 100.0 / rdm - 1
+ rdm = recruit.defense_modifier(loc) - 1
+ if rdm:
+ defense += 100.0 / rdm
else:
defense += 1.00
@@ -527,10 +528,16 @@
return score
+
+st = time.time()
ai = AI()
ai.recruit()
-while 1:
+while True:
if not ai.do_one_move():
break
ai.recruit()
ai.report_stats()
+
+print "======================="
+print "bruteforce ran for %0.4f-seconds." % (time.time() - st)
+print "======================="
Modified: trunk/data/ais/bruteforce_unsafe.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ais/bruteforce_unsafe.py?rev=27618&r1=27617&r2=27618&view=diff
==============================================================================
--- trunk/data/ais/bruteforce_unsafe.py (original)
+++ trunk/data/ais/bruteforce_unsafe.py Mon Jun 30 19:55:49 2008
@@ -363,13 +363,12 @@
for y in range(m.y):
loc = wesnoth.get_location(x,y)
speed += 1.0 / recruit.movement_cost(loc)
- rdm = recruit.defense_modifier(loc)
+ rdm = recruit.defense_modifier(loc) - 1
if rdm:
- defense += 100.0 / rdm - 1
+ defense += 100.0 / rdm
else:
defense += 1.00
-
# speed is more important on larger maps
speed *= self.mapsize * recruit.movement / n
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits