mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
I am going to try to undertake the task of creating a gaming bot that spits out a 1 or 2 word sentence, and you can find words within those words and itll give you a point for each word you find.

I already have a list of almost every word in the english language that I am going to use for checking words.

However, the major task that I do not know how to do is make it see the words the person types and check it with its words it spit out.

Say for example it spits out the word Chocolate.

How would I make it see that the word "Coco" can be made from the word "Chocolate"?

Or say the word "Locate" can be made from the word "Chocolate".

I appreciate your help!

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
alias locate { 
  var %string $1, %locate = $2, %i = 1, %found
  while $mid(%string,%i,1) {
    if $count(%locate,$mid(%string,%i,1)) { inc %found }
    inc %i
  }
  return $iif(%found != $len(%string),0,1)
}

//echo -a $locate(coco,chocolate) - returns 1 because coco was found in chocolate

edit: someone else can probably think of a better way of doing it.

Last edited by tidy_trax; 23/02/04 09:09 PM.

New username: hixxy
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
what about the word locate in chocolate? would that also work for letters that are not "in order"?

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
yes, the only problem is.. it will also work for: $locate(oooo,chocolate)


New username: hixxy
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
hmm see that wont work shocked

its got to be real words lol.

any other ideas guys? cause i have no idea what-so-ever on how to do this.

just to make sure its clear what i am trying to accomplish (since its pretty confusing lol)

I will have a large words.dat file that is going to contain almost all of the words in the english language (found it on sourceforge.net), and the bot is going to spit out say, the word "chocolate" and users can then form words out of that word, and for every real word they form they will get a point.

Example:

<WordBot> Chocolate
<user1> Locate
<user2> Coco
<user3> tale


etc etc.

How would I go about having the bot check to see if the word "tale" "coco" and "locate" are real words that can be made out of the word "Chocolate"?

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
This should work:
Code:
contains {
  ; $contains(&lt;haystack&gt;, &lt;needle&gt;)
  var %needle = $2, %char
  while $left(%needle, 1) != $null {
    %char = $ifmatch
    if ($count(%needle, %char) &gt; $count($1, %char)) return
    %needle = $remove(%needle, %char)
  }
  return $true
}

eg.
$contains(chocolate, locate) = $true
$contains(chocolate, ooo) = $null
$contains(chocolate, Locate) = $true


Edit: This is only to check one word is within another word. To make an alias which checks within the file would require knowing the format it uses to store words.

Last edited by starbucks_mafia; 23/02/04 11:26 PM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
yeah, the format of the file that the words are in is just like this:


a
as
apple
astronaut

etc etc


and thanks guys, i will try it out in a bit when my headache goes away!

Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
i am trying to make sence of the code u wrote, but its just confusing the heck out of me because I cannot see where some of these variable are being set etc.

can you please go over each step so that I can correctly put that code into the bot and mold it the way i need? (IE place it correctly into on-text event's etc.)

thank you so much!

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
you dont need to add that to the on text, its a standalone identifier alias, you just uses it in the on text

on text {
blah blah
if ($contains(%masterword, %word.in.it) == $true) {
; found a possable word in the master word
; now to check if thats a real word from that file ya got
}

Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
ahhh ok.

i did not know aliases could be used like that

i thought they could only be used as /aliasname to make 'em work :P

what about this:

var %needle = $2, %char

where is the $2 coming from?
and why is there a , %char? I've never seen a variable being set with a , and then another empty variable after it. Can you explain that part to me too?

Thanks so much!

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
var %needle = $2, %char
  "where is the $2 coming from?"
$contains(<haystack>, <needle>)
  ^^ <haystack> is $1 and <needle> is $2

"var %needle = $2, %char"
^^ this sets two local variables, %needle and %char.
  %char is empty at this point

From [/b]/help /var[/b]
You can create multiple local variables by separating them with commas:
/var %x = hello, %y, %z = $me

Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
ah ok, thank you smile

i will try to see if i can get all this to work tommorow smile


Link Copied to Clipboard