Results 1 to 3 of 3

Thread: Perl programming in sdba (http://duncanlamb.com/sdba/)

  1. #1
    JRaz is offline Just Give Me the Beans!
    Join Date
    Aug 2006
    Beans
    45
    Distro
    Edgy Eft Testing

    Perl programming in sdba (http://duncanlamb.com/sdba/)

    I'm not sure if this is more of a perl or sdba question so bare with me. Basically I'm attempting to write a msn bot in sdba (http://duncanlamb.com/sdba/). Sdba allows you to write pages in perl as if the msn chat was a web server and each response was like a web page.

    Anyway the bot I am making is a hangman game which will generate a random word from a database and then present the game to the user, the user will then send a message containing a character until he/she dies or correctly guesses the word.

    The problem is however that the variables are global to all users, so Player A would initiate a conversation and a game. Then Player B decides to start a game too, however he would end up getting Player A's game and progress since he would be using his variables.

    I initially thought of making every non-array variable an array and every array a 2d array with the users email address as the index, however while I cant think of why it wouldn't work I had trouble implementing such a method.

    Anyway I've rambled for long enough so ill just post my code bellow and if anyone can think of a way to implement the index method i talked about or possibly a better method I'm all ears. Thanks in advance.

    Code:
    #HEAD:play
    <%
    if(!$word){
     $word='hangman';
     @char=split(//,$word);
    }
    
    #reduce msg to 1 char lower case
    $msg=lc substr($INCOMINGMSG,0,1);
    
    #if alpabetic then add to guesses
    if($msg=~/[a-z]/){
     #clear msg if its a repeat
     for($a=0;$a<@guess;$a++){
      if($msg eq $guess[$a]){
       $msg='';
      }
     }
    
     #if msg nt clear then add it to array
     if($msg){
     # push(@guess,$msg);
       $guess[$a]=$msg;
     }
    }
    
    imecho "@guess\n\n";
    
    for($a=0;$a<@char;$a++){
     $letter='_';
     for($b=0;$b<@guess;$b++){
      if($char[$a] eq $guess[$b]){
       $letter=$char[$a];
      }
     }
     imecho $letter;
    }
    
    $NEXTPAGE='game.first';
    %>

  2. #2
    JRaz is offline Just Give Me the Beans!
    Join Date
    Aug 2006
    Beans
    45
    Distro
    Edgy Eft Testing

    Re: Perl programming in sdba (http://duncanlamb.com/sdba/)

    Well I managed to figure out that problem and am almost done I'm my implementation of hangman, I just have one hurdle left. I need to generate a random word from a large a dictionary as possible.

    So I have two choices, ideally I would like to be able to generate a random word form aspell or less ideally does anyone know a good word list I can dumb into a mysql table and just read off a random row.

    Any help would be appreciated, many thanks.

    PS If anyone is interested I am happy to post the code, but be warned it aint pretty lol

  3. #3
    JRaz is offline Just Give Me the Beans!
    Join Date
    Aug 2006
    Beans
    45
    Distro
    Edgy Eft Testing

    Re: Perl programming in sdba (http://duncanlamb.com/sdba/)

    Well the bot is pretty much up and running, if anyone would like to add it the address is hangraz@hotmail.com and he runs on the MSN network.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •