ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

The return value of s1_has_trait is reversed with PUT ALL ON CONTAINER #267

Open warrigal24 opened 3 years ago

warrigal24 commented 3 years ago

I have a bunch of Christmas presents that are identified by the trait 'treasure_t'. I also have a sleigh. You can only put things on the sleigh if they are Christmas presents. This is checked using s1_has_trait "treasure_t". If they aren't presents, you get an appropriate message. A sample program is attached. You can put all the individual presents on the sleigh, but if you try to PUT ALL ON SLEIGH, it fails. After considerable experimenting, I realised that the return value of the s1_has_trait test is flipped with PUT ALL.

Here is some sample input:

>GET ALL
You get the jack-in-the-box.
You get the skipping rope.
You get the lump of coal.

>PUT ALL ON SLEIGH
Expected:
You put the jack-in-the-box on the sleigh.
You put the skipping rope on the sleigh.
You put the lump of coal on the sleigh.
Actual:
You can only put the presents for the children on the sleigh.
You can only put the presents for the children on the sleigh.
You can only put the presents for the children on the sleigh.

>PUT BOX ON SLEIGH
You put the jack-in-the-box on the sleigh.

>PUT ROPE ON SLEIGH
You put the skipping rope on the sleigh.

>PUT COAL ON SLEIGH
You put the lump of coal on the sleigh.

Here's the sample program with debugging code to show that in each case, noun1 is identified correctly and s1 is identified correctly, but PUT ALL fails. If you change the test from '!s1_has_trait' to 's1_has_trait', the results are reversed. PUT ALL works, but PUT doesn't.

start_at = room01

game_settings {
   enable_standard_all_behaviour = false
   experimental_auto_propogate_known = true
   experimental_new_parser = true
   experimental_new_scoping = true
}

integers {
   sleigh_item_limit : integer_const "10";
}

collections {
   list_object_buffer : list;
}

traits {
   treasure_t : trait;
}

locations {
   room01 : location "You're in a barn.";
   limbo : location "You're in limbo.";
}

objects {
   cookie_box : object "a cookie box" at = "limbo";
   jack_box : object "a jack-in-the-box" at = "room01" weight = "6" {experimental_matching_text_sequences = ["jack-in-the-box", "jack in the box", "jack-in-box", "jack in box", "jack box", "jack", "box"] traits = [treasure_t]}
   skipping_rope : object "a skipping rope" at = "room01" weight = "3" {experimental_matching_text_sequences = ["skipping rope", "skipping", "rope"] traits = [treasure_t]}
   sleigh : scenery "Santa's sleigh" at = "room01" container_type = "surface" {experimental_matching_text_sequences = ["santa's sleigh", "sleigh"]}
   rope : object "a rope" at = "limbo" weight = "3";
   coal : object "a lump of coal" at = "room01" weight = "2" {experimental_matching_text_sequences = ["lump of coal", "lump", "coal"] traits = [treasure_t]}
}

on_pre_command {
   : match "_ _" {
      : disambiguate_s1 "present";
      : disambiguate_s2 "present";
   }
}

on_command {
   // Cookie box (container)
   : if (is_present "cookie_box") {
      : match "examine box" {
         : print "It's a box with a hinged lid and a latch to keep it shut. ";
         : done;
      }
   }
   // Jack-in-the-box (treasure)
   : if (is_present "jack_box") {
      : match "examine box" {
         : print "It's the jack-in-the-box you made for Jennifer.";
      }
   }
   // Skipping rope (treasure)
   : if (is_present "skipping_rope") {
      : match "examine rope" {
         : print "It's the skipping rope you made for Cindy.";
         : done;
      }
   }
   // Santa's sleigh (supporter)
   : if (is_present "sleigh") {
      : match "examine sleigh" {
         : disambiguate_s1 "present";
         : append "It's Santa's sleigh. ";
         : if (child_count(s1()) == 0) {
            : print "None of the toys were made by you.";
            : done;
         }
         : append "Of the toys on the sleigh, yours ";
         : if (child_count(s1()) == 1) {
            : append "is ";
         }
         : else {
            : append "are ";
         }
         : look_inside
            of = "sleigh"
            extract_the = "description"
            store_results_in = "list_object_buffer"
            make_known = "true";
         : print_list_verbose "list_object_buffer" lead_in = "";
         : done;
      }
      : match "get all" {
         : disambiguate_s2 "present";
         : if (s2() == "sleigh") {
            : do_all "sleigh";
         }
      }
      : match "get _" {
         : disambiguate_s1 "present";
         : disambiguate_s2 "present";
         : if (parent_of(s1()) == "sleigh" && (s2() == "sleigh" || noun2_is "")) {
            : remove_from_container "sleigh" quiet = "true";
            : print {("You get " + definite(d(s1())) + ".")}
            : done;
         }
      }
      : match "put all" {
         : disambiguate_s2 "present";
         : if (s2() == "sleigh") {
            : do_all "inventory_notworn";
         }
      }
      : match "put _" {
         : disambiguate_s1 "carried" with_trait = "treasure_t";
         : disambiguate_s2 "present";
         : gosub "test_parser";
         : if (s2() == "sleigh") {
            : if (parent_of(s1()) == "sleigh") {
               : print {(first_cap(definite(d(s1()))) + " is already on Santa's sleigh.")}
               : done;
            }
            : if (!is_carried(s1())) {
               : print {("You're not carrying any " + original "noun1" + ".")}
               : done;
            }
            : if (!s1_has_trait "treasure_t") {
               : print "You can only put the presents for the children on the sleigh.";
               : done;
            }
            : if (child_count(s2()) == sleigh_item_limit) {
               : print "You can't put any more items on the sleigh.";
               : done;
            }
            : if (weigh(s1()) > 6) {
               : print {(first_cap(definite(d(s1()))) + "  won't fit on the sleigh.")}
               : done;
            }
            : insert_in_container "sleigh" quiet = "true";
            : print {("You put " + definite(d(s1())) + " on Santa's sleigh.")}
            : done;
         }
      }
   }

   // Rope
   : if (is_present "rope") {
      : match "examine rope" {
         : print "It's a short length of rope.";
         : done;
      }
   }

   // Lump of coal
   : if (is_present "coal") {
      : match "examine coal" {
         : print "It's a lump of coal.";
         : done;
      }
   }

   // Post processing of verbs (in alphabetical order)
   // Drop
   : match "drop *" {
      : if (noun1_is "all") {
         : do_all "inventory_notworn";
      }
      : disambiguate_s1 "carried";
      : if (!is_carried(s1())) {
         : print {("You're not carrying any " + original "noun1" + ".")}
         : done;
      }
      : if (is_carried (s1()) && !is_worn (s1())) {
         : drop quiet = "true";
         : print {("You drop " + definite(d(s1())) + ".")}
         : done;
      }
   }
   // Get
   : match "get *" {
      : if (noun1_is "all") {
         : do_all "current_location_objects";
      }
      : disambiguate_s1 "present";
      : if (is_carried(s1())) {
         : print {("You're already carrying " + definite(d(s1())) + ".")}
         : done;
      }
      : if (!is_present(s1())) {
         : print {("You can't see any " + original "noun1" + " here.")}
         : done;
      }
      : if (!is_pocketable (s1())) {
         : print "You can't carry any more. Try dropping something.";
         : done;
      }
      : if (is_beside (s1())) {
         : get quiet = "true";
         : print {("You get " + definite(d(s1())) + ".")}
         : done;
      }
   }
   // Put
   : match "put *" {
      : disambiguate_s1 "carried";
      : if (!is_carried(s1())) {
         : print {("You're not carrying any " + original "noun1" + ".")}
         : done;
      }
      : print "There's no container.";
      : done;
   }
   // Remove
   : match "remove *" {
      : if (noun1_is "all") {
         : do_all "inventory_worn";
      }
   }
   // Wear
   : match "wear *" {
      : if (noun1_is "all") {
         : do_all "inventory_notworn_wearable";
      }
      : disambiguate_s1 "present";
      : if (is_worn(s1())) {
         : print {("You're already wearing " + definite(d(s1())) + ".")}
         : done;
      }
      : if (!is_carried(s1())) {
         : print {("You're not carrying any " + original "noun1" + ".")}
         : done;
      }
   }
}

subroutines {
   test_parser : subroutine {
      : match "_ _" {
         : mask {
            : print {("^n^verb = " + original "verb")}
            : print {("^n^preposition1 = " + original "preposition1")}
            : print {("^n^noun1 = " + original "noun1")}
            : print {("^n^preposition2 = " + original "preposition2")}
            : print {("^n^noun2 = " + original "noun2")}
            : print {("^n^s1 = " + s1())}
            : print {("^n^s2 = " + s2() + "^m^")}
         }
      }
   }
}
ainslec commented 3 years ago

Trimmed down minimal test case :

start_at = room01

game_settings {
   enable_standard_all_behaviour = false
   experimental_auto_propogate_known = true
   experimental_new_parser = true
   experimental_new_scoping = true
}

integers {
   sleigh_item_limit : integer_const "10";
}

collections {
   list_object_buffer : list;
}

traits {
   treasure_t : trait;
}

locations {
   room01 : location "You're in a barn.";
}

objects {

   sleigh : scenery "Santa's sleigh" at = "room01" container_type = "surface" {experimental_matching_text_sequences = ["santa's sleigh", "sleigh"]}
   coal : object "a lump of coal" at = "inventory" weight = "2" {experimental_matching_text_sequences = ["lump of coal", "lump", "coal"] traits = [treasure_t]}
}

on_pre_command {
   : match "_ _" {
      : disambiguate_s1 "present";
      : disambiguate_s2 "present";
   }
}

on_command {
   : match "put all" {
      : disambiguate_s2 "present";
      : if (s2() == "sleigh") {
         : do_all "inventory_notworn";
      }
   }
   : match "put _" {
      : disambiguate_s1 "carried" with_trait = "treasure_t";
      : disambiguate_s2 "present";

      : mask {
         : print {("^n^verb = " + original "verb")}
         : print {("^n^preposition1 = " + original "preposition1")}
         : print {("^n^noun1 = " + original "noun1")}
         : print {("^n^preposition2 = " + original "preposition2")}
         : print {("^n^noun2 = " + original "noun2")}
         : print {("^n^s1 = " + s1())}
         : print {("^n^s2 = " + s2() + "^m^")}
      }

      : if (s2() == "sleigh") {
         : if (parent_of(s1()) == "sleigh") {
            : print {(first_cap(definite(d(s1()))) + " is already on Santa's sleigh.")}
            : done;
         }
         : if (!is_carried(s1())) {
            : print {("You're not carrying any " + original "noun1" + ".")}
            : done;
         }
         : if (!s1_has_trait "treasure_t") {
            : print "You can only put the presents for the children on the sleigh.";
            : done;
         }
         : if (child_count(s2()) == sleigh_item_limit) {
            : print "You can't put any more items on the sleigh.";
            : done;
         }
         : if (weigh(s1()) > 6) {
            : print {(first_cap(definite(d(s1()))) + "  won't fit on the sleigh.")}
            : done;
         }
         : insert_in_container "sleigh" quiet = "true";
         : print {("You put " + definite(d(s1())) + " on Santa's sleigh.")}
         : done;
      }
   }
}
ainslec commented 3 years ago

Fixed in beta 66s.

ainslec commented 3 years ago

From Garry:

"Re #267: PUT ALL ON SLEIGH now works, but GET ALL FROM SLEIGH fails on first object. You can test it with the same code. It looks like : remove_from_container "sleigh" quiet = "true"; fails and prints an inappropriate system message saying "You don't have it.", then prints my message saying that I just took it. Is there any way of testing the success or otherwise of remove_from_container and changing the default system message? What happens with remove_from_container if your inventory is full?"

image

ainslec commented 3 years ago

NOTE: Running these commands in text version of Adventuron does not replicate the issue. There appears to be a difference between the transpiled version of Adventuron's internal logic versus the pure Java version. Very worrying.

ainslec commented 3 years ago

Fixed in 66t.

ainslec commented 3 years ago

Re-opening this, also related to issue #427 (see findEntitiesForSubject() )....

  • PUT COAL ON SLEIGH
  • PUT ALL ON SLEIGH
start_at = room01

game_settings {
   enable_standard_all_behaviour = false
   experimental_auto_propogate_known = true

}

integers {
   sleigh_item_limit : integer_const "10";
}

collections {
   list_object_buffer : list;
}

traits {
   treasure_t : trait;
}

locations {
   room01 : location "You're in a barn.";
}

objects {

   sleigh : scenery "Santa's sleigh" at = "room01" container_type = "surface" {experimental_matching_text_sequences = ["santa's sleigh", "sleigh"] noun="sleigh"}
   coal : object "a lump of coal" at = "inventory" weight = "2" {experimental_matching_text_sequences = ["lump of coal", "lump", "coal"] traits = [treasure_t]noun="coal"}
}

on_pre_command {
   : match "_ _" {
      : disambiguate_s1 "present";
      : disambiguate_s2 "present";
   }
}

on_command {
   : match "put all" {
      : disambiguate_s2 "present";
      : if (s2() == "sleigh") {
         : do_all "inventory_notworn";
      }
   }
   : match "put _" {
      : disambiguate_s1 "carried" with_trait = "treasure_t";
      : disambiguate_s2 "present";

      : mask {
         : print {("^n^verb = " + original "verb")}
         : print {("^n^preposition1 = " + original "preposition1")}
         : print {("^n^noun1 = " + original "noun1")}
         : print {("^n^preposition2 = " + original "preposition2")}
         : print {("^n^noun2 = " + original "noun2")}
         : print {("^n^s1 = " + s1())}
         : print {("^n^s2 = " + s2() + "^m^")}
      }

      : if (s2() == "sleigh") {
         : if (parent_of(s1()) == "sleigh") {
            : print {(first_cap(definite(d(s1()))) + " is already on Santa's sleigh.")}
            : done;
         }
         : if (!is_carried(s1())) {
            : print {("You're not carrying any " + original "noun1" + ".")}
            : done;
         }
         : if (!s1_has_trait "treasure_t") {
            : print "You can only put the presents for the children on the sleigh.";
            : done;
         }
         : if (count(s2()) == sleigh_item_limit) {
            : print "You can't put any more items on the sleigh.";
            : done;
         }
         : if (weigh(s1()) > 6) {
            : print {(first_cap(definite(d(s1()))) + "  won't fit on the sleigh.")}
            : done;
         }
         : insert_in_container "sleigh" quiet = "true";
         : print {("You put " + definite(d(s1())) + " on Santa's sleigh.")}
         : done;
      }
   }
}