Natural Language Bondage Code for Use with Hardware

Selfbondage software and other kinky developments

Moderators: Riddle, Shannon SteelSlave

Post Reply
zappy1
*
Posts: 31
Joined: 28 Dec 2019, 06:37

Natural Language Bondage Code for Use with Hardware

Post by zappy1 »

I wrote some code in Python as an example of how natural language can be used in bondage games. Routines can be used in any language. It uses a random generator and keywords.

The keywords can be used for output from any input. It would allow for full natural sentences from speech to text. I used keywords such as "not" and "never." If the keyword is in the sentence, it can respond. The random generator combined with concatenation means the output will not be the same all the time. I called the variable "end" to be used at the end of sentences. Just put "+ end" at the end of any sentence and it will be impossible to predict the output. For a full fledged program it is easy to come up with lots of ending to choose from.

Another tricks to be more natural is to have verbal output after a certain amount of time if the user does not respond. This would be random also. Output could be text to speech.

The idea of this is to call other routines such as with the BJ trainer or motion detector. Such as "If user moves, print 'stop moving.'" It can also to be connected to talking animation.

Use this compiler to test, just copy and paste.
https://www.onlinegdb.com/online_python_compiler
# Sentence ending variations
import random
randending = random.randint(1, 4)


if randending == (1):
end = ', damn it!'

if randending == (2):
end = ', now!'

if randending == (3):
end = (', or else!')

if randending == (4):
end = (', or you will get it bad')



response = str(input("Tell me that you want it: "))

responselow=response.lower() # Make lower case to find keyword easier

# keyword find
matches = ["no", "not", "never", "won't"] # keywords

if any(x in responselow for x in matches):
print ("I said do it" + (end))
else:
print("Then do it")
User avatar
kinbaku
*****
Posts: 5052
Joined: 10 Jan 2020, 20:26
Location: Belgium

Re: Natural Language Bondage Code for Use with Hardware

Post by kinbaku »

Thank you for the code, zappy1.
You can use in the module random the function choice. It is easier to add new sentences later. I also used a \ so that you can see how you can split the string in the middle of a sentence.
If you only use "no" and "not", the sentences "Now, I want to do crossdressing" and "I will make strong knots in my bondage" can give wrong answers.
I have also provided a minimum answer length of 4 characters to avoid the answer "no" for example. I haven't found a solution for "no" + "\r" (Return key=chr(13)). Maybe there are others who can provide the solution for this?

Code: Select all

# Sentence ending variations
from random import choice
end = [ ', damn it!', ', now!', ', or else!',', or you will \
get it bad']

response = str(input("Tell me that you want it: "))
while len(response)<5:
    response = str(input("Give a longer answer (more than 4 characters): "))

responselow=response.lower() # Make lower case to find keyword easier

# keyword find
matches = ["no ", "no,", " not ", " not,", "not!", "never", "won't"] # keywords

if any(x in responselow for x in matches):
    print ("I said do it" + choice(end))
else:
    print("Then do it")
zappy1
*
Posts: 31
Joined: 28 Dec 2019, 06:37

Re: Natural Language Bondage Code for Use with Hardware

Post by zappy1 »

kinbaku wrote:Thank you for the code, zappy1.
You can use in the module random the function choice.
Thanks for the suggestions. Below is an improved version that I did. I am trying to do it within a function that I can call from anywhere, but the function won't work. I also tried loops to get the input to return after a response, but that did not work either.

If anyone wants to try it out, paste it here https://www.programiz.com/python-progra ... -compiler/
# Sentence ending variations
from random import choice

end = [ ', damn it!', ', now!', ', or else!',', or you will get it bad']

response = str(input("Tell me that you want it: "))
while len(response)<3:
response = str(input("Give a longer answer (more than 3 characters): "))

responselow=response.lower() # Make lower case to find keyword easier

# keyword find
negatives = ["no ", "no,", " not ", " not,", "not!", "never", "won't"] # keywords
positives = ["yes", "ok", "o.k.", "yeah"]
maybes = ["maybe", "perhaps", "possibly"]

if any(x in responselow for x in negatives):
print ("I said do it" + choice(end))

if any(x in responselow for x in positives):
print ("Then do it" + choice(end))

if any(x in responselow for x in maybes):
print ("Answer yes or no" + choice(end))

else:
print("Give me and answer" + choice(end))
User avatar
kinbaku
*****
Posts: 5052
Joined: 10 Jan 2020, 20:26
Location: Belgium

Re: Natural Language Bondage Code for Use with Hardware

Post by kinbaku »

You must use elif instead of if. I have also added two functions to show you how to use them.
(If you use the button <Code> around your code in your post, then the correct spaces - as required by Python - are visible)

Code: Select all

# Sentence ending variations

# import the function choice from the module random
from random import choice

# Sentence endings
end = [ ', damn it!', ', now!', ', or else!',', or you will get it bad']


#FUNCTIONS
# function for YES or NO answer
def yesNo(demand):
    while True:                                                     # when users answer is not started with y(es)/n(o) this function repeat
        ynAnswer = input(demand + " (y/n): ")
        if len(ynAnswer)>0 and ynAnswer[0].lower() in ('y', 'n'):
            return ynAnswer[0].lower() == 'y'             # True when 'y', and False when 'n'


# function that ask the question "questionString" and returns the Answer "response"
def Answer(questionString):
    response = str(input(questionString))
    while len(response)<3:
        response = str(input("Give a longer answer (more than 3 characters): "))

    responselow=response.lower() # Make lower case to find keyword easier

    # keyword find
    negatives = ["no ", "no,", " not ", " not,", "not!", "never", "won't"] # keywords
    positives = ["yes", "ok", "o.k.", "yeah"]
    maybes = ["maybe", "perhaps", "possibly"]
    if any(x in responselow for x in negatives):
        print ("I said do it" + choice(end))

    elif any(x in responselow for x in positives):
        print ("Then do it" + choice(end))

    elif any(x in responselow for x in maybes):

# change the     print ("Answer yes or no" + choice(end))      in a function; thus a function in a function!
        if yesNo("Answer yes or no"):                      # calling the function yesNo
            print("Do it" + choice(end))                    # user answer was YES (function yesNo returns True)
        else:
            print("You must" + choice(end))              # user answer was NO (function yesNo returns False)
    else:
        print("I don't understand what you mean by \"{}\", so you have no business here.".format(response))  # user has no negatives, positives or maybes

    return(response)


# MAIN PROGRAM
# calling the function Answer
question = "Tell me that you want it: "
userResponse = Answer(question)                     # the variable "question" is given to the parameter "questionString" from the function Answer,
                                                                      # and the function returns the variable "response" which is put in the variable "userResponse"
print("Users response was: {}".format(userResponse)) #This just to show. Normally you can continue working with your program with the user's answer. Like
                                                                      # calling the function again: userResponce = Answer("Do you want to tie your ankles? ")
Post Reply