Author Topic: Spreadsheet approach to using variables  (Read 2193 times)

Mike308

  • Newbie
  • *
  • Posts: 48
Spreadsheet approach to using variables
« on: December 01, 2017, 12:48:56 PM »
Hey VA!

I am trying to simulate the human ability to answer generic questions in the context of a conversation, and I’ve found a lot of guidance on this forum already. The start seems straightforward by declaring a variable called “Topic”

“What can you tell me about a Camaro?” would do two things: prompt a basic TTS reply and then set “Topic” to ‘Camaro’ (or some corresponding numeric value)

Subsequent generic questions like “How fast is it?” or “What does it cost?” would be answered based on whatever Topic was currently set, i.e. Camaro, Mustang, and so forth.

But if I apply this to Star Citizen and some fifty or sixty different ship types, I need to create and update each of the Generic Question code blocks to include all of the possible ships; i.e. “How Fast” needs a series of If statements “If Camaro, If Mustang…”, a list that has to be repeated in “How Expensive” along with every other Generic Question.

What I’d like to do (and forgive me for describing this visually rather than in proper coding terms) is have each Generic Question carry its own Identifier Code  (GQIC). Then my logic tells me I could use the current Topic and GQIC values like “row and column” coordinates in a spreadsheet to pluck out the proper response. That way I would only have to create the full matrix of answers one time.

Topic ——>         Camaro      Mustang      Firebird
How Fast            100mph      110mph      120mph
How Expensive         $10         $15         $20
How Much Weight      1000lb      1200lb      1400lb

The nice aspect is the human-like ability to come back to a topic if otherwise interrupted. “What were we talking about?” would respond like any other GQ with something like “We were talking about Camaros.” I like the human feel of that. I just don't know if VA is set up to accommodate something like this.  If there is a term for this kinda thing I can start doing my homework.

Thanks all!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Spreadsheet approach to using variables
« Reply #1 on: December 01, 2017, 03:03:22 PM »
Given the options available within VoiceAttack, I'd load all the data for a given topic into variables, and read from those.

E.G.
What can you tell me about a [Camaro;Mustang;Firebird]
Code: [Select]
Begin Text Compare : [{CMDSEGMENT:1}] Does Not Equal [Topic]
    Set Text [Topic] to '{CMDSEGMENT:1}'
    Write '[Blue] What would you like to know?' to log
    Begin Text Compare : [{CMDSEGMENT:1}] Equals 'Camaro'
        Set integer [maxSpeed] value to 100
        Set integer [price] value to 10
        Set integer [weight] value to 1000
    End Condition - Exit when condition met
    Begin Text Compare : [{CMDSEGMENT:1}] Equals 'Mustang'
        Set integer [maxSpeed] value to 110
        Set integer [price] value to 15
        Set integer [weight] value to 1200
    End Condition - Exit when condition met
    Begin Text Compare : [{CMDSEGMENT:1}] Equals 'Firebird'
        Set integer [maxSpeed] value to 120
        Set integer [price] value to 20
        Set integer [weight] value to 1400
    End Condition - Exit when condition met
Else
    Write '[Blue] Already on this topic' to log
End Condition

How fast is it
Code: [Select]
Write '[Blue] {INT:maxSpeed}mph' to log

What does it cost
Code: [Select]
Write '[Blue] {INT:price}$' to log

Mike308

  • Newbie
  • *
  • Posts: 48
Re: Spreadsheet approach to using variables
« Reply #2 on: December 01, 2017, 03:45:12 PM »
aaaahhhh, brilliant! It took me about four read-throughs to grasp what you were doing but the lightbulb came on. With eyes open it strikes me that you are playing the Control Flow game you talked about in the sticky at the beginning of this section. So at the point that I choose a topic, I am pre-loading all of the variable boxes so subsequent questions will just plug-n-play. instead of having to fish for data when the next question comes.

VA is my gateway into anything close to programming. It is providing some good lessons on how to 'think like the machine' and be efficient. Thanks for the continued help!!