Forum

Please note that you can subscribe to the individual forums. A subscription for news only covers the news.

Notifications
Clear all

Toilet permission based on questions

5 Posts
2 Users
0 Likes
1,087 Views
 asub
(@asub)
Member
Joined: 5 years ago
Posts: 50
Topic starter  

Just to share with community, here's the code I've made to make decision if sub can use toilet or not based on several factors:

  1. How much time has passed since the last toilet use.
  2. How much sub wants to go to the toilet
  3. A bit random factor.

Before permission is calculated sub is asked several questions. Time since the last toilet permission participates too. Based on those factors probability of permission is calculated and then a random number decides the fate πŸ™‚

However, if sub has not used toilet for a long time, or it's an urge, the probability can be over 100%, that will guarantee the permission.

Hope it will inspire or help someone here!

[permission-Go to the toilet]
   PreStatus=free
   BeforeProcedure=procBeforeToilet

   NewStatus=toilet
   instructions=usetoiletAll
   EndText=Finished toilet
   
   ; code to do if permission was granted
   add#=#dailyToiletUsed,1
   set!=!lastToiletUsageTime,!zzNow


[procedure-procBeforeToilet]
	; drop flags
	removeFlag=zzPermit
	removeFlag=zzDeny
	removeFlag=zzCancel
	removeFlag=useToiletPoo
	removeFlag=useToiletPee
	
	; set default maximum time in toilet
	set!=!maxToiletTime,00:10:00
	; init probabiity
	set#=#toiletProbability,0
	
	; calculate amount of probability
	
	; probability on time passed from the last toilet use
	set!=!timePassed,!zzNow
	subtract!=!timePassed,!lastToiletUsageTime
	minutes#=#timePassedMinutes,!timePassed

	; this means for every 60 minutes we give 20 point of probability
	divide#=#timePassedMinutes,3
	; multiply#=#timePassedMinutes,5

	add#=#toiletProbability,#timePassedMinutes
	
	; ask sub some questions to change probability
	question=questionToiletPeeOrPoo
	question=questionToiletUrge
	
	
	; calculate final answer
	random#=#randomValue,100
	Case=First
		When=#randomValue>#toiletProbability
			setFlag=zzDeny
		When=None
			setFlag=zzPermit
	Case=End
	
	; debug message, just in case!
	Message=Toilet probability is {#toiletProbability}
	


[question-questionToiletPeeOrPoo]
	phrase=What are you going?
	?Pee=*
		removeFlag=useToiletPoo
		setFlag=useToiletPee
		set!=!maxToiletTime,00:06:00
	?Poo=*
		removeFlag=useToiletPee
		setFlag=useToiletPoo
		set!=!maxToiletTime,00:15:00


[question-questionToiletUrge]
	phrase=What is the reason?
	?Common need=*
		add#=#toiletProbability,10
	?I want it realy=*
		add#=#toiletProbability,55
	?It's before leaving=*
		add#=#toiletProbability,80
	?I feel seek=*
		add#=#toiletProbability,100

Β 

P.S.: I have additional some reports for toilet use outside (not at home), it just asks the approximate time of use and sets theΒ  !lastToiletUsageTime to that time.

Β 

P.P.S.: I'll be glad to answer if you have any questions or ideas how to improve this code.


   
Quote
(@sven_b)
Member Admin
Joined: 3 weeks ago
Posts: 456
 

Thank you for sharing this. It looks good.

Just a few comments:

It is not necessary to remove the flags zzPermit, zzDeny and zzCancel. They are automatically removed before the procedure is called. But it doesn't hurt either.

As for your debugging message, if you don't want to show the message, you can use WriteReport instead of Message. Then you will have the number in the report, and the sub will not be disturbed.

Once again, thanks for sharing.

Sven

Β 


   
ReplyQuote
 asub
(@asub)
Member
Joined: 5 years ago
Posts: 50
Topic starter  

@admin: Thanks for comments.

I just wanted to add, that when I was setting zzAllow (not zzPermit), I had to set Pct=100 to give permission. It means that permission procedure has got none of service flags and used common way to decide. And it leads to such commands like: Delay, MaxWait, MinInterval, etc. affect the answer. This can also be very useful.

I even think to return to this variant to use Delay. To stop sub asking quickly for permission again and again. It can be programmed in BeforeProcedure, but why should I, if I it is already programmed?! πŸ™‚


   
ReplyQuote
(@sven_b)
Member Admin
Joined: 3 weeks ago
Posts: 456
 

@asub: The built in commands can give a great variety. Personally, I only use zzPermit or zzDeny for special purposes.

When asking a question, as you do here, I often add "I asked by mistake". And if that is chosen, set the zzCancel flag. Because we all know it is possible to choose the wrong entry in a menu. 😉Β 

Sven


   
ReplyQuote
 asub
(@asub)
Member
Joined: 5 years ago
Posts: 50
Topic starter  
Posted by: @admin

When asking a question, as you do here, I often add "I asked by mistake". And if that is chosen, set the zzCancel flag. Because we all know it is possible to choose the wrong entry in a menu.

Oh, yeah! πŸ™‚ I think i need some kind of this variant for nearly all lines of the menu. Especially for reports of something valuable.


   
ReplyQuote