mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 02:58:14 +00:00
fixup pathfind tests, add reachability tests
This commit is contained in:
parent
6cb367594b
commit
3a102774b5
31
data/test/macros/pathfind_answers.cfg
Normal file
31
data/test/macros/pathfind_answers.cfg
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,11 @@
|
||||
###
|
||||
### sed -n 's/^.*: \([ [:digit:]]*\) ,/\1/p' <foo | tr '\n' ','
|
||||
###
|
||||
### so you get a nice comma separated list. Then paste it below to GENERATED_ANSWERS, and change GENERATE_ANSWERS to 0 again.
|
||||
### so you get a nice comma separated list. Then paste it in data/test/macros/pathfind_answers.cfg,
|
||||
### and in this file change GENERATE_ANSWERS to 0 again.
|
||||
|
||||
#define GENERATE_ANSWERS
|
||||
1
|
||||
#enddef
|
||||
|
||||
#define GENERATED_ANSWERS
|
||||
3,3,1,11,16,2,16,22,3,23,30,4,34,48,6,25,40,5,26,47,6,18,28,4,7,7,1,31,36,4,7,12,2,34,40,6,23,38,5,1,6,1,30,47,7,23,29,5,13,26,4,9,10,2,4,14,2,28,44,7,13,21,3,3,3,1,0,0,0,9,11,2,23,30,5,5,12,2,24,35,7,39,59,10,38,45,8,28,32,7,37,53,11,40,48,8,41,49,9,32,39,8,35,48,8,38,46,8,39,59,12,32,39,7,23,32,8,11,11,3,16,26,6,22,32,8,12,16,4,13,20,5,34,44,11,41,52,11,45,51,11,33,41,9,37,54,8,29,38,6,17,21,3,46,62,11,42,53,8,34,38,6,26,47,6,20,32,4,16,16,2,29,50,5,26,37,4,35,41,5,51,62,7,54,61,7,17,21,3,12,14,2,18,25,5,15,18,3,13,16,3,41,45,7,28,32,4,20,22,4,31,32,4,37,41,6,49,51,7,0,30,48,6,34,36,4,43,47,6,15,16,2,36,40,5,18,36,4,29,32,4,13,18,2,6,7,1,32,45,8,22,36,6,27,40,6,14,21,4,14,14,3,9,9,2,21,32,8,44,50,13,0,0,0,38,44,7,32,32,5,29,40,8,45,54,9,28,34,6,39,47,8,39,47,10,7,9,2,37,43,8,24,31,6,12,28,4,39,50,9,42,44,7,23,32,4,27,33,5,35,36,6,37,40,6,39,49,7,44,51,8,39,50,8,29,31,6,4,5,1,19,28,4,21,21,3,24,25,4,22,23,4,40,47,8,20,21,4,46,47,7,10,16,2,16,18,3,8,10,2,10,11,2,19,21,3,15,35,5,55,64,11,49,66,11,26,34,6,7,8,2,16,18,2,15,27,3,11,12,2,11,28,5,6,6,1,32,44,7,41,52,8,29,42,6,25,32,6,20,22,4,21,30,5,22,23,4,38,43,8,27,40,8,25,33,6,32,45,8,32,33,7
|
||||
0
|
||||
#enddef
|
||||
|
||||
#define IF_GEN_ANS T E
|
||||
@ -45,7 +42,8 @@
|
||||
message="$observed_answer ,"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message])
|
||||
[/wml_message]
|
||||
)
|
||||
({VARIABLE current_answer $answers[$answer_counter|].val|}
|
||||
{VARIABLE observed_answer ${X}}
|
||||
[wml_message]
|
||||
@ -59,9 +57,9 @@
|
||||
{VARIABLE_OP answer_counter add 1}
|
||||
#enddef
|
||||
|
||||
#define INIT_ANSWERS
|
||||
#define INIT_ANSWERS LIST
|
||||
{VARIABLE answer_counter 0}
|
||||
{VARIABLE answers_list ("{GENERATED_ANSWERS}")}
|
||||
{VARIABLE answers_list ("{{LIST}}")}
|
||||
{SPLIT_COMMA_LIST $answers_list answers}
|
||||
|
||||
[wml_message]
|
||||
@ -71,17 +69,6 @@
|
||||
[/wml_message]
|
||||
#enddef
|
||||
|
||||
#define FORMAT ARRAY VARIABLE
|
||||
{VARIABLE_OP {VARIABLE} to_variable {ARRAY}.{VARIABLE}}
|
||||
#enddef
|
||||
|
||||
#put {NEXT INDEX} after it
|
||||
#define FOREACH_FORMAT ARRAY INDEX
|
||||
{FOREACH {ARRAY} {INDEX}}
|
||||
{FORMAT {ARRAY}[${INDEX}] x}
|
||||
{FORMAT {ARRAY}[${INDEX}] y}
|
||||
#enddef
|
||||
|
||||
#define TEST_PATHFIND SRC DST
|
||||
[find_path]
|
||||
[traveler]
|
||||
@ -94,7 +81,6 @@
|
||||
variable=path
|
||||
[/find_path]
|
||||
{VARIABLE nhexes $path.hexes}
|
||||
{CHECK_ANSWER nhexes}
|
||||
{IF_VAR nhexes equals 0 (
|
||||
[then]
|
||||
#[wml_message]
|
||||
@ -102,41 +88,19 @@
|
||||
# logger=error
|
||||
# to_chat=false
|
||||
#[/wml_message]
|
||||
{CHECK_ANSWER nhexes}
|
||||
[/then]
|
||||
[else]
|
||||
{CHECK_ANSWER path.movement_cost}
|
||||
{CHECK_ANSWER path.required_turns}
|
||||
{FOREACH path.steps step}
|
||||
{CHECK_ANSWER (path.steps[$step|].x)}
|
||||
{CHECK_ANSWER (path.steps[$step|].y)}
|
||||
{NEXT step}
|
||||
#{CHECK_ANSWER path.required_turns} Comment this out -- there may be multiple shortest paths, so finding a different shortest path is okay.
|
||||
#{FOREACH path.steps step}
|
||||
# {CHECK_ANSWER (path.steps[$step|].x)}
|
||||
# {CHECK_ANSWER (path.steps[$step|].y)}
|
||||
#{NEXT step}
|
||||
[/else]
|
||||
)}
|
||||
#enddef
|
||||
|
||||
|
||||
#define TEST_PATHFIND_WITH_OPTS SRC DST ALLOW_MULTIPLE_TURNS CHECK_VISIBILITY CHECK_TELEPORT CHECK_ZOC
|
||||
[find_path]
|
||||
[traveler]
|
||||
{SRC}
|
||||
[/traveler]
|
||||
[destination]
|
||||
{DST}
|
||||
[/destination]
|
||||
variable=path
|
||||
allow_multiple_turns = {ALLOW_MULTIPLE_TURNS}
|
||||
check_visibility = {CHECK_VISIBILITY}
|
||||
check_teleport = {CHECK_TELEPORT}
|
||||
check_zoc = {CHECK_ZOC}
|
||||
[/find_path]
|
||||
{CHECK_ANSWER path.movement_cost}
|
||||
{CHECK_ANSWER path.required_turns}
|
||||
{FOREACH path.steps step}
|
||||
{CHECK_ANSWER "path.steps[$step|].x"}
|
||||
{CHECK_ANSWER "path.steps[$step|].y"}
|
||||
{NEXT step}
|
||||
#enddef
|
||||
|
||||
#define TEST_NEXT_UNIT TEST_MACRO DST
|
||||
[store_locations]
|
||||
{DST}
|
||||
@ -173,7 +137,7 @@
|
||||
[/if]
|
||||
#enddef
|
||||
|
||||
#define MAKE_TEST ID MACRO
|
||||
#define MAKE_TEST ID MACRO INIT_MACRO
|
||||
[test]
|
||||
name="Unit Test {ID}"
|
||||
id={ID}
|
||||
@ -183,7 +147,7 @@
|
||||
name = side 1 turn 1
|
||||
first_time_only=yes
|
||||
{VARIABLE GEN_ANS {GENERATE_ANSWERS}}
|
||||
{INIT_ANSWERS}
|
||||
{INIT_ANSWERS ({INIT_MACRO})}
|
||||
|
||||
[store_unit]
|
||||
[filter]
|
||||
@ -385,9 +349,9 @@
|
||||
[/test]
|
||||
#enddef
|
||||
|
||||
{MAKE_TEST characterize_pathfinding_one TEST_PATHFIND}
|
||||
{MAKE_TEST characterize_pathfinding_one TEST_PATHFIND GENERATED_FIND_PATH_ANSWERS}
|
||||
|
||||
#define MAKE_TEST_INIT_ONLY ID MACRO
|
||||
#define MAKE_TEST_INIT_ONLY ID MACRO INIT_MACRO
|
||||
[test]
|
||||
name="Unit Test {ID}"
|
||||
id={ID}
|
||||
@ -397,9 +361,97 @@
|
||||
name = side 1 turn 1
|
||||
first_time_only=yes
|
||||
{VARIABLE GEN_ANS {GENERATE_ANSWERS}}
|
||||
{INIT_ANSWERS}
|
||||
{INIT_ANSWERS ({INIT_MACRO})}
|
||||
[/event]
|
||||
[/test]
|
||||
#enddef
|
||||
|
||||
{MAKE_TEST_INIT_ONLY characterize_pathfinding_init TEST_PATHFIND}
|
||||
{MAKE_TEST_INIT_ONLY characterize_pathfinding_init TEST_PATHFIND GENERATED_FIND_PATH_ANSWERS}
|
||||
|
||||
### Reach test goes below here ###
|
||||
|
||||
#define TEST_PATHREACH SRC DST
|
||||
[store_reachable_locations]
|
||||
[filter]
|
||||
{SRC}
|
||||
[/filter]
|
||||
variable=r
|
||||
[/store_reachable_locations]
|
||||
{VARIABLE nlocs $r.length}
|
||||
{CHECK_ANSWER nlocs}
|
||||
{FOREACH r i}
|
||||
{CHECK_ANSWER (r[$i|].x)}
|
||||
{CHECK_ANSWER (r[$i|].y)}
|
||||
{NEXT i}
|
||||
#enddef
|
||||
|
||||
#define MAKE_SHORT_TEST ID MACRO INIT_MACRO INIT_COUNTER
|
||||
[test]
|
||||
name="Unit Test {ID}"
|
||||
id={ID}
|
||||
{test/maps/pathfind_1.cfg}
|
||||
|
||||
[event]
|
||||
name = side 1 turn 1
|
||||
first_time_only=yes
|
||||
{VARIABLE GEN_ANS {GENERATE_ANSWERS}}
|
||||
{INIT_ANSWERS ({INIT_MACRO})}
|
||||
|
||||
[store_unit]
|
||||
[filter]
|
||||
[/filter]
|
||||
variable=units
|
||||
[/store_unit]
|
||||
{VARIABLE unit_counter {INIT_COUNTER}}
|
||||
|
||||
[wml_message]
|
||||
message="$units.length| units"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message]
|
||||
|
||||
{REPEAT 5 (
|
||||
{TEST_NEXT_UNIT {MACRO} (x,y=8,8)}
|
||||
)}
|
||||
|
||||
[wml_message]
|
||||
message="$answer_counter| answers made"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message]
|
||||
{VARIABLE anslength $answers.length}
|
||||
[wml_message]
|
||||
message="$answers.length| anslength"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message]
|
||||
|
||||
{IF_GEN_ANS
|
||||
({ASSERT ({VARIABLE_CONDITIONAL answer_counter equals $anslength})}
|
||||
[wml_message]
|
||||
message="unit counter = $unit_counter"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message]
|
||||
{VARIABLE temp $units.length}
|
||||
[wml_message]
|
||||
message="units.length = $units.length"
|
||||
logger=debug
|
||||
to_chat=false
|
||||
[/wml_message])
|
||||
()}
|
||||
[/event]
|
||||
[event]
|
||||
name = side 1 turn refresh
|
||||
{RETURN ([true][/true])}
|
||||
[/event]
|
||||
[/test]
|
||||
#enddef
|
||||
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_1 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_1 0}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_2 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_2 20}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_3 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_3 40}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_4 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_4 60}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_5 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_5 80}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_6 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_6 100}
|
||||
{MAKE_SHORT_TEST characterize_pathfinding_reach_7 TEST_PATHREACH GENERATED_REACHABILITY_ANSWERS_7 120}
|
||||
|
@ -76,6 +76,13 @@
|
||||
#
|
||||
0 store_locations_one
|
||||
0 characterize_pathfinding_one
|
||||
0 characterize_pathfinding_reach_1
|
||||
0 characterize_pathfinding_reach_2
|
||||
0 characterize_pathfinding_reach_3
|
||||
0 characterize_pathfinding_reach_4
|
||||
0 characterize_pathfinding_reach_5
|
||||
0 characterize_pathfinding_reach_6
|
||||
0 characterize_pathfinding_reach_7
|
||||
#
|
||||
# Attack calculations & codepath tests
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user