From 2d80c960fd958b7cc631b6972f7d7e43fa5ebbc6 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Wed, 10 Apr 2024 15:33:16 -0700 Subject: [PATCH 01/16] listwriter patch --- .../WorldModelKit/Sections/ListWriter.i6t | 235 ++++++++++++++---- .../standard_rules/Sections/Activities.w | 17 +- .../Sections/Variables and Rulebooks.w | 19 +- 3 files changed, 196 insertions(+), 75 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 33594303b7..c7c098322b 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -932,69 +932,198 @@ achieved by calling |WriteListR|, using the |ObjectTreeIterator| (whatever the iterator used at the top level) and increasing the depth by 1. = + +Constant LW_LIT = $$00000001; +Constant LW_CLOSED = $$00000010; +Constant LW_EMPTY = $$00000100; +Constant LW_WORN = $$00001000; +Constant LW_OPEN = $$00010000; +Constant LW_LOCKED = $$00100000; + +[ BitCount flags result; + do { + if (flags % 2) result++; + flags = flags / 2; + } until (~~flags); + return result; +]; + +[ WriteAfterEntryTerm o flags thisflag print_count last_comma and_position lwresponse; + if (flags & thisflag) { + if (print_count && print_count < last_comma) { + print ", "; + if (print_count < and_position) print " "; + } + if (print_count == and_position) LW_Response('Z', o); ! " and " + LW_Response(lwresponse, o); + return 1; + } + return 0; +]; + [ WriteAfterEntry o depth - p recurse_flag parenth_flag eldest_child child_count combo; + p recurse_flag parenth_flag eldest_child child_count print_count flags terms last_comma and_position bit_counter; inventory_stage = 2; if (c_style & PARTINV_BIT) { - BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); + ! zero to three of: closed, empty, providing light; + BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { - combo = 0; - if (o has light && location hasnt light) combo=combo+1; - if (o has container && o hasnt open) combo=combo+2; - if ((o has container && (o has open || o has transparent)) - && (child(o)==0)) combo=combo+4; - if (combo) LW_Response('A'); ! space and open bracket - switch (combo) { - 1: LW_Response('D', o); - 2: LW_Response('E', o); - 3: LW_Response('H', o); - 4: LW_Response('F', o); - 5: LW_Response('I', o); - 6: LW_Response('G', o); - 7: LW_Response('J', o); - } - if (combo) LW_Response('B'); ! close bracket - } +! terms = 0; +! if (o has light && location hasnt light) { flags = flags | LW_LIT; terms++; } + if (o has light && location hasnt light) flags = flags | LW_LIT; + if (o has container) { + if (o has open || o has transparent) { +! if (~~ObviouslyOccupied(o)) { flags = flags | LW_EMPTY; terms++; } + if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; + } +! if (o hasnt open) { flags = flags | LW_CLOSED; terms++; } + if (o hasnt open) flags = flags | LW_CLOSED; + } + and_position = -1; + terms = BitCount(flags); + ! if there's more than one term, put an 'and' before term n + if (terms > 1) and_position = terms - 1; + if (terms > 2) { + if (BasicInformKit`SERIAL_COMMA_CFGF) last_comma = terms; + else last_comma = terms - 1; + } + if (terms) { + LW_Response('A'); ! " (" +! print_count = 0; + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); +! if (flags & LW_CLOSED) { +! LW_Response('E', o); ! "closed" +! print_count++; +! } + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); + +!if (flags & LW_EMPTY) { +! if (print_count && print_count < last_comma) { +! print ","; +! if (print_count < and_position) print " "; +! } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('F', o); ! "empty" +! print_count++; +! } + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); +! if (flags & LW_LIT) { +! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('D', o); ! "providing light"; +! } + LW_Response('B'); ! close bracket ")"; + } + } EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); } ! end of PARTINV_BIT processing + ! gets "empty" if (open & openable) || (!openable & transparent) + - if (c_style & FULLINV_BIT) { + if (c_style & FULLINV_BIT) { BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { - if (o has light && o has worn) { LW_Response('A'); LW_Response('K', o); parenth_flag = true; } - else { - if (o has light) { LW_Response('A'); LW_Response('D', o); parenth_flag = true; } - if (o has worn) { LW_Response('A'); LW_Response('L', o); parenth_flag = true; } - } - - if (o has container) { - if (o has openable) { - if (parenth_flag) { - if (BasicInformKit`SERIAL_COMMA_CFGF) - print ","; - LW_Response('C'); - } else LW_Response('A', o); - if (o has open) { - if (child(o)) LW_Response('M', o); - else LW_Response('N', o); - } else { - if (o has lockable && o has locked) LW_Response('P', o); - else LW_Response('O', o); - } - parenth_flag = true; - } - else { - if (child(o)==0 && o has transparent) { - if (parenth_flag) { LW_Response('C'); LW_Response('F'); } - else { LW_Response('A'); LW_Response('F'); LW_Response('B'); } - } - } - } - if (parenth_flag) LW_Response('B'); - } - EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); - } ! end of FULLINV_BIT processing + ! setup +! if (o has light) { flags = flags | LW_LIT; terms++; } +! if (o has worn) { flags = flags | LW_WORN; terms++; } + if (o has light) flags = flags | LW_LIT; + if (o has worn) flags = flags | LW_WORN; + if (o has container) { + if (o has openable) { + if (o has open) { + flags = flags | LW_OPEN; + if (~~ObviouslyOccupied(o)) !{ + flags = flags | LW_EMPTY; + !terms++; + !} + } + else { + flags = flags | LW_CLOSED; + if (o has locked) flags = flags | LW_LOCKED; + !if (o has locked) { flags = flags | LW_LOCKED; terms++; } + } + !terms++; ! for one of 'open' or 'closed' + } + else { + if (((o has transparent)) && (~~ObviouslyOccupied(o))) !{ + flags = flags | LW_EMPTY; + !terms++; + !} + } + } + terms = BitCount(flags); +! bit_counter = flags; +! do { +! if (~~(bit_counter % 2)) terms++; +! bit_counter = bit_counter / 2; +! } until (~~bit_counter); +! print "original terms: ", terms; +! terms = 0; +! bit_counter = flags; +! do { +! if (~~(bit_counter % 2)) terms++; +! bit_counter = bit_counter / 2; +! } until (~~bit_counter); +! print "; bit counted terms: ", terms, "^"; + if (flags & (LW_OPEN | LW_EMPTY)) terms--; + if (terms) { + print_count = 0; + and_position = last_comma = -1; + ! if there's more than one term, put an 'and' before term n + if (terms > 1) and_position = terms - 1; + if (terms > 2) { + if (BasicInformKit`SERIAL_COMMA_CFGF) last_comma = terms; + else last_comma = terms - 1; + } + LW_Response('A'); ! " (" + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); +! if (flags & LW_LIT) { +! ! initial doesn't need and/comma check +! LW_Response('D', o); ! providing light +! print_count++; +! } + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_WORN, print_count, last_comma, and_position, 'L'); +! if (flags & LW_WORN) { +! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('L', o); ! being worn +! print_count++; +! } + if (flags & LW_OPEN) { + if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } + if (print_count == and_position) LW_Response('Z', o); + if (flags & LW_EMPTY) LW_Response('N', o); ! open but empty + else LW_Response('M', o); ! open + print_count++; + } + else print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); + +!if (flags & LW_EMPTY) { +! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('F', o); ! empty +! print_count++; +! } + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); +! if (flags & LW_CLOSED) { +! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('E', o); ! closed +! print_count++; +! } + print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LOCKED, print_count, last_comma, and_position, 'O'); +! if (flags & LW_LOCKED) { +! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } +! if (print_count == and_position) LW_Response('Z', o); +! LW_Response('O', o); ! locked +! print_count++; +! } + LW_Response('B'); ! close bracket ")" + } + } + EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); + } ! end of FULLINV_BIT processing child_count = 0; eldest_child = nothing; diff --git a/inform7/extensions/standard_rules/Sections/Activities.w b/inform7/extensions/standard_rules/Sections/Activities.w index 327427f41c..6f912f456c 100644 --- a/inform7/extensions/standard_rules/Sections/Activities.w +++ b/inform7/extensions/standard_rules/Sections/Activities.w @@ -66,21 +66,10 @@ supplemented by details: Printing room description details of something (hidden in RULES command) (documented at act_details) is an activity. The printing room description details activity is accessible to Inter as "PRINTING_ROOM_DESC_DETAILS_ACT". -For printing room description details of a container (called the box) when the box is falsely-unoccupied (this is the falsely-unoccupied container room description details rule): - say text of list writer internal rule response (A); [ " (" ] - if the box is lit and the location is unlit begin; - if the box is closed, say text of list writer internal rule response (J); [ "closed, empty[if serial comma option is active],[end if] and providing light" ] - else say text of list writer internal rule response (I); [ "empty and providing light" ] - else; - if the box is closed, say text of list writer internal rule response (E); [ "closed" ] - else say text of list writer internal rule response (F); [ "empty" ] - end if; - say text of list writer internal rule response (B); [ ")" ] - Printing inventory details of something (hidden in RULES command) (documented at act_idetails) is an activity. The printing inventory details activity is accessible to Inter as "PRINTING_INVENTORY_DETAILS_ACT". - +[ To say the deceitfully empty inventory details of (box - a container): let inventory text printed be false; if the box is lit begin; @@ -110,7 +99,8 @@ To say the deceitfully empty inventory details of (box - a container): now inventory text printed is true; [ not relevant unless code is added ] end if; end if; - +] +[ For printing inventory details of a container (called the box) when the box is falsely-unoccupied (this is the falsely-unoccupied container inventory details rule): let the tag be "[the deceitfully empty inventory details of box]"; if tag is not empty begin; @@ -118,6 +108,7 @@ For printing inventory details of a container (called the box) when the box is f say tag; say text of list writer internal rule response (B); [ ")" ] end if; +] @ Names of things are often formed up into lists, in which they are sometimes grouped together: diff --git a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w index 1ddf65ba03..e0617ae889 100644 --- a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w +++ b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w @@ -1142,20 +1142,20 @@ The list writer internal rule is defined by Inter as "LIST_WRITER_INTERNAL_R" with " (" (A), ")" (B), - " and " (C), + " and " (C), [ as used by WriteListR ] "providing light" (D), "closed" (E), "empty" (F), - "closed and empty" (G), - "closed and providing light" (H), - "empty and providing light" (I), - "closed, empty[if serial comma option is active],[end if] and providing light" (J), - "providing light and being worn" (K), + "closed and empty" (G), [ no longer used ] + "closed and providing light" (H), [ no longer used ] + "empty and providing light" (I), [ no longer used ] + "closed, empty[if serial comma option is active],[end if] and providing light" (J), [ no longer used ] + "providing light and being worn" (K), [ no longer used ] "being worn" (L), "open" (M), "open but empty" (N), - "closed" (O), - "closed and locked" (P), + "locked" (O), [ was "closed", i.e., redundant with (E), prior to 11.0 ] + "closed and locked" (P), [ no longer used ] "containing" (Q), "on [if the noun is a person]whom[otherwise]which[end if] " (R), ", on top of [if the noun is a person]whom[otherwise]which[end if] " (S), @@ -1164,7 +1164,8 @@ The list writer internal rule is defined by Inter as "[regarding list writer internals][are]" (V), "[regarding list writer internals][are] nothing" (W), "Nothing" (X), - "nothing" (Y). + "nothing" (Y), + " and " (Z). [ as used by WriteAfterEntryTerm ] The action processing internal rule is defined by Inter as "ACTION_PROCESSING_INTERNAL_R" with From efbfa98ce4d288f2c5aa4f773fceeba786cde062 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Wed, 10 Apr 2024 15:52:52 -0700 Subject: [PATCH 02/16] removing some debug statements --- .../WorldModelKit/Sections/ListWriter.i6t | 92 ++----------------- .../Sections/Variables and Rulebooks.w | 5 +- 2 files changed, 12 insertions(+), 85 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index c7c098322b..dafbeacdcf 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -720,6 +720,7 @@ The big one: |WriteListR| is the heart of the list-writer. [ WriteListR o depth from_start partition_classes partition_class_sizes cl memb index k2 l m no_classes q groups_to_do current_lt; + print "WriteListR^"; if (o == nothing) return; ! An empty list: no output if (from_start) { @@ -954,7 +955,7 @@ Constant LW_LOCKED = $$00100000; print ", "; if (print_count < and_position) print " "; } - if (print_count == and_position) LW_Response('Z', o); ! " and " + if (print_count == and_position) LW_Response('C', o); ! " and " LW_Response(lwresponse, o); return 1; } @@ -963,21 +964,18 @@ Constant LW_LOCKED = $$00100000; [ WriteAfterEntry o depth p recurse_flag parenth_flag eldest_child child_count print_count flags terms last_comma and_position bit_counter; - + print "WriteAfterEntry^"; inventory_stage = 2; if (c_style & PARTINV_BIT) { + print "partinv^"; ! zero to three of: closed, empty, providing light; BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { -! terms = 0; -! if (o has light && location hasnt light) { flags = flags | LW_LIT; terms++; } if (o has light && location hasnt light) flags = flags | LW_LIT; if (o has container) { if (o has open || o has transparent) { -! if (~~ObviouslyOccupied(o)) { flags = flags | LW_EMPTY; terms++; } if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; } -! if (o hasnt open) { flags = flags | LW_CLOSED; terms++; } if (o hasnt open) flags = flags | LW_CLOSED; } and_position = -1; @@ -988,31 +986,11 @@ Constant LW_LOCKED = $$00100000; if (BasicInformKit`SERIAL_COMMA_CFGF) last_comma = terms; else last_comma = terms - 1; } - if (terms) { + if (terms > 0) { LW_Response('A'); ! " (" -! print_count = 0; print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); -! if (flags & LW_CLOSED) { -! LW_Response('E', o); ! "closed" -! print_count++; -! } print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); - -!if (flags & LW_EMPTY) { -! if (print_count && print_count < last_comma) { -! print ","; -! if (print_count < and_position) print " "; -! } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('F', o); ! "empty" -! print_count++; -! } print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); -! if (flags & LW_LIT) { -! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('D', o); ! "providing light"; -! } LW_Response('B'); ! close bracket ")"; } } @@ -1022,52 +1000,30 @@ Constant LW_LOCKED = $$00100000; if (c_style & FULLINV_BIT) { + print "fullinv^"; BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { ! setup -! if (o has light) { flags = flags | LW_LIT; terms++; } -! if (o has worn) { flags = flags | LW_WORN; terms++; } if (o has light) flags = flags | LW_LIT; if (o has worn) flags = flags | LW_WORN; if (o has container) { if (o has openable) { if (o has open) { flags = flags | LW_OPEN; - if (~~ObviouslyOccupied(o)) !{ - flags = flags | LW_EMPTY; - !terms++; - !} + if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; } else { flags = flags | LW_CLOSED; if (o has locked) flags = flags | LW_LOCKED; - !if (o has locked) { flags = flags | LW_LOCKED; terms++; } } - !terms++; ! for one of 'open' or 'closed' } else { - if (((o has transparent)) && (~~ObviouslyOccupied(o))) !{ - flags = flags | LW_EMPTY; - !terms++; - !} + if (((o has transparent)) && (~~ObviouslyOccupied(o))) flags = flags | LW_EMPTY; } } terms = BitCount(flags); -! bit_counter = flags; -! do { -! if (~~(bit_counter % 2)) terms++; -! bit_counter = bit_counter / 2; -! } until (~~bit_counter); -! print "original terms: ", terms; -! terms = 0; -! bit_counter = flags; -! do { -! if (~~(bit_counter % 2)) terms++; -! bit_counter = bit_counter / 2; -! } until (~~bit_counter); -! print "; bit counted terms: ", terms, "^"; if (flags & (LW_OPEN | LW_EMPTY)) terms--; - if (terms) { + if (terms > 0) { print_count = 0; and_position = last_comma = -1; ! if there's more than one term, put an 'and' before term n @@ -1078,18 +1034,7 @@ Constant LW_LOCKED = $$00100000; } LW_Response('A'); ! " (" print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); -! if (flags & LW_LIT) { -! ! initial doesn't need and/comma check -! LW_Response('D', o); ! providing light -! print_count++; -! } print_count = print_count + WriteAfterEntryTerm(o, flags, LW_WORN, print_count, last_comma, and_position, 'L'); -! if (flags & LW_WORN) { -! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('L', o); ! being worn -! print_count++; -! } if (flags & LW_OPEN) { if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } if (print_count == and_position) LW_Response('Z', o); @@ -1098,27 +1043,8 @@ Constant LW_LOCKED = $$00100000; print_count++; } else print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); - -!if (flags & LW_EMPTY) { -! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('F', o); ! empty -! print_count++; -! } print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); -! if (flags & LW_CLOSED) { -! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('E', o); ! closed -! print_count++; -! } print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LOCKED, print_count, last_comma, and_position, 'O'); -! if (flags & LW_LOCKED) { -! if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } -! if (print_count == and_position) LW_Response('Z', o); -! LW_Response('O', o); ! locked -! print_count++; -! } LW_Response('B'); ! close bracket ")" } } diff --git a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w index e0617ae889..ac9fdd638b 100644 --- a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w +++ b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w @@ -1164,8 +1164,9 @@ The list writer internal rule is defined by Inter as "[regarding list writer internals][are]" (V), "[regarding list writer internals][are] nothing" (W), "Nothing" (X), - "nothing" (Y), - " and " (Z). [ as used by WriteAfterEntryTerm ] + "nothing" (Y). +[ , + " and " (Z). [ as used by WriteAfterEntryTerm ]] The action processing internal rule is defined by Inter as "ACTION_PROCESSING_INTERNAL_R" with From 5e81874956292c8c758643987f4c9d2a3f625f50 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Wed, 10 Apr 2024 19:45:46 -0700 Subject: [PATCH 03/16] removing debug statements; response Z --- .../Inter/WorldModelKit/Sections/ListWriter.i6t | 15 ++++++--------- .../Sections/Variables and Rulebooks.w | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index dafbeacdcf..0ca1793191 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -173,7 +173,7 @@ Global MarkedObjectLength = 0; MarkedObjectArray = RequisitionStack(length); MarkedObjectLength = length; if (MarkedObjectArray == 0) - return IssueRTP("ListWriterRanOutOfMemory", + return IssueRTP("ListWriterRanOutOfMemory", "The list-writer has run out of memory.^", BasicInformKitRTPs); if (common_parent) { @@ -720,7 +720,7 @@ The big one: |WriteListR| is the heart of the list-writer. [ WriteListR o depth from_start partition_classes partition_class_sizes cl memb index k2 l m no_classes q groups_to_do current_lt; - print "WriteListR^"; + if (o == nothing) return; ! An empty list: no output if (from_start) { @@ -743,7 +743,7 @@ The big one: |WriteListR| is the heart of the list-writer. partition_classes = RequisitionStack(index/WORDSIZE + 2); partition_class_sizes = RequisitionStack(index/WORDSIZE + 2); if ((partition_classes == 0) || (partition_class_sizes == 0)) - return IssueRTP("ListWriterRanOutOfMemory", + return IssueRTP("ListWriterRanOutOfMemory", "The list-writer has run out of memory.^", BasicInformKitRTPs); no_classes = @@ -964,14 +964,13 @@ Constant LW_LOCKED = $$00100000; [ WriteAfterEntry o depth p recurse_flag parenth_flag eldest_child child_count print_count flags terms last_comma and_position bit_counter; - print "WriteAfterEntry^"; inventory_stage = 2; if (c_style & PARTINV_BIT) { print "partinv^"; ! zero to three of: closed, empty, providing light; BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { - if (o has light && location hasnt light) flags = flags | LW_LIT; + if (o has light && location hasnt light) flags = flags | LW_LIT; if (o has container) { if (o has open || o has transparent) { if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; @@ -996,8 +995,6 @@ Constant LW_LOCKED = $$00100000; } EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); } ! end of PARTINV_BIT processing - ! gets "empty" if (open & openable) || (!openable & transparent) - if (c_style & FULLINV_BIT) { print "fullinv^"; @@ -1016,7 +1013,7 @@ Constant LW_LOCKED = $$00100000; flags = flags | LW_CLOSED; if (o has locked) flags = flags | LW_LOCKED; } - } + } else { if (((o has transparent)) && (~~ObviouslyOccupied(o))) flags = flags | LW_EMPTY; } @@ -1037,7 +1034,7 @@ Constant LW_LOCKED = $$00100000; print_count = print_count + WriteAfterEntryTerm(o, flags, LW_WORN, print_count, last_comma, and_position, 'L'); if (flags & LW_OPEN) { if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } - if (print_count == and_position) LW_Response('Z', o); + if (print_count == and_position) LW_Response('C', o); if (flags & LW_EMPTY) LW_Response('N', o); ! open but empty else LW_Response('M', o); ! open print_count++; diff --git a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w index ac9fdd638b..6fbd96e48c 100644 --- a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w +++ b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w @@ -1165,8 +1165,6 @@ The list writer internal rule is defined by Inter as "[regarding list writer internals][are] nothing" (W), "Nothing" (X), "nothing" (Y). -[ , - " and " (Z). [ as used by WriteAfterEntryTerm ]] The action processing internal rule is defined by Inter as "ACTION_PROCESSING_INTERNAL_R" with From 00ce2b8c79cf332b1caa6e0f998c89fe94e5cd84 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Thu, 11 Apr 2024 15:15:39 -0700 Subject: [PATCH 04/16] showing empty for closed transparent containers --- .../Inter/WorldModelKit/Sections/ListWriter.i6t | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 0ca1793191..9318a2272e 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -966,7 +966,6 @@ Constant LW_LOCKED = $$00100000; p recurse_flag parenth_flag eldest_child child_count print_count flags terms last_comma and_position bit_counter; inventory_stage = 2; if (c_style & PARTINV_BIT) { - print "partinv^"; ! zero to three of: closed, empty, providing light; BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { @@ -997,7 +996,6 @@ Constant LW_LOCKED = $$00100000; } ! end of PARTINV_BIT processing if (c_style & FULLINV_BIT) { - print "fullinv^"; BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { ! setup @@ -1005,11 +1003,13 @@ Constant LW_LOCKED = $$00100000; if (o has worn) flags = flags | LW_WORN; if (o has container) { if (o has openable) { - if (o has open) { - flags = flags | LW_OPEN; - if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; + if ((o has open) || (o has transparent)) { + if (~~ObviouslyOccupied(o)) { + flags = flags | LW_EMPTY; + if (o has open) flags = flags | LW_OPEN; + } } - else { + else if (o hasnt open) { flags = flags | LW_CLOSED; if (o has locked) flags = flags | LW_LOCKED; } From a151768080cc012ef45ecb35cdfbf53d53338ac8 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Sun, 14 Apr 2024 18:55:50 -0700 Subject: [PATCH 05/16] WriteAfterEntryTerms --- .../WorldModelKit/Sections/ListWriter.i6t | 190 +++++++++--------- 1 file changed, 91 insertions(+), 99 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 9318a2272e..503695c7cf 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -360,10 +360,11 @@ anyway. = [ ObviouslyOccupied o x; if (~~((o ofclass K5_container) || (o ofclass K6_supporter))) rfalse; - if (o has container && o hasnt open && o hasnt transparent) rfalse; ! opaque closed container's status can never be obvious +! if ((o has container) && (o hasnt open) && (o hasnt transparent)) print "rfalse "; + if ((o has container) && (o hasnt open) && (o hasnt transparent)) rfalse; ! opaque closed container's status can never be obvious x = child(o); while (x) { - if ((x hasnt concealed) && (~~TestConcealment(o, x))) rtrue; + if ((x hasnt concealed) && (~~(TestConcealment(o, x)))) rtrue; x = sibling(x); } rfalse; @@ -609,11 +610,14 @@ is implemented, which in turn hangs on the |parse_noun| properties compiled by Inform. But this seems to be sound. = -[ ListEqual o1 o2; +[ ListEqual o1 o2 occ1 occ2; if (o1.KD_Count ~= o2.KD_Count) rfalse; if ((o1.plural == 0) || (o2.plural == 0)) rfalse; - if (ObviouslyOccupied(o1) && WillRecurs(o1)) rfalse; - if (ObviouslyOccupied(o2) && WillRecurs(o2)) rfalse; + occ1 = ObviouslyOccupied(o1); + if (occ1 && WillRecurs(o1)) rfalse; + occ2 = ObviouslyOccupied(o2); + if (occ2 && WillRecurs(o2)) rfalse; + if (occ1 =~ occ2) rfalse; if (c_style & (FULLINV_BIT + PARTINV_BIT) ~= 0) { if ((o1 hasnt worn && o2 has worn) || (o2 hasnt worn && o1 has worn)) rfalse; if ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light)) rfalse; @@ -933,13 +937,15 @@ achieved by calling |WriteListR|, using the |ObjectTreeIterator| (whatever the iterator used at the top level) and increasing the depth by 1. = +Constant LW_LIT = $$01000000; ! 'D' +Constant LW_WORN = $$00100000; ! 'L' +Constant LW_CLOSED = $$00010000; ! 'E' +Constant LW_LOCKED = $$00001000; ! 'O' +Constant LW_OPEN = $$00000100; ! 'M' +Constant LW_EMPTY = $$00000010; ! 'F' +Constant LW_OPEN_BUT_EMPTY = $$00000001; ! 'N' -Constant LW_LIT = $$00000001; -Constant LW_CLOSED = $$00000010; -Constant LW_EMPTY = $$00000100; -Constant LW_WORN = $$00001000; -Constant LW_OPEN = $$00010000; -Constant LW_LOCKED = $$00100000; +Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; [ BitCount flags result; do { @@ -949,104 +955,90 @@ Constant LW_LOCKED = $$00100000; return result; ]; -[ WriteAfterEntryTerm o flags thisflag print_count last_comma and_position lwresponse; - if (flags & thisflag) { - if (print_count && print_count < last_comma) { - print ", "; - if (print_count < and_position) print " "; +! test that at least one flag is set before calling +[ WriteAfterEntryTerms o flags terms current counter print_count last_index last_comma; +!Glulx_PrintAnything(o); + terms = BitCount(flags); + if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { + flags = flags & (~(LW_OPEN + LW_EMPTY)); + flags = flags | LW_OPEN_BUT_EMPTY; + terms--; + } + last_index = terms - 1; ! where "and" goes if terms > 1 + current = LW_LIT; ! largest + if ((terms > 2) && BasicInformKit`SERIAL_COMMA_CFGF) last_comma = last_index; + else last_comma = last_index - 1; + +!print " -- "; +!if (flags & LW_LIT) print "lit "; +!if (flags & LW_WORN) print "worn "; +!if (flags & LW_CLOSED) print "closed "; +!if (flags & LW_LOCKED) print "locked "; +!if (flags & LW_OPEN) print "open "; +!if (flags & LW_EMPTY) print "empty "; +!if (flags & LW_OPEN_BUT_EMPTY) print "openbutempty "; +!print " -- "; + + + LW_Response('A'); ! " (" + while (current > 0) { + if (flags & current) { + if (print_count) { + if (print_count <= last_comma) { + print ","; + if ((print_count ~= last_index) || (~~(BasicInformKit`SERIAL_COMMA_CFGF))) print " "; + } + if (print_count == last_index) LW_Response('C', o); ! " and " + } + LW_Response(LW_Bit_To_Response->counter); + print_count++; } - if (print_count == and_position) LW_Response('C', o); ! " and " - LW_Response(lwresponse, o); - return 1; + counter++; + current = current / 2; } - return 0; + LW_Response('B'); ! close bracket ")"; ]; [ WriteAfterEntry o depth - p recurse_flag parenth_flag eldest_child child_count print_count flags terms last_comma and_position bit_counter; + p recurse_flag parenth_flag eldest_child child_count print_count flags terms empty bit_counter; inventory_stage = 2; if (c_style & PARTINV_BIT) { ! zero to three of: closed, empty, providing light; - BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); - if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { - if (o has light && location hasnt light) flags = flags | LW_LIT; - if (o has container) { - if (o has open || o has transparent) { - if (~~ObviouslyOccupied(o)) flags = flags | LW_EMPTY; - } - if (o hasnt open) flags = flags | LW_CLOSED; - } - and_position = -1; - terms = BitCount(flags); - ! if there's more than one term, put an 'and' before term n - if (terms > 1) and_position = terms - 1; - if (terms > 2) { - if (BasicInformKit`SERIAL_COMMA_CFGF) last_comma = terms; - else last_comma = terms - 1; - } - if (terms > 0) { - LW_Response('A'); ! " (" - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); - LW_Response('B'); ! close bracket ")"; - } - } - EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); + BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); + if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { + if (o has light && location hasnt light) flags = flags | LW_LIT; + if (o has container) { +! print "ObvOcc: ", ObviouslyOccupied(o), " "; + if ((o hasnt open) && (o hasnt transparent) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + if (o has openable) { + if (o has open) flags = flags | LW_OPEN; + else flags = flags | LW_CLOSED; + } + } + if (flags) WriteAfterEntryTerms(o, flags); + } + EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); } ! end of PARTINV_BIT processing - if (c_style & FULLINV_BIT) { - BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); - if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { - ! setup - if (o has light) flags = flags | LW_LIT; - if (o has worn) flags = flags | LW_WORN; - if (o has container) { - if (o has openable) { - if ((o has open) || (o has transparent)) { - if (~~ObviouslyOccupied(o)) { - flags = flags | LW_EMPTY; - if (o has open) flags = flags | LW_OPEN; - } - } - else if (o hasnt open) { - flags = flags | LW_CLOSED; - if (o has locked) flags = flags | LW_LOCKED; - } - } - else { - if (((o has transparent)) && (~~ObviouslyOccupied(o))) flags = flags | LW_EMPTY; - } - } - terms = BitCount(flags); - if (flags & (LW_OPEN | LW_EMPTY)) terms--; - if (terms > 0) { - print_count = 0; - and_position = last_comma = -1; - ! if there's more than one term, put an 'and' before term n - if (terms > 1) and_position = terms - 1; - if (terms > 2) { - if (BasicInformKit`SERIAL_COMMA_CFGF) last_comma = terms; - else last_comma = terms - 1; - } - LW_Response('A'); ! " (" - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LIT, print_count, last_comma, and_position, 'D'); - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_WORN, print_count, last_comma, and_position, 'L'); - if (flags & LW_OPEN) { - if (print_count && print_count < last_comma) { print ","; if (print_count < and_position) print " "; } - if (print_count == and_position) LW_Response('C', o); - if (flags & LW_EMPTY) LW_Response('N', o); ! open but empty - else LW_Response('M', o); ! open - print_count++; - } - else print_count = print_count + WriteAfterEntryTerm(o, flags, LW_EMPTY, print_count, last_comma, and_position, 'F'); - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_CLOSED, print_count, last_comma, and_position, 'E'); - print_count = print_count + WriteAfterEntryTerm(o, flags, LW_LOCKED, print_count, last_comma, and_position, 'O'); - LW_Response('B'); ! close bracket ")" - } - } - EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); - } ! end of FULLINV_BIT processing + if (c_style & FULLINV_BIT) { + BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); + if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { + if (o has light) flags = flags | LW_LIT; + if (o has worn) flags = flags | LW_WORN; + if (o has container) { +!print "ObvOcc: ", ObviouslyOccupied(o), " "; + if (((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + if (o has openable) { + if (o has open) flags = flags | LW_OPEN; + else flags = flags | LW_CLOSED; + } + + if (o has locked) flags = flags | LW_LOCKED; + } + if (flags) WriteAfterEntryTerms(o, flags); + } + EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); + } ! end of FULLINV_BIT processing child_count = 0; eldest_child = nothing; From 4bd85869e306899a25325bcc64224bd1993011a5 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Sun, 14 Apr 2024 21:31:49 -0700 Subject: [PATCH 06/16] emptiness working --- .../WorldModelKit/Sections/ListWriter.i6t | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 503695c7cf..7fe7934c4c 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -360,7 +360,6 @@ anyway. = [ ObviouslyOccupied o x; if (~~((o ofclass K5_container) || (o ofclass K6_supporter))) rfalse; -! if ((o has container) && (o hasnt open) && (o hasnt transparent)) print "rfalse "; if ((o has container) && (o hasnt open) && (o hasnt transparent)) rfalse; ! opaque closed container's status can never be obvious x = child(o); while (x) { @@ -617,11 +616,13 @@ by Inform. But this seems to be sound. if (occ1 && WillRecurs(o1)) rfalse; occ2 = ObviouslyOccupied(o2); if (occ2 && WillRecurs(o2)) rfalse; + if ((o1 hasnt open) && (o1 hasnt transparent)) occ1 = false; + if ((o2 hasnt open) && (o2 hasnt transparent)) occ2 = false; if (occ1 =~ occ2) rfalse; if (c_style & (FULLINV_BIT + PARTINV_BIT) ~= 0) { if ((o1 hasnt worn && o2 has worn) || (o2 hasnt worn && o1 has worn)) rfalse; if ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light)) rfalse; - if ((o1 has open && o2 hasnt open) || (o2 has open && o1 hasnt open)) rfalse; +! if ((o1 has open && o2 hasnt open) || (o2 has open && o1 hasnt open)) rfalse; } return Identical(o1, o2); ]; @@ -957,7 +958,6 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; ! test that at least one flag is set before calling [ WriteAfterEntryTerms o flags terms current counter print_count last_index last_comma; -!Glulx_PrintAnything(o); terms = BitCount(flags); if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { flags = flags & (~(LW_OPEN + LW_EMPTY)); @@ -968,18 +968,6 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; current = LW_LIT; ! largest if ((terms > 2) && BasicInformKit`SERIAL_COMMA_CFGF) last_comma = last_index; else last_comma = last_index - 1; - -!print " -- "; -!if (flags & LW_LIT) print "lit "; -!if (flags & LW_WORN) print "worn "; -!if (flags & LW_CLOSED) print "closed "; -!if (flags & LW_LOCKED) print "locked "; -!if (flags & LW_OPEN) print "open "; -!if (flags & LW_EMPTY) print "empty "; -!if (flags & LW_OPEN_BUT_EMPTY) print "openbutempty "; -!print " -- "; - - LW_Response('A'); ! " (" while (current > 0) { if (flags & current) { @@ -1003,13 +991,13 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; p recurse_flag parenth_flag eldest_child child_count print_count flags terms empty bit_counter; inventory_stage = 2; if (c_style & PARTINV_BIT) { - ! zero to three of: closed, empty, providing light; BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { if (o has light && location hasnt light) flags = flags | LW_LIT; if (o has container) { -! print "ObvOcc: ", ObviouslyOccupied(o), " "; - if ((o hasnt open) && (o hasnt transparent) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + if ((o has open) || (o has transparent)) { + if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + } if (o has openable) { if (o has open) flags = flags | LW_OPEN; else flags = flags | LW_CLOSED; @@ -1026,13 +1014,13 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if (o has light) flags = flags | LW_LIT; if (o has worn) flags = flags | LW_WORN; if (o has container) { -!print "ObvOcc: ", ObviouslyOccupied(o), " "; - if (((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + if ((o has open) || (o has transparent)) { + if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + } if (o has openable) { if (o has open) flags = flags | LW_OPEN; else flags = flags | LW_CLOSED; } - if (o has locked) flags = flags | LW_LOCKED; } if (flags) WriteAfterEntryTerms(o, flags); From 63bd164cd383d5d6649cb8a1cdc964b5f8372a10 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Sun, 14 Apr 2024 22:28:44 -0700 Subject: [PATCH 07/16] revising ListEqual --- .../WorldModelKit/Sections/ListWriter.i6t | 117 +++++++++--------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 7fe7934c4c..edbac47bf5 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -616,13 +616,20 @@ by Inform. But this seems to be sound. if (occ1 && WillRecurs(o1)) rfalse; occ2 = ObviouslyOccupied(o2); if (occ2 && WillRecurs(o2)) rfalse; - if ((o1 hasnt open) && (o1 hasnt transparent)) occ1 = false; - if ((o2 hasnt open) && (o2 hasnt transparent)) occ2 = false; - if (occ1 =~ occ2) rfalse; - if (c_style & (FULLINV_BIT + PARTINV_BIT) ~= 0) { - if ((o1 hasnt worn && o2 has worn) || (o2 hasnt worn && o1 has worn)) rfalse; - if ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light)) rfalse; -! if ((o1 has open && o2 hasnt open) || (o2 has open && o1 hasnt open)) rfalse; + if (c_style) { + if (c_style & FULLINV_BIT) { + if ((o1 hasnt worn && o2 has worn) || (o2 hasnt worn && o1 has worn)) rfalse; + if ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light)) rfalse; + if ((o1 hasnt locked && o2 has locked) || (o2 hasnt locked && o1 has locked)) rfalse; + } + else if (c_style & PARTINV_BIT) { + if ((location hasnt light) && ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light))) rfalse; + } + if (c_style & (FULLINV_BIT + PARTINV_BIT)) { + if ((((o1 has openable) || o1 has transparent)) && ((o2 has openable) || o2 has transparent)) { + if ((o1 has open && o2 hasnt open) || (o2 has open && o1 hasnt open))) rfalse; + if (occ1 =~ occ2) rfalse; + } } return Identical(o1, o2); ]; @@ -956,35 +963,48 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; return result; ]; -! test that at least one flag is set before calling -[ WriteAfterEntryTerms o flags terms current counter print_count last_index last_comma; - terms = BitCount(flags); - if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { - flags = flags & (~(LW_OPEN + LW_EMPTY)); - flags = flags | LW_OPEN_BUT_EMPTY; - terms--; - } - last_index = terms - 1; ! where "and" goes if terms > 1 - current = LW_LIT; ! largest - if ((terms > 2) && BasicInformKit`SERIAL_COMMA_CFGF) last_comma = last_index; - else last_comma = last_index - 1; - LW_Response('A'); ! " (" - while (current > 0) { - if (flags & current) { - if (print_count) { - if (print_count <= last_comma) { - print ","; - if ((print_count ~= last_index) || (~~(BasicInformKit`SERIAL_COMMA_CFGF))) print " "; - } - if (print_count == last_index) LW_Response('C', o); ! " and " +[ WriteAfterEntryTerms o roomdesc flags terms current counter print_count last_index last_comma; + if (o has light && (~~(roomdesc && (location has light)))) flags = flags | LW_LIT; + if (o has worn) flags = flags | LW_WORN; + if (o has container) { + if ((o has open) || (o has transparent)) { + if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed + } + if (o has openable) { + if (o has open) flags = flags | LW_OPEN; + else flags = flags | LW_CLOSED; + if ((o has locked) && (~~roomdesc)) flags = flags | LW_LOCKED; + } + } + if (flags) { + terms = BitCount(flags); + if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { + flags = flags & (~(LW_OPEN + LW_EMPTY)); + flags = flags | LW_OPEN_BUT_EMPTY; + terms--; + } + last_index = terms - 1; ! where "and" goes if terms > 1 + current = LW_LIT; ! largest + if ((terms > 2) && BasicInformKit`SERIAL_COMMA_CFGF) last_comma = last_index; + else last_comma = last_index - 1; + LW_Response('A'); ! " (" + while (current > 0) { + if (flags & current) { + if (print_count) { + if (print_count <= last_comma) { + print ","; + if ((print_count ~= last_index) || (~~(BasicInformKit`SERIAL_COMMA_CFGF))) print " "; } - LW_Response(LW_Bit_To_Response->counter); - print_count++; - } - counter++; - current = current / 2; - } - LW_Response('B'); ! close bracket ")"; + if (print_count == last_index) LW_Response('C', o); ! " and " + } + LW_Response(LW_Bit_To_Response->counter); + print_count++; + } + counter++; + current = current / 2; + } + LW_Response('B'); ! close bracket ")"; + } ]; [ WriteAfterEntry o depth @@ -993,17 +1013,8 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if (c_style & PARTINV_BIT) { BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { - if (o has light && location hasnt light) flags = flags | LW_LIT; - if (o has container) { - if ((o has open) || (o has transparent)) { - if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed - } - if (o has openable) { - if (o has open) flags = flags | LW_OPEN; - else flags = flags | LW_CLOSED; - } - } - if (flags) WriteAfterEntryTerms(o, flags); + WriteAfterEntryTerms(o, 1); +! if (flags) WriteAfterEntryTerms(o, flags); } EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); } ! end of PARTINV_BIT processing @@ -1011,19 +1022,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if (c_style & FULLINV_BIT) { BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { - if (o has light) flags = flags | LW_LIT; - if (o has worn) flags = flags | LW_WORN; - if (o has container) { - if ((o has open) || (o has transparent)) { - if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed - } - if (o has openable) { - if (o has open) flags = flags | LW_OPEN; - else flags = flags | LW_CLOSED; - } - if (o has locked) flags = flags | LW_LOCKED; - } - if (flags) WriteAfterEntryTerms(o, flags); + WriteAfterEntryTerms(o); } EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); } ! end of FULLINV_BIT processing From 11ce46599ce2c19bb90fd6accf455437dbd211ec Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Mon, 15 Apr 2024 01:58:23 -0700 Subject: [PATCH 08/16] fixed ListEqual --- .../WorldModelKit/Sections/ListWriter.i6t | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index edbac47bf5..ad404b0ca2 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -609,27 +609,22 @@ is implemented, which in turn hangs on the |parse_noun| properties compiled by Inform. But this seems to be sound. = -[ ListEqual o1 o2 occ1 occ2; +[ ListEqual o1 o2 f1 f2; if (o1.KD_Count ~= o2.KD_Count) rfalse; if ((o1.plural == 0) || (o2.plural == 0)) rfalse; - occ1 = ObviouslyOccupied(o1); - if (occ1 && WillRecurs(o1)) rfalse; - occ2 = ObviouslyOccupied(o2); - if (occ2 && WillRecurs(o2)) rfalse; - if (c_style) { - if (c_style & FULLINV_BIT) { - if ((o1 hasnt worn && o2 has worn) || (o2 hasnt worn && o1 has worn)) rfalse; - if ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light)) rfalse; - if ((o1 hasnt locked && o2 has locked) || (o2 hasnt locked && o1 has locked)) rfalse; - } - else if (c_style & PARTINV_BIT) { - if ((location hasnt light) && ((o1 hasnt light && o2 has light) || (o2 hasnt light && o1 has light))) rfalse; - } - if (c_style & (FULLINV_BIT + PARTINV_BIT)) { - if ((((o1 has openable) || o1 has transparent)) && ((o2 has openable) || o2 has transparent)) { - if ((o1 has open && o2 hasnt open) || (o2 has open && o1 hasnt open))) rfalse; - if (occ1 =~ occ2) rfalse; - } + if (c_style & FULLINV_BIT) { + f1 = DetailFlags(o1); + if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; + f2 = DetailFlags(o2); + if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; + if (f1 =~ f2) rfalse; + } + else if (c_style & PARTINV_BIT) { + f1 = DetailFlags(o1,1); + if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; + f2 = DetailFlags(o2,1); + if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; + if (f1 =~ f2) rfalse; } return Identical(o1, o2); ]; @@ -963,7 +958,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; return result; ]; -[ WriteAfterEntryTerms o roomdesc flags terms current counter print_count last_index last_comma; +[ DetailFlags o roomdesc flags; if (o has light && (~~(roomdesc && (location has light)))) flags = flags | LW_LIT; if (o has worn) flags = flags | LW_WORN; if (o has container) { @@ -976,7 +971,12 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if ((o has locked) && (~~roomdesc)) flags = flags | LW_LOCKED; } } - if (flags) { + return flags; +]; + +[ WriteAfterEntryTerms o roomdesc flags terms current counter print_count last_index last_comma; + flags = DetailFlags(o, roomdesc); + if (flags) { terms = BitCount(flags); if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { flags = flags & (~(LW_OPEN + LW_EMPTY)); From ece494d812c54d76c09db6a7e7b21ea066c1749f Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Mon, 15 Apr 2024 13:16:49 -0700 Subject: [PATCH 09/16] inlining bitcount; format changes --- .../WorldModelKit/Sections/ListWriter.i6t | 91 +++++++++---------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index ad404b0ca2..3a97cc6cd1 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -318,10 +318,10 @@ very rapid anyway (because the player can only read very slowly). START_ITF: return MarkedObjectArray-->0; COALESCE_ITF: return MarkedListCoalesce(); SEEK_ITF, ADVANCE_ITF: - for (i=0: ii == obj) { if (function == ADVANCE_ITF) i++; - for (:ii; if ((LT_Compare(required_lt, EMPTY_TEXT_VALUE) ~= 0) && (LT_Compare(obj.list_together, required_lt) ~= 0)) continue; @@ -374,20 +374,20 @@ The return value is the new first entry in the raw list. = [ MarkedListCoalesce o i lt l swap m; - for (i=0: ii).list_together; if (LT_Compare(lt, EMPTY_TEXT_VALUE) ~= 0) { ! Find first object in list after contiguous run with this list_together value: for (i++: (ii).list_together, lt) == 0): i++) ; + (LT_Compare((MarkedObjectArray-->i).list_together, lt) == 0): i++ ) ; ! If the contiguous run extends to end of list, the list is now perfect: if (i == MarkedObjectLength) return MarkedObjectArray-->0; ! And otherwise we look to see if any future entries belong in the earlier run: - for (l=i+1: ll).list_together, lt) == 0) { ! Yes, they do: so we perform a rotation to insert it before element i: swap = MarkedObjectArray-->l; - for (m=l: m>i: m--) MarkedObjectArray-->m = MarkedObjectArray-->(m-1); + for (m=l: m>i: m-- ) MarkedObjectArray-->m = MarkedObjectArray-->(m-1); MarkedObjectArray-->i = swap; ! And now the run is longer: i++; @@ -562,7 +562,7 @@ Global DBLW_no_classes; Global DBLW_no_objs; [ DebugPartition partition_class_sizes partition_classes first depth i k o; print "[Length of list is ", DBLW_no_objs, " with ", k, " plural.]^"; print "[Partitioned into ", DBLW_no_classes, " equivalence classes.]^"; - for (i=1: i<=DBLW_no_classes : i++) { + for (i=1: i<=DBLW_no_classes : i++ ) { print "Class ", i, " has size ", partition_class_sizes->i, "^"; } for (k=0, o=first: ki = 0; + for (i=0: ii = 0; n = 1; - for (i=first, k=0: kk == 0) { partition_classes->k = n; partition_class_sizes->n = 1; for (l=c_iterator(i, depth, lt_value, ADVANCE_ITF), m=k+1: (l~=0) && (mm == 0) && (ListEqual(i, l))) { if (partition_class_sizes->n < 255) (partition_class_sizes->n)++; partition_classes->m = n; @@ -613,18 +613,18 @@ by Inform. But this seems to be sound. if (o1.KD_Count ~= o2.KD_Count) rfalse; if ((o1.plural == 0) || (o2.plural == 0)) rfalse; if (c_style & FULLINV_BIT) { - f1 = DetailFlags(o1); + f1 = DetailFlags(o1,1); if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; - f2 = DetailFlags(o2); - if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; + f2 = DetailFlags(o2,1); if (f1 =~ f2) rfalse; + if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; } else if (c_style & PARTINV_BIT) { - f1 = DetailFlags(o1,1); + f1 = DetailFlags(o1); if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; - f2 = DetailFlags(o2,1); - if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; + f2 = DetailFlags(o2); if (f1 =~ f2) rfalse; + if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; } return Identical(o1, o2); ]; @@ -687,7 +687,7 @@ in the above sense. current_lt = EMPTY_TEXT_VALUE; lt = EMPTY_TEXT_VALUE; no_groups = no_classes; - for (cl=1, memb=o, k=0: cl<=no_classes: cl++) { + for (cl=1, memb=o, k=0: cl<=no_classes: cl++ ) { ! Advance to first member of class number cl while (partition_classes->k ~= cl) { k++; memb = c_iterator(memb, depth, lt_value, ADVANCE_ITF); @@ -759,7 +759,7 @@ The big one: |WriteListR| is the heart of the list-writer. groups_to_do = NumberOfGroupsInList(o, no_classes, depth, partition_classes, partition_class_sizes); - for (cl=1, memb=o, index=0, current_lt=EMPTY_TEXT_VALUE: groups_to_do>0: cl++) { + for (cl=1, memb=o, index=0, current_lt=EMPTY_TEXT_VALUE: groups_to_do>0: cl++ ) { ! Set memb to first object of partition class cl while (partition_classes->index ~= cl) { index++; memb=c_iterator(memb, depth, lt_value, ADVANCE_ITF); @@ -854,7 +854,7 @@ below, and {\it that} is where they are printed. } else if (pv) { ! Set k2 to the number of objects covered by the group k2 = 0; - for (l=0 : l(l+cl); + for (l=0 : l(l+cl); EnglishNumber(k2); print " "; print (TEXT_TY_Say) pv; if (c_style & ENGLISH_BIT ~= 0) print " ("; @@ -950,45 +950,43 @@ Constant LW_OPEN_BUT_EMPTY = $$00000001; ! 'N' Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; -[ BitCount flags result; - do { - if (flags % 2) result++; - flags = flags / 2; - } until (~~flags); - return result; -]; - -[ DetailFlags o roomdesc flags; - if (o has light && (~~(roomdesc && (location has light)))) flags = flags | LW_LIT; +[ DetailFlags o invdesc flags; + if (o has light && (invdesc || (location has light))) flags = flags | LW_LIT; if (o has worn) flags = flags | LW_WORN; if (o has container) { - if ((o has open) || (o has transparent)) { - if (~~(ObviouslyOccupied(o))) flags = flags | LW_EMPTY; ! ObviouslyOccupied is always false for opaque/closed - } + ! we can't know it's empty unless it's at least one of open or transparent + if (((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; if (o has openable) { if (o has open) flags = flags | LW_OPEN; else flags = flags | LW_CLOSED; - if ((o has locked) && (~~roomdesc)) flags = flags | LW_LOCKED; + if ((o has locked) && invdesc) flags = flags | LW_LOCKED; } } return flags; ]; -[ WriteAfterEntryTerms o roomdesc flags terms current counter print_count last_index last_comma; - flags = DetailFlags(o, roomdesc); +[ WriteAfterEntryTerms o invdesc flags terms current counter print_count last_index last_comma; + flags = DetailFlags(o, invdesc); if (flags) { - terms = BitCount(flags); if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { flags = flags & (~(LW_OPEN + LW_EMPTY)); flags = flags | LW_OPEN_BUT_EMPTY; - terms--; } + current = LW_LIT; ! largest + while (current) { ! count bits by shifting right till we're at 0 + if (flags & current) terms++; + #ifdef TARGET_ZCODE; + @log_shift current -1 -> current; + #ifnot; + @ushiftr current 1 current; + #endif; + } last_index = terms - 1; ! where "and" goes if terms > 1 current = LW_LIT; ! largest if ((terms > 2) && BasicInformKit`SERIAL_COMMA_CFGF) last_comma = last_index; else last_comma = last_index - 1; LW_Response('A'); ! " (" - while (current > 0) { + while (current) { if (flags & current) { if (print_count) { if (print_count <= last_comma) { @@ -1001,10 +999,14 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; print_count++; } counter++; - current = current / 2; + #ifdef TARGET_ZCODE; + @log_shift current -1 -> current; + #ifnot; + @ushiftr current 1 current; + #endif; } LW_Response('B'); ! close bracket ")"; - } + } ]; [ WriteAfterEntry o depth @@ -1012,18 +1014,13 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; inventory_stage = 2; if (c_style & PARTINV_BIT) { BeginActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); - if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) { - WriteAfterEntryTerms(o, 1); -! if (flags) WriteAfterEntryTerms(o, flags); - } + if (ForActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o) == false) WriteAfterEntryTerms(o); EndActivity(PRINTING_ROOM_DESC_DETAILS_ACT, o); } ! end of PARTINV_BIT processing if (c_style & FULLINV_BIT) { BeginActivity(PRINTING_INVENTORY_DETAILS_ACT, o); - if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) { - WriteAfterEntryTerms(o); - } + if (ForActivity(PRINTING_INVENTORY_DETAILS_ACT, o) == false) WriteAfterEntryTerms(o, 1); EndActivity(PRINTING_INVENTORY_DETAILS_ACT, o); } ! end of FULLINV_BIT processing From 0237c60b65f21f0b40141f551b92cd7f01dc58cf Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Mon, 15 Apr 2024 13:39:16 -0700 Subject: [PATCH 10/16] switching the polarity of the inv flow --- inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 3a97cc6cd1..416ca9590f 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -951,7 +951,7 @@ Constant LW_OPEN_BUT_EMPTY = $$00000001; ! 'N' Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; [ DetailFlags o invdesc flags; - if (o has light && (invdesc || (location has light))) flags = flags | LW_LIT; + if (o has light && (invdesc || (location hasnt light))) flags = flags | LW_LIT; if (o has worn) flags = flags | LW_WORN; if (o has container) { ! we can't know it's empty unless it's at least one of open or transparent From cb089e179ef7cb0a58f5998dbaa4dcee9a658a84 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Tue, 16 Apr 2024 07:45:01 -0700 Subject: [PATCH 11/16] cleanup --- .../Internal/Inter/WorldModelKit/Sections/ListWriter.i6t | 9 ++++++--- .../standard_rules/Sections/Physical World Model.w | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 416ca9590f..9986f2ece4 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -965,7 +965,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; return flags; ]; -[ WriteAfterEntryTerms o invdesc flags terms current counter print_count last_index last_comma; +[ WriteAfterEntryTerms o invdesc flags terms current counter print_count last_index last_comma spare x; flags = DetailFlags(o, invdesc); if (flags) { if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { @@ -976,7 +976,9 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; while (current) { ! count bits by shifting right till we're at 0 if (flags & current) terms++; #ifdef TARGET_ZCODE; - @log_shift current -1 -> current; + x = -1; + @log_shift current x -> current; +! current = spare; #ifnot; @ushiftr current 1 current; #endif; @@ -1000,7 +1002,8 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; } counter++; #ifdef TARGET_ZCODE; - @log_shift current -1 -> current; + @log_shift current x -> current; +! current = spare; #ifnot; @ushiftr current 1 current; #endif; diff --git a/inform7/extensions/standard_rules/Sections/Physical World Model.w b/inform7/extensions/standard_rules/Sections/Physical World Model.w index a044b128d9..ec88be1537 100644 --- a/inform7/extensions/standard_rules/Sections/Physical World Model.w +++ b/inform7/extensions/standard_rules/Sections/Physical World Model.w @@ -131,6 +131,8 @@ I6 routine "ObviouslyOccupied" says so (it contains at least one obvious thing). Definition: a supporter is obviously-occupied rather than possibly-unoccupied if I6 routine "ObviouslyOccupied" says so (it supports at least one obvious thing). +Definition: a container is seemingly-empty if (it is open or it is transparent) and it is not obviously-occupied. + Definition: a container (called c) is falsely-unoccupied: if the first thing held by it is nothing, no; if it is closed and it is opaque and it does not enclose the player, no; From db95c23410c00dadbe7f23aac320603b3ab11231 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Thu, 18 Apr 2024 11:19:39 -0700 Subject: [PATCH 12/16] cleanup debug statements --- .../WorldModelKit/Sections/ListWriter.i6t | 77 ++++++++++++------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 9986f2ece4..5291105319 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -609,31 +609,51 @@ is implemented, which in turn hangs on the |parse_noun| properties compiled by Inform. But this seems to be sound. = -[ ListEqual o1 o2 f1 f2; + +!#ifdef TARGET_GLULX; +Array NBUF1 --> TEXT_TY_BufferSize; +Array NBUF2 --> TEXT_TY_BufferSize; + +[ lstring str i; +!print "len: ", str-->0, " "; +#ifdef TARGET_GLULX; +for (i = 1 : i <= str-->0 : i++ ) glk_put_char_uni(str-->i); +#ifnot; +for (i = WORDSIZE : i < ((str-->0) + WORDSIZE) : i++ ) print (char) str->i; +#endif; +]; + +[ StringEqualObjectNames o1 o2 i; + VM_PrintToBuffer(NBUF1, TEXT_TY_BufferSize, PSN__, o1); + VM_PrintToBuffer(NBUF2, TEXT_TY_BufferSize, PSN__, o2); +#ifdef TARGET_GLULX; + for ( i = 0 : i <= NBUF1-->0 : i++ ) if (NBUF1-->i ~= NBUF2-->i) rfalse; +#ifnot; + if (NBUF1-->0 ~= NBUF2-->0) rfalse; + for (i = WORDSIZE : i < ((NBUF1-->0) + WORDSIZE) : i++ ) if (NBUF1->i ~= NBUF2->i) rfalse; +#endif; + rtrue; +]; + +[ ListEqual o1 o2 v1 v2; if (o1.KD_Count ~= o2.KD_Count) rfalse; if ((o1.plural == 0) || (o2.plural == 0)) rfalse; - if (c_style & FULLINV_BIT) { - f1 = DetailFlags(o1,1); - if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; - f2 = DetailFlags(o2,1); - if (f1 =~ f2) rfalse; - if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; - } - else if (c_style & PARTINV_BIT) { - f1 = DetailFlags(o1); - if ((f1 & LW_EMPTY) && WillRecurs(o1)) rfalse; - f2 = DetailFlags(o2); - if (f1 =~ f2) rfalse; - if ((f2 & LW_EMPTY) && WillRecurs(o2)) rfalse; + ! only containers get labeled empty, so DetailFlags only calls ObviouslyOccupied for containers + ! so for supporter case we have to test here + if (o1 ofclass K6_supporter) { + v1 = ObviouslyOccupied(o1); + if (v1 && ((c_style & ALWAYS_BIT) || (~~(c_style & RECURSE_BIT)))) rfalse; + v2 = ObviouslyOccupied(o1); + if (v2 && ((c_style & ALWAYS_BIT) || (~~(c_style & RECURSE_BIT)))) rfalse; + if (v1 ~= v2) rfalse; } - return Identical(o1, o2); -]; - -[ WillRecurs o; - if (c_style & ALWAYS_BIT ~= 0) rtrue; - if (c_style & RECURSE_BIT == 0) rfalse; - if ((o has supporter) || ((o has container) && (o has open or transparent))) rtrue; - rfalse; + if ((c_style & FULLINV_BIT) && (DetailFlags(o1,1,1) ~= DetailFlags(o2,1,1))) rfalse; + else if ((c_style & PARTINV_BIT) && (DetailFlags(o1,0,1) ~= DetailFlags(o2,0,1))) rfalse; +!#ifdef TARGET_GLULX; + return StringEqualObjectNames(o1, o2); +!#ifnot; +! return Identical(o1, o2); +!#endif; ]; @h Grouping. @@ -950,22 +970,23 @@ Constant LW_OPEN_BUT_EMPTY = $$00000001; ! 'N' Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; -[ DetailFlags o invdesc flags; - if (o has light && (invdesc || (location hasnt light))) flags = flags | LW_LIT; +[ DetailFlags o invdesc empty_truth flags; + if (o has light && (invdesc || (location hasnt light))) flags = flags | LW_LIT; ! this is overly simplistic... it shouldn't be whether the location has light but whether the player would be in darkness without some lit object in the location that the player doesn't carry if (o has worn) flags = flags | LW_WORN; if (o has container) { ! we can't know it's empty unless it's at least one of open or transparent - if (((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) flags = flags | LW_EMPTY; + ! TODO but not unopenable closed transparent things + if ((((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) && (~~((o hasnt open) && (o hasnt openable) && (~~empty_truth)))) flags = flags | LW_EMPTY; + if ((o has locked) && invdesc) flags = flags | LW_LOCKED; if (o has openable) { if (o has open) flags = flags | LW_OPEN; else flags = flags | LW_CLOSED; - if ((o has locked) && invdesc) flags = flags | LW_LOCKED; } } return flags; ]; -[ WriteAfterEntryTerms o invdesc flags terms current counter print_count last_index last_comma spare x; +[ WriteAfterEntryTerms o invdesc flags terms current counter print_count last_index last_comma x; flags = DetailFlags(o, invdesc); if (flags) { if ((flags & LW_OPEN) && (flags & LW_EMPTY)) { @@ -978,7 +999,6 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; #ifdef TARGET_ZCODE; x = -1; @log_shift current x -> current; -! current = spare; #ifnot; @ushiftr current 1 current; #endif; @@ -1003,7 +1023,6 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; counter++; #ifdef TARGET_ZCODE; @log_shift current x -> current; -! current = spare; #ifnot; @ushiftr current 1 current; #endif; From b6c1a61f825f2ce21ce3b20e3d0446d72e05d6cf Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Thu, 18 Apr 2024 21:24:30 -0700 Subject: [PATCH 13/16] fine tuning --- .../Internal/Inter/WorldModelKit/Sections/ListWriter.i6t | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 5291105319..3ac40181da 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -649,11 +649,7 @@ for (i = WORDSIZE : i < ((str-->0) + WORDSIZE) : i++ ) print (char) str->i; } if ((c_style & FULLINV_BIT) && (DetailFlags(o1,1,1) ~= DetailFlags(o2,1,1))) rfalse; else if ((c_style & PARTINV_BIT) && (DetailFlags(o1,0,1) ~= DetailFlags(o2,0,1))) rfalse; -!#ifdef TARGET_GLULX; return StringEqualObjectNames(o1, o2); -!#ifnot; -! return Identical(o1, o2); -!#endif; ]; @h Grouping. @@ -975,8 +971,8 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if (o has worn) flags = flags | LW_WORN; if (o has container) { ! we can't know it's empty unless it's at least one of open or transparent - ! TODO but not unopenable closed transparent things - if ((((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) && (~~((o hasnt open) && (o hasnt openable) && (~~empty_truth)))) flags = flags | LW_EMPTY; + ! TODO but not unopenable closed transparent things ! && (~~((o hasnt open) && (o hasnt openable)) && (~~empty_truth)) + if ((((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) ) flags = flags | LW_EMPTY; if ((o has locked) && invdesc) flags = flags | LW_LOCKED; if (o has openable) { if (o has open) flags = flags | LW_OPEN; From fc958db1baa0d1a181a7428d4bf66277163b3d92 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Thu, 18 Apr 2024 22:51:05 -0700 Subject: [PATCH 14/16] final cleanup --- .../WorldModelKit/Sections/ListWriter.i6t | 17 ++------ .../standard_rules/Sections/Activities.w | 41 ------------------- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 3ac40181da..30e90dfefa 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -586,7 +586,7 @@ accordingly. We return $n$, the number of classes. partition_classes->k = n; partition_class_sizes->n = 1; for (l=c_iterator(i, depth, lt_value, ADVANCE_ITF), m=k+1: (l~=0) && (mm == 0) && (ListEqual(i, l))) { if (partition_class_sizes->n < 255) (partition_class_sizes->n)++; partition_classes->m = n; @@ -610,19 +610,9 @@ by Inform. But this seems to be sound. = -!#ifdef TARGET_GLULX; Array NBUF1 --> TEXT_TY_BufferSize; Array NBUF2 --> TEXT_TY_BufferSize; -[ lstring str i; -!print "len: ", str-->0, " "; -#ifdef TARGET_GLULX; -for (i = 1 : i <= str-->0 : i++ ) glk_put_char_uni(str-->i); -#ifnot; -for (i = WORDSIZE : i < ((str-->0) + WORDSIZE) : i++ ) print (char) str->i; -#endif; -]; - [ StringEqualObjectNames o1 o2 i; VM_PrintToBuffer(NBUF1, TEXT_TY_BufferSize, PSN__, o1); VM_PrintToBuffer(NBUF2, TEXT_TY_BufferSize, PSN__, o2); @@ -971,7 +961,6 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; if (o has worn) flags = flags | LW_WORN; if (o has container) { ! we can't know it's empty unless it's at least one of open or transparent - ! TODO but not unopenable closed transparent things ! && (~~((o hasnt open) && (o hasnt openable)) && (~~empty_truth)) if ((((o has open) || (o has transparent)) && (~~(ObviouslyOccupied(o)))) ) flags = flags | LW_EMPTY; if ((o has locked) && invdesc) flags = flags | LW_LOCKED; if (o has openable) { @@ -993,7 +982,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; while (current) { ! count bits by shifting right till we're at 0 if (flags & current) terms++; #ifdef TARGET_ZCODE; - x = -1; + x = -1; @log_shift current x -> current; #ifnot; @ushiftr current 1 current; @@ -1006,7 +995,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; LW_Response('A'); ! " (" while (current) { if (flags & current) { - if (print_count) { + if (print_count) { if (print_count <= last_comma) { print ","; if ((print_count ~= last_index) || (~~(BasicInformKit`SERIAL_COMMA_CFGF))) print " "; diff --git a/inform7/extensions/standard_rules/Sections/Activities.w b/inform7/extensions/standard_rules/Sections/Activities.w index 6f912f456c..e749b7bb50 100644 --- a/inform7/extensions/standard_rules/Sections/Activities.w +++ b/inform7/extensions/standard_rules/Sections/Activities.w @@ -69,47 +69,6 @@ The printing room description details activity is accessible to Inter as "PRINTI Printing inventory details of something (hidden in RULES command) (documented at act_idetails) is an activity. The printing inventory details activity is accessible to Inter as "PRINTING_INVENTORY_DETAILS_ACT". -[ -To say the deceitfully empty inventory details of (box - a container): - let inventory text printed be false; - if the box is lit begin; - if the box is worn, say text of list writer internal rule response (K); [ "providing light and being worn" ] - else say text of list writer internal rule response (D); [ "providing light" ] - now inventory text printed is true; - else if the box is worn; - say text of list writer internal rule response (L); [ "being worn" ] - now inventory text printed is true; - end if; - if the box is openable begin; - if inventory text printed is true begin; - if the serial comma option is active, say ","; - say text of list writer internal rule response (C); [ "and" ] - end if; - if the box is open begin; - say text of list writer internal rule response (N); [ "open but empty" ] - else; [ it's closed ] - if the box is locked, say text of list writer internal rule response (P); [ "closed and locked" ] - else say text of list writer internal rule response (O); [ "closed" ] - now inventory text printed is true; - end if; - else; [ it's not openable ] - if the box is transparent begin; - if inventory text printed is true, say text of list writer internal rule response (C); [ "and" ] - say text of list writer internal rule response (F); [ "empty" ] - now inventory text printed is true; [ not relevant unless code is added ] - end if; - end if; -] -[ -For printing inventory details of a container (called the box) when the box is falsely-unoccupied (this is the falsely-unoccupied container inventory details rule): - let the tag be "[the deceitfully empty inventory details of box]"; - if tag is not empty begin; - say text of list writer internal rule response (A); [ "(" ] - say tag; - say text of list writer internal rule response (B); [ ")" ] - end if; -] - @ Names of things are often formed up into lists, in which they are sometimes grouped together: From 0fd2282fc3df9ed251aaeb43b13a04c37f144eed Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Fri, 19 Apr 2024 11:30:06 -0700 Subject: [PATCH 15/16] moving assignment out of loop --- inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index 30e90dfefa..21ba4bdfb9 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -979,10 +979,12 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; flags = flags | LW_OPEN_BUT_EMPTY; } current = LW_LIT; ! largest + #ifdef TARGET_ZCODE; + x = -1; + #endif; while (current) { ! count bits by shifting right till we're at 0 if (flags & current) terms++; #ifdef TARGET_ZCODE; - x = -1; @log_shift current x -> current; #ifnot; @ushiftr current 1 current; From 204f7ed143bb50a7a626e90d8cc9a0681de5f8b2 Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Sun, 19 May 2024 18:52:39 -0700 Subject: [PATCH 16/16] add list writer internal rule response Z --- inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t | 2 +- .../standard_rules/Sections/Variables and Rulebooks.w | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t index d14a905816..936b0d6221 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/ListWriter.i6t @@ -1002,7 +1002,7 @@ Array LW_Bit_To_Response -> [ 'D'; 'L'; 'E'; 'O'; 'M'; 'F'; 'N' ]; print ","; if ((print_count ~= last_index) || (~~(BasicInformKit`SERIAL_COMMA_CFGF))) print " "; } - if (print_count == last_index) LW_Response('C', o); ! " and " + if (print_count == last_index) LW_Response('Z', o); ! " and " } LW_Response(LW_Bit_To_Response->counter); print_count++; diff --git a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w index c01c8b5348..41e3d19ffa 100644 --- a/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w +++ b/inform7/extensions/standard_rules/Sections/Variables and Rulebooks.w @@ -1167,7 +1167,8 @@ The list writer internal rule is defined by Inter as "[regarding list writer internals][are]" (V), "[regarding list writer internals][are] nothing" (W), "Nothing" (X), - "nothing" (Y). + "nothing" (Y), + " and " (Z). The action processing internal rule is defined by Inter as "ACTION_PROCESSING_INTERNAL_R" with