Raised This Month: $13 Target: $400
 3% 

[Help] MegaHAL chatter bot into amxx module.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
metal_upa
Member
Join Date: Jun 2016
Old 11-12-2018 , 12:00   [Help] MegaHAL chatter bot into amxx module.
Reply With Quote #1

Hi, i tried to convert this SM extension into amxx module but my cpp skill are not so good. I just copy and paste a fun module as basis.

At this moment module compiled and can be run on windows server, but this chatter bot make hlds micro stutter about 0.2~0.3 second each time bot do reply function.

My problem:
Spoiler


What cause micro stutter issue:
Spoiler


Module sources, MegaHAL files, .sma attached.
Attached Files
File Type: zip MegaHAL.AmxModX.zip (238.2 KB, 49 views)
metal_upa is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-16-2018 , 06:36   Re: [Help] MegaHAL chatter bot into amxx module.
Reply With Quote #2

PHP Code:
    /*
     *        Loop for the specified waiting period, generating and evaluating
     *        replies
     */
    
max_surprise=(float)-1.0;
    
count=0;
    
basetime=time(NULL);
/*     progress("Generating reply", 0, 1);  */
    
do {
    
replywords=reply(modelkeywords);
    
surprise=evaluate_reply(modelkeywordsreplywords);
    ++
count;
    if((
surprise>max_surprise)&&(dissimilar(wordsreplywords)==TRUE)) {
        
max_surprise=surprise;
        
output=make_output(replywords);
    }
/*      progress(NULL, (time(NULL)-basetime),timeout); */
    
} while((time(NULL)-basetime)<timeout); 

"Loop for the specified waiting period"

That's the issue. It seems it forces the loop to run until 1 second elapsed to simulated a waiting time?
You can't do that in HLDS, it's single-threaded, it's going to block everything else.
Remove the do/while, and if you need the waiting, use a task system.
__________________
Arkshine is offline
metal_upa
Member
Join Date: Jun 2016
Old 11-18-2018 , 03:36   Re: [Help] MegaHAL chatter bot into amxx module.
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
PHP Code:
    /*
     *        Loop for the specified waiting period, generating and evaluating
     *        replies
     */
    
max_surprise=(float)-1.0;
    
count=0;
    
basetime=time(NULL);
/*     progress("Generating reply", 0, 1);  */
    
do {
    
replywords=reply(modelkeywords);
    
surprise=evaluate_reply(modelkeywordsreplywords);
    ++
count;
    if((
surprise>max_surprise)&&(dissimilar(wordsreplywords)==TRUE)) {
        
max_surprise=surprise;
        
output=make_output(replywords);
    }
/*      progress(NULL, (time(NULL)-basetime),timeout); */
    
} while((time(NULL)-basetime)<timeout); 

"Loop for the specified waiting period"

That's the issue. It seems it forces the loop to run until 1 second elapsed to simulated a waiting time?
You can't do that in HLDS, it's single-threaded, it's going to block everything else.
Remove the do/while, and if you need the waiting, use a task system.
I see, thanks for your help, i've removed this do/while and it works.
metal_upa is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:32.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode