Expand scope of coverage_dungeon.py - specials
This commit is contained in:
parent
39cc166979
commit
e176039b01
4 changed files with 199 additions and 4 deletions
|
@ -92,6 +92,15 @@
|
||||||
<td class="headerCovTableEntry">{}</td>
|
<td class="headerCovTableEntry">{}</td>
|
||||||
<td class="headerCovTableEntry">{}%</td>
|
<td class="headerCovTableEntry">{}%</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="headerItem">Specials:</td>
|
||||||
|
<td class="headerCovTableEntry">{}</td>
|
||||||
|
<td class="headerCovTableEntry">{}</td>
|
||||||
|
<td class="headerCovTableEntry">{}%</td>
|
||||||
|
</tr>
|
||||||
<tr><td><img src="glass.png" width=3 height=3 alt=""></td></tr>
|
<tr><td><img src="glass.png" width=3 height=3 alt=""></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
@ -162,6 +171,7 @@
|
||||||
<td class="tableHead">Special ID</td>
|
<td class="tableHead">Special ID</td>
|
||||||
<td class="tableHead">Message</td>
|
<td class="tableHead">Message</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</center>
|
</center>
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import re
|
import re
|
||||||
import pprint
|
|
||||||
|
|
||||||
test_dir = "."
|
test_dir = "."
|
||||||
yaml_name = "../adventure.yaml"
|
yaml_name = "../adventure.yaml"
|
||||||
|
@ -87,7 +86,6 @@ def obj_coverage(objects, text):
|
||||||
obj["descriptions"][j] = True
|
obj["descriptions"][j] = True
|
||||||
objects[i] = (obj_name, obj)
|
objects[i] = (obj_name, obj)
|
||||||
|
|
||||||
|
|
||||||
def hint_coverage(hints, text):
|
def hint_coverage(hints, text):
|
||||||
for name, hint in hints:
|
for name, hint in hints:
|
||||||
if hint["question"] != True:
|
if hint["question"] != True:
|
||||||
|
@ -96,7 +94,14 @@ def hint_coverage(hints, text):
|
||||||
if hint["hint"] != True:
|
if hint["hint"] != True:
|
||||||
if search(hint["hint"], text):
|
if search(hint["hint"], text):
|
||||||
hint["hint"] = True
|
hint["hint"] = True
|
||||||
continue
|
|
||||||
|
def special_coverage(specials, text):
|
||||||
|
for name, special in specials:
|
||||||
|
if special["message"] == None:
|
||||||
|
special["message"] = True
|
||||||
|
if special["message"] != True:
|
||||||
|
if search(special["message"], text):
|
||||||
|
special["message"] = True
|
||||||
|
|
||||||
def threshold_coverage(classes, text):
|
def threshold_coverage(classes, text):
|
||||||
for i, msg in enumerate(classes):
|
for i, msg in enumerate(classes):
|
||||||
|
@ -120,6 +125,7 @@ if __name__ == "__main__":
|
||||||
hintsraw = db["hints"]
|
hintsraw = db["hints"]
|
||||||
classes = db["classes"]
|
classes = db["classes"]
|
||||||
turn_thresholds = db["turn_thresholds"]
|
turn_thresholds = db["turn_thresholds"]
|
||||||
|
specials = db["specials"]
|
||||||
|
|
||||||
hints = []
|
hints = []
|
||||||
for hint in hintsraw:
|
for hint in hintsraw:
|
||||||
|
@ -136,6 +142,7 @@ if __name__ == "__main__":
|
||||||
hint_coverage(hints, text)
|
hint_coverage(hints, text)
|
||||||
threshold_coverage(classes, text)
|
threshold_coverage(classes, text)
|
||||||
threshold_coverage(turn_thresholds, text)
|
threshold_coverage(turn_thresholds, text)
|
||||||
|
special_coverage(specials, text)
|
||||||
|
|
||||||
location_html = ""
|
location_html = ""
|
||||||
location_total = len(locations) * 2
|
location_total = len(locations) * 2
|
||||||
|
@ -230,6 +237,18 @@ if __name__ == "__main__":
|
||||||
turn_html += arb_msg_row.format(msg["threshold"], success)
|
turn_html += arb_msg_row.format(msg["threshold"], success)
|
||||||
turn_percent = round((turn_covered / float(turn_total)) * 100, 1)
|
turn_percent = round((turn_covered / float(turn_total)) * 100, 1)
|
||||||
|
|
||||||
|
special_html = ""
|
||||||
|
special_total = len(specials)
|
||||||
|
special_covered = 0
|
||||||
|
for name, special in specials:
|
||||||
|
if special["message"] != True:
|
||||||
|
success = "uncovered"
|
||||||
|
else:
|
||||||
|
success = "covered"
|
||||||
|
special_covered += 1
|
||||||
|
special_html += arb_msg_row.format(name, success)
|
||||||
|
special_percent = round((special_covered / float(special_total)) * 100, 1)
|
||||||
|
|
||||||
# output some quick report stats
|
# output some quick report stats
|
||||||
print("\nadventure.yaml coverage rate:")
|
print("\nadventure.yaml coverage rate:")
|
||||||
print(" locations..........: {}% covered ({} of {})".format(location_percent, location_covered, location_total))
|
print(" locations..........: {}% covered ({} of {})".format(location_percent, location_covered, location_total))
|
||||||
|
@ -238,6 +257,7 @@ if __name__ == "__main__":
|
||||||
print(" hints..............: {}% covered ({} of {})".format(hints_percent, hints_covered, hints_total))
|
print(" hints..............: {}% covered ({} of {})".format(hints_percent, hints_covered, hints_total))
|
||||||
print(" classes............: {}% covered ({} of {})".format(class_percent, class_covered, class_total))
|
print(" classes............: {}% covered ({} of {})".format(class_percent, class_covered, class_total))
|
||||||
print(" turn_thresholds....: {}% covered ({} of {})".format(turn_percent, turn_covered, turn_total))
|
print(" turn_thresholds....: {}% covered ({} of {})".format(turn_percent, turn_covered, turn_total))
|
||||||
|
print(" specials...........: {}% covered ({} of {})".format(special_percent, special_covered, special_total))
|
||||||
|
|
||||||
# render HTML report
|
# render HTML report
|
||||||
with open(html_output_path, "w") as f:
|
with open(html_output_path, "w") as f:
|
||||||
|
@ -248,5 +268,7 @@ if __name__ == "__main__":
|
||||||
hints_total, hints_covered, hints_percent,
|
hints_total, hints_covered, hints_percent,
|
||||||
class_total, class_covered, class_percent,
|
class_total, class_covered, class_percent,
|
||||||
turn_total, turn_covered, turn_percent,
|
turn_total, turn_covered, turn_percent,
|
||||||
location_html, arb_msg_html, object_html, hints_html, class_html, turn_html
|
special_total, special_covered, special_percent,
|
||||||
|
location_html, arb_msg_html, object_html, hints_html,
|
||||||
|
class_html, turn_html, special_html
|
||||||
))
|
))
|
||||||
|
|
145
tests/specials.chk
Normal file
145
tests/specials.chk
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
|
||||||
|
Welcome to Adventure!! Would you like instructions?
|
||||||
|
|
||||||
|
> n
|
||||||
|
|
||||||
|
You are standing at the end of a road before a small brick building.
|
||||||
|
Around you is a forest. A small stream flows out of the building and
|
||||||
|
down a gully.
|
||||||
|
|
||||||
|
> thank
|
||||||
|
|
||||||
|
You're quite welcome.
|
||||||
|
|
||||||
|
> shazam
|
||||||
|
|
||||||
|
Good try, but that is an old worn-out magic word.
|
||||||
|
|
||||||
|
> help
|
||||||
|
|
||||||
|
I know of places, actions, and things. Most of my vocabulary
|
||||||
|
describes places and is used to move you there. To move, try words
|
||||||
|
like forest, building, downstream, enter, east, west, north, south,
|
||||||
|
up, or down. I know about a few special objects, like a black rod
|
||||||
|
hidden in the cave. These objects can be manipulated using some of
|
||||||
|
the action words that I know. Usually you will need to give both the
|
||||||
|
object and action words (in either order), but sometimes I can infer
|
||||||
|
the object from the verb alone. Some objects also imply verbs; in
|
||||||
|
particular, "inventory" implies "take inventory", which causes me to
|
||||||
|
give you a list of what you're carrying. Some objects have unexpected
|
||||||
|
effects; the effects are not always desirable! Usually people having
|
||||||
|
trouble moving just need to try a few more words. Usually people
|
||||||
|
trying unsuccessfully to manipulate an object are attempting something
|
||||||
|
beyond their (or my!) capabilities and should try a completely
|
||||||
|
different tack. One point often confusing to beginners is that, when
|
||||||
|
there are several ways to go in a certain direction (e.g., if there
|
||||||
|
are several holes in a wall), choosing that direction in effect
|
||||||
|
chooses one of the ways at random; often, though, by specifying the
|
||||||
|
place you want to reach you can guarantee choosing the right path.
|
||||||
|
Also, to speed the game you can sometimes move long distances with a
|
||||||
|
single word. For example, "building" usually gets you to the building
|
||||||
|
from anywhere above ground except when lost in the forest. Also, note
|
||||||
|
that cave passages and forest paths turn a lot, so leaving one place
|
||||||
|
heading north doesn't guarantee entering the next from the south.
|
||||||
|
However (another important point), except when you've used a "long
|
||||||
|
distance" word such as "building", there is always a way to go back
|
||||||
|
where you just came from unless I warn you to the contrary, even
|
||||||
|
though the direction that takes you back might not be the reverse of
|
||||||
|
what got you here. Good luck, and have fun!
|
||||||
|
|
||||||
|
> no
|
||||||
|
|
||||||
|
OK
|
||||||
|
|
||||||
|
> tree
|
||||||
|
|
||||||
|
The trees of the forest are large hardwood oak and maple, with an
|
||||||
|
occasional grove of pine or spruce. There is quite a bit of under-
|
||||||
|
growth, largely birch and ash saplings plus nondescript bushes of
|
||||||
|
various sorts. This time of year visibility is quite restricted by
|
||||||
|
all the leaves, but travel is quite easy if you detour around the
|
||||||
|
spruce and berry bushes.
|
||||||
|
|
||||||
|
> dig
|
||||||
|
|
||||||
|
Digging without a shovel is quite impractical. Even with a shovel
|
||||||
|
progress is unlikely.
|
||||||
|
|
||||||
|
> lost
|
||||||
|
|
||||||
|
I'm as confused as you are.
|
||||||
|
|
||||||
|
> mist
|
||||||
|
|
||||||
|
Mist is a white vapor, usually water, seen from time to time in
|
||||||
|
caverns. It can be found anywhere but is frequently a sign of a deep
|
||||||
|
pit leading down to water.'
|
||||||
|
|
||||||
|
> fuck
|
||||||
|
|
||||||
|
Watch it!
|
||||||
|
|
||||||
|
> stop
|
||||||
|
|
||||||
|
I don't know the word "stop". Use "quit" if you want to give up.
|
||||||
|
|
||||||
|
> info
|
||||||
|
|
||||||
|
For a summary of the most recent changes to the game, say "news".
|
||||||
|
If you want to end your adventure early, say "quit". To suspend your
|
||||||
|
adventure such that you can continue later, say "suspend" (or "pause"
|
||||||
|
or "save"). To see how well you're doing, say "score". To get full
|
||||||
|
credit for a treasure, you must have left it safely in the building,
|
||||||
|
though you get partial credit just for locating it. You lose points
|
||||||
|
for getting killed, or for quitting, though the former costs you more.
|
||||||
|
There are also points based on how much (if any) of the cave you've
|
||||||
|
managed to explore; in particular, there is a large bonus just for
|
||||||
|
getting in (to distinguish the beginners from the rest of the pack),
|
||||||
|
and there are other ways to determine whether you've been through some
|
||||||
|
of the more harrowing sections. If you think you've found all the
|
||||||
|
treasures, just keep exploring for a while. If nothing interesting
|
||||||
|
happens, you haven't found them all yet. If something interesting
|
||||||
|
*DOES* happen (incidentally, there *ARE* ways to hasten things along),
|
||||||
|
it means you're getting a bonus and have an opportunity to garner many
|
||||||
|
more points in the Master's section. I may occasionally offer hints
|
||||||
|
if you seem to be having trouble. If I do, I'll warn you in advance
|
||||||
|
how much it will affect your score to accept the hints. Finally, to
|
||||||
|
save time, you may specify "brief", which tells me never to repeat the
|
||||||
|
full description of a place unless you explicitly ask me to.
|
||||||
|
|
||||||
|
> swim
|
||||||
|
|
||||||
|
I don't know how.
|
||||||
|
|
||||||
|
> wizard
|
||||||
|
|
||||||
|
Wizards are not to be disturbed by such as you.
|
||||||
|
|
||||||
|
> yes
|
||||||
|
|
||||||
|
Guess again.
|
||||||
|
|
||||||
|
> news
|
||||||
|
|
||||||
|
Open Adventure is an author-approved open-source release of
|
||||||
|
Version 2.5 with, as yet, no gameplay changes.
|
||||||
|
Version 2.5 was essentially the same as Version II; the cave and the
|
||||||
|
hazards therein are unchanged, and top score is still 430 points.
|
||||||
|
There are a few more hints, especially for some of the more obscure
|
||||||
|
puzzles. There are a few minor bugfixes and cosmetic changes. You
|
||||||
|
can now save a game and resume it at once (formerly you had to wait a
|
||||||
|
while first), but it now costs you a few points each time you save the
|
||||||
|
game. Saved games are now stored in much smaller files than before.
|
||||||
|
|
||||||
|
> version
|
||||||
|
|
||||||
|
There is a puff of orange smoke; within it, fiery runes spell out:
|
||||||
|
|
||||||
|
Open Adventure 1.2 - http://www.catb.org/esr/open-adventure/
|
||||||
|
|
||||||
|
|
||||||
|
You scored 32 out of a possible 430, using 16 turns.
|
||||||
|
|
||||||
|
You are obviously a rank amateur. Better luck next time.
|
||||||
|
|
||||||
|
To achieve the next higher rating, you need 14 more points.
|
18
tests/specials.log
Normal file
18
tests/specials.log
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
## Test special words
|
||||||
|
n
|
||||||
|
thank
|
||||||
|
shazam
|
||||||
|
help
|
||||||
|
no
|
||||||
|
tree
|
||||||
|
dig
|
||||||
|
lost
|
||||||
|
mist
|
||||||
|
fuck
|
||||||
|
stop
|
||||||
|
info
|
||||||
|
swim
|
||||||
|
wizard
|
||||||
|
yes
|
||||||
|
news
|
||||||
|
version
|
Loading…
Add table
Add a link
Reference in a new issue