AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   [Help] MegaHAL chatter bot into amxx module. (https://forums.alliedmods.net/showthread.php?t=312015)

metal_upa 11-12-2018 12:00

[Help] MegaHAL chatter bot into amxx module.
 
1 Attachment(s)
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.

Arkshine 11-16-2018 06:36

Re: [Help] MegaHAL chatter bot into amxx module.
 
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.

metal_upa 11-18-2018 03:36

Re: [Help] MegaHAL chatter bot into amxx module.
 
Quote:

Originally Posted by Arkshine (Post 2624265)
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.


All times are GMT -4. The time now is 04:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.