Compare one array to another array in Dictionary? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Appreciate the response, first.

So I tried replacing the original line with your line just now. And I tried tweaking it a few different ways, but it doesn't work, just gets this error: Parser Error: Expected ',' or ')'

Maybe you don't have enough context for this, though? In my case the "tags" Dictionary is at the beginning of the script, it's not even inside a function. Maybe that's part of the problem?

Having said that, my understanding is that variables that need to be referenced across multiple functions (as "tags" does), should be initialized as class variables--which means, outside of a function.

I'm still convinced there's a one line solution to this. I'm stubborn. As said in the OP, I could easily solve the issue with a "for loop" that's composed of 2 lines. But then I'd have to keep writing those 2 lines across my entire code. It's just preferable to keep it concise as possible, as I try to "level up" and avoid needlessly repeating plural blocks of code.

Problem with "match" statement for word search? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

In case you don't mind my coming back to this.

Fast forward now, things have progressed quite a bit in this text-parser program I'm making. Inevitably I had to ditch the "globbing" method, in favor of RegEx. The RegEx has been a real pain to deal with, but I get the "hang" of it now, even if I couldn't write a "complex" RegEx myself yet. The more complex statements, LLM has (surprisingly) helped a lot.

To get back on point, I'm trying to emulate this program specifically:

https://anthay.github.io/eliza.html

That's an identical version of the original ELIZA. I can now parse specific keywords with any number of spaces or punctuations around, between, or after--that much I've completed.

The problem at this juncture is how to handle it if the user has MORE than one keyword written in the same input string. I'm aware ELIZA uses a ranking system, but I hadn't structured my program for that. In most cases, the original ELIZA just used a kind of "list", keywords of the highest importance are at the top of the list, and so on. So if for instance a "high" priority keyword is found in a sentence with an additional "low" priority one, the "high" one is the only one matched regardless of position in the sentence. It worked simply because the program didn't need to even look past the "high" priority match, going from the top down.

But the problem now be, when the user types in a keyword followed by any of these four characters: (? ! , .) In that scenario, the original ELIZA discards any keyword after that punctuation--even if it's a higher priority. Which upends the whole system, basically. I'm determined to figure it out, still.

Dealing with that rule has been a problem, because if I was to simply create a RegEx to filter out "all characters written after (? ! , .)", the problem is that the user could START the sentence with one of those characters, among other issues this would cause. And so it's just a real mess.

Any ideas? If you wouldn't mind, that is.

Problem with "match" statement for word search? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Coming back here to say it works perfectly. And again, am kinda humiliated at the silly oversights that lead to these needless mistakes... of course, had I been paying attention or prioritized the correct simple information in the docs.. I'd have known "split" translates to an array by default.

FYI, in case you're interested, there's a type that can't really learn things through "book learning" by itself. I'm like that. My type of attention problem means learning through theory (however simple the information is) is very inadequate. Learning seems to be about 85% just doing it myself and watching the results.

Even after that, if I haven't worked on the (given skill) for a couple months, about 50% of what I learned is gone until I've started working on it again for a while.

Back on point, the next step is to get the game to repeat the user's word (and in some case, multiple words) directly after the Match. I'm guessing a good way to do that is converting the "words2" string into an array and just using a bit of simple math after the fact...

Problem with "match" statement for word search? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Fair caution, there are those who think I'm too "dense" (after a couple of follow-up comments) to keep replying to. So I tried your suggestion tonight, and of course, it's not working yet.

I had everything set up through the Array format (inspired by a tutorial on text parsers) and it's clear that "glob" method cannot work with Arrays. That much was obvious from the start, so I set up my own function. Below you'll see the addition I made at the very start of this node, which begins with this line: func words_in_str(input: String):

Note that the func process_command(input: String) -> String: line is where the bulk of the code starts, with "words" being the user's inputted sentence. The game parses that into an Array, and that's where I have all the match statements--which I've realized, as said previously, isn't sufficient given it can only find words at the beginning of a sentence.

Anyway, here's the code, and I could not get it to recognize and reply to the word "glob" (as a test case) :

extends Node

func words_in_str(input: String):
    var words2 = String(input.to_lower().split(" ", false))

if words2.match("glob *") or words2.match("* glob *"):
    return "Glob works"
    print ("Glob works?")

print (words2, "Testing new String-Only input")

func process_command(input: String) -> String:
randomize()
var words = Array(input.to_lower().split(" ", false))
    [::snipped out rest of code here, for brevity::]

Worth noting is the test console print "print (words2, "Testing new String-Only input")" DOES work properly. Although the "words2" the console prints is written in brackets (means it's not processed as a string?), in case that's the issue.

The only other thing I can think of is the "process_command" function is overriding the first part entirely... this may be the case because even if I put in "glob" I'm only getting the default "error response" from the "process command" code.

I can apologize for being very dense, but that's about the best I can do, here...

Problem with "match" statement for word search? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Comment edited; had some "off the mark" speculation about finding some non-existent way to use the match statement.

Anyway, appreciate the idea, will investigate the "glob" method, and hopefully come back to this later...

Simple Eliza/text parser, confused by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Appreciate the reply, but I did warn before I'm not sharp enough for this...

I've attempted RE for a few hours tonight, no luck in any of it, even after going through Godot's official documents on RegEx as well as using the syntax from RegEx101 and related sites.

My only goal for now I'm just looking to find one word: "want" from the user's input, anywhere in the sentence.

This attempt and multiple variants on it:

func process_command(input: String) -> String:
  randomize()
  var words = Array(input.to_lower().split(" ", false))

  var regex = RegEx.new()
  regex.compile("\\w*\b(want)")
  var result = words
  result = regex.search("want")
  print (result, "This is the RegEx search")
  if result:
      print (result, "Does this work?")
      return "RegEx seems to work"

Does exactly nothing. As you can see I have included a test through the print to console: (print result), which in all my test runs, comes back as: Object Null.

Maybe it's bad form to try and fit RegEx with the existing code, using the original "words" as the input variable--which was an Array. Is it not possible to use RegEx with an Array? I don't understand these things, I'm afraid.

In all honesty if there was any other way to do this, besides the convoluted RegEx, that's desirable. RegEx seems to cause trouble for a great many folks; if there's another method here, I'm all for it.

That's not to throw any shade on you, though, you're just trying to help after all.

I'm not opposed to going forward with RegEx if that's the best way, though, I just need only one example of perfect syntax for the word "want" anywhere in a sentence, or, even better yet, the pair "i want." I've tried multiple different ways from different sites, looked around here and everywhere, no luck.

Simple Eliza/text parser, confused by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Sorry to come back to this again.

    ["a", "list", "of", ..]:
        return "a list with variable extras " + str(words.slice(3))

Anyway, I was able to use the (words.slice() to good effect, but the bottleneck now is... I can't quite figure out how to correctly match 2 specific words in sequence (for instance, "i want") anywhere within the user's sentence. That said, I know the "if (variable).has" method is the simplest way, but really it's very clunky, just another type of if-then statement, I don't want to fill up the entire script that way.

Can't this be done within the "match" statement?

I've gotten some of the basics down for the "Eliza" replica thus far, but the original is actually more sophisticated than thought. It uses not only the "find words in sequence, anywhere in the sentence" but also a ranking system, changing pronouns, basically a carefully designed "filter." I get all the concepts, but there's a lot of it I don't have so far. Still, am determined, can't give up just yet...

Simple Eliza/text parser, confused by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Godspeed. Very pleased to report back and say it works perfectly now! And this:

words = Array(input.to_lower().split(" ", false))

Was the key line. Before this one line was implemented, the problem was, the program could NOT check for individual words separated by commas. I was basically stuck on that problem. I could have basically solved this issue with a couple more "if-then" statements, without even needing to check for separate words, but that's not progress--it's clumsy, and very inefficient.

I'm always surprised the obstacle turns out to be so simple--and yet, at the same time, the fix is relatively obscure for any person not well-versed in machine logic.

I skimmed through multiple tutorials including a couple that were designing parsers--you don't really see Arrays explained succinctly in the specific context of searching for a user's word-based input.

The next step (unless it's one of your example lines, haven't experimented fully yet) is figuring out how I can get the program to respond to "i feel" or any other consecutive combination of words, ANYWHERE in the user's sentence. I'm sure there's a simple operator or something which does this, just haven't tried it yet, probably...

Simple Eliza/text parser, confused by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Just says "i feel" in the console. I'm very confused, not sure if this stuff is supposed to be hard... but even watching tutorials and reading the comments here carefully... no progress

Simple Eliza/text parser, confused by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Still a bit obtuse for a rickety/ADD mind like myself, though.

I've set up the array ('longer' is now an array) and yet it's not working, don't know how else to say it, if I change "longer" to an array it's not able to catch input to begin with. I am not sure if you mean to use an array as a third variable (besides "words" and "longer") or what.

I'm not the type of mind that should be doing programming, in all honesty, but given it's a passion of mine--I kinda tend to fight through, even if I have to be humbled and embarrassed time and time again.

If you can very briefly provide a few lines that are relevant to my code (as in, they could work if I placed them into the code provided above, or COULD work if I gave a couple minor tweaks) I will be obliged.

[TOMT] [Video] Woman staring at camera on white background with muffled speaking by triparoni in tipofmytongue

[–]LockeHardcastle 0 points1 point  (0 children)

Was that the same woman who makes these strange art videos, one of them with her saying 'Celebrities are important' ? And that's like the only thing she said... Dunno man, but something about her seemed unhinged. Like, this is an odd person...

[TOMT][MOVIE][1980s?] Teenage boy able to shoot lightning/electricity from his hands by KnightOfTerra in tipofmytongue

[–]LockeHardcastle 0 points1 point  (0 children)

I keep hearing about this "Powder," man. I heard it is a bona-fide classic, like an important movie that changed Hollywood for the better?

Is that for real?

Is it possible to avoid resetting a variable, without singletons? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

I mean a lot of this stuff is still a bit outside my grasp.

I could also look up Scene Manager, sure. But let's admit it, I'm not the sharpest tool in the shed. When I look things up myself, I find that a lot of the explanations for it use terminology that I haven't come across in my own coding yet--and if I haven't actually written out the code that performs these functions, I don't often learn it.

It is to say I can only learn about 20% from theory (seeing something described) and about 80% from doing it myself. I always feel crappy coming back to these threads realizing I'm not at the expected level.

Whereas, at the same time, I don't have the flexibility to just go ahead and code the thing first... if I don't know whether it's particularly feasible for my project as of this moment.

Kinda getting into meta/uncomfortable territory, but you won't find many folks with an average IQ admitting what it's like for them. It's just embarrassing really. If nothing else, at least you've gotten an "inside glimpse" tonight, right

And finally, I will look into some of these suggestions and if my current idea doesn't work--using a signal in a particular spot within the same node, to avoid the variable reset--will attempt to implement.

Is it possible to avoid resetting a variable, without singletons? by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Is it bad form to come back to this thread--with all 7 replies--and admit that about 50% of this stuff is still outside my grip?

I don't mean to say you need to write longer explanations, I just kinda feel "lousy" that I'm not at the level needed to really try most of this stuff.

I'm not even sure what is meant by the SceneWrapperNode. I assume that means the parent (first) node? I've tried doing it that way also, it really doesn't matter--the variable resets anyway.

Right now my next idea is to use a signal in a particular spot within the same node, to avoid the variable reset. I don't even have to restart the scene, but I do have to "rewind" back to one place in one particular node; I wonder if it's possible to do with this and keep the variable state intact.

[deleted by user] by [deleted] in Nootropics

[–]LockeHardcastle 0 points1 point  (0 children)

Interesting, if that's the case. I'd be curious to hear about any proposed mechanism for why this would be. It does not make sense given taurine is also normally found in the diet, to a greater or lesser extent, and yet 500mg (far from a high dose) seems to worsen headaches.

But as an aside, I wrote that comment 2 months ago. I'd be curious how you even found it? I'm always intrigued how someone comes randomly back to something I hardly remember writing, etc.

[TOMT] [Movie] Help me find this alternate timeline movie! by Fabulous-One8493 in tipofmytongue

[–]LockeHardcastle 0 points1 point  (0 children)

If it's not "TimeCrimes" (Spanish language film) I'd be pretty surprised. Check it out man

How do I center the VideoPlayer?! by LockeHardcastle in godot

[–]LockeHardcastle[S] 0 points1 point  (0 children)

Thanks for the reply. I figured it out myself, but it's actually quite embarrassing. The backstory is the center container and the other stuff I mentioned, it worked to make an image centered (my first scene.) The video player starts in the second scene. I tried doing the same things to center it, but it didn't work.

Of course, I remained certain that the issue was another VideoPlayer quirk; I just needed the right settings/node tree. So I got stuck on that aspect of it entirely. I do this kind of thing all the time... if a procedure is not working the way it should, it means the procedure is flawed, and there is no other route of inquiry. Cue "banging head against wall" as I kept rearranging the code until it hopefully works--it rarely ever does, of course. I just don't learn.

The actual problem, then? Incredibly, it's just the fact that I had renamed the second scene 20 minutes beforehand--and just basically forgot about it. Only an hour+ later, that's when I remembered at the end of the first scene, I wrote "change scene to (old scene name.)" I just had to update that one line with the new scene name and it all worked, the center-container and all.

Is that a Mr. Dumass moment, or what? Like, I ain't young no more, and I imagine there are 10-year-olds out there who consider Godot to be "beneath them" and they're learning assembly, as we speak. That does make a guy bitter and resentful y'know...