# Artificial intelligence (AI)

Of course calling dll's or other files is probably a necessity but I was curious to see what we as a community could do in ahk. I don't think it needs to be anything to spectacular, I also don't think it has to be able to change its own programming, but I think it would be cool if it could "learn" and remember new things, such as recognize a persons name or other data it had been previously given.

I would like to hear anyones comments and suggestions and hopefully, we can make something work

(='.'=) Copy and paste Bunny onto your signature.

(")_(") Help Bunny gain World Domination.

**AutoHotkey state, the forum, Poly, and Drainx1. The short story.**

**I love my wife, my life, my atomic-match; for giving me the greatest gift a man could ask for, such a perfect and beautiful little girl.**

... but if you must, there are a few so-called 'strategies' for developing AI. One is to cram as much information into a system as possible, and hope that it spontaneously becomes sentient (e.g: skynet).

Another is to design an evolving genetic process. Create a program that can rewrite itself, however clumsily, and set up a testing environment in which only the most intelligent programs can survive. Add a bunch of CG effects and turn it into a movie (a-la Tron) and make million$.

Or you can assemble a crack team of programmers and data theorists to build an AI, then take all of the credit for it.

... good luck 8-)

Like I said, just suggestions, I am curious to see what everyone comes up with.

(='.'=) Copy and paste Bunny onto your signature.

(")_(") Help Bunny gain World Domination.

And I quit, with this:

Input := "Yo, whatz one plus four added by three, i cant find the answer!" OrigInput := Input StringReplace, Input, Input,zero,0,1 StringReplace, Input, Input,one,1,1 StringReplace, Input, Input,two,2,1 StringReplace, Input, Input,three,3,1 StringReplace, Input, Input,four,4,1 StringReplace, Input, Input,five,5,1 StringReplace, Input, Input,six,6,1 StringReplace, Input, Input,seven,7,1 StringReplace, Input, Input,eight,8,1 StringReplace, Input, Input,nine,9,1 StringReplace, Input, Input,ten,10,1 StringReplace, Input, Input,eleven,11,1 StringReplace, Input, Input,twelve,12,1 StringReplace, Input, Input,added by,+,1 StringReplace, Input, Input,added,+,1 StringReplace, Input, Input,add,+,1 StringReplace, Input, Input,plus,+,1 StringReplace, Input, Input,subtracted by,-,1 StringReplace, Input, Input,subtracted,-,1 StringReplace, Input, Input,subtract,-,1 StringReplace, Input, Input,minus,-,1 StringReplace, Input, Input,multiplied by,*,1 StringReplace, Input, Input,multiplied,*,1 StringReplace, Input, Input,multiply,*,1 StringReplace, Input, Input,times,*,1 StringReplace, Input, Input,divided by,/,1 StringReplace, Input, Input,divided,/,1 StringReplace, Input, Input,divide,/,1 Loop, % StrLen(Input) { If(InStr("0123456789+-/* ",SubStr(Input,A_Index,1))) Expression .= SubStr(Input,A_Index,1) } Output := Eval(Expression) MsgBox, %Output% Eval(x) { ; non-recursive PRE/POST PROCESSING: I/O forms, numbers, ops, ";" Local FORM, FormF, FormI, i, W, y, y1, y2, y3, y4 FormI := A_FormatInteger, FormF := A_FormatFloat SetFormat Integer, D ; decimal intermediate results! RegExMatch(x, "\$(b|h|x|)(\d*[eEgG]?)", y) FORM := y1, W := y2 ; HeX, Bin, .{digits} output format SetFormat FLOAT, 0.16e ; Full intermediate float precision StringReplace x, x, %y% ; remove $.. Loop If RegExMatch(x, "i)(.*)(0x[a-f\d]*)(.*)", y) x := y1 . y2+0 . y3 ; convert hex numbers to decimal Else Break Loop If RegExMatch(x, "(.*)'([01]*)(.*)", y) x := y1 . FromBin(y2) . y3 ; convert binary numbers to decimal: sign = first bit Else Break x := RegExReplace(x,"(^|[^.\d])(\d+)(e|E)","$1$2.$3") ; add missing '.' before E (1e3 -> 1.e3) ; literal scientific numbers between ‘ and ’ chars x := RegExReplace(x,"(\d*\.\d*|\d)([eE][+-]?\d+)","‘$1$2’") StringReplace x, x,`%, \, All ; % -> \ (= MOD) StringReplace x, x, **,@, All ; ** -> @ for easier process StringReplace x, x, +, ±, All ; ± is addition x := RegExReplace(x,"(‘[^’]*)±","$1+") ; ...not inside literal numbers StringReplace x, x, -, ¬, All ; ¬ is subtraction x := RegExReplace(x,"(‘[^’]*)¬","$1-") ; ...not inside literal numbers Loop Parse, x, `; y := Eval1(A_LoopField) ; work on pre-processed sub expressions ; return result of last sub-expression (numeric) If FORM = b ; convert output to binary y := W ? ToBinW(Round(y),W) : ToBin(Round(y)) Else If (FORM="h" or FORM="x") { SetFormat Integer, Hex ; convert output to hex y := Round(y) + 0 } Else { W := W="" ? "0.6g" : "0." . W ; Set output form, Default = 6 decimal places SetFormat FLOAT, %W% y += 0.0 } SetFormat Integer, %FormI% ; restore original formats SetFormat FLOAT, %FormF% Return y } Eval1(x) { ; recursive PREPROCESSING of :=, vars, (..) [decimal, no ";"] Local i, y, y1, y2, y3 ; save function definition: f(x) := expr If RegExMatch(x, "(\S*?)\((.*?)\)\s*:=\s*(.*)", y) { f%y1%__X := y2, f%y1%__F := y3 Return } ; execute leftmost ":=" operator of a := b := ... If RegExMatch(x, "(\S*?)\s*:=\s*(.*)", y) { y := "x" . y1 ; user vars internally start with x to avoid name conflicts Return %y% := Eval1(y2) } ; here: no variable to the left of last ":=" x := RegExReplace(x,"([\)’.\w]\s+|[\)’])([a-z_A-Z]+)","$1«$2»") ; op -> «op» x := RegExReplace(x,"\s+") ; remove spaces, tabs, newlines x := RegExReplace(x,"([a-z_A-Z]\w*)\(","'$1'(") ; func( -> 'func'( to avoid atan|tan conflicts x := RegExReplace(x,"([a-z_A-Z]\w*)([^\w'»’]|$)","%x$1%$2") ; VAR -> %xVAR% x := RegExReplace(x,"(‘[^’]*)%x[eE]%","$1e") ; in numbers %xe% -> e x := RegExReplace(x,"‘|’") ; no more need for number markers Transform x, Deref, %x% ; dereference all right-hand-side %var%-s Loop { ; find last innermost (..) If RegExMatch(x, "(.*)\(([^\(\)]*)\)(.*)", y) x := y1 . [email protected](y2) . y3 ; replace (x) with value of x Else Break } Return [email protected](x) } [email protected](x) { ; EVALUATE PRE-PROCESSED EXPRESSIONS [decimal, NO space, vars, (..), ";", ":="] Local i, y, y1, y2, y3, y4 If x is number ; no more operators left Return x ; execute rightmost ?,: operator RegExMatch(x, "(.*)(\?|:)(.*)", y) IfEqual y2,?, Return [email protected](y1) ? [email protected](y3) : "" IfEqual y2,:, Return ((y := [email protected](y1)) = "" ? [email protected](y3) : y) StringGetPos i, x, ||, R ; execute rightmost || operator IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) || [email protected](SubStr(x,3+i)) StringGetPos i, x, &&, R ; execute rightmost && operator IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) && [email protected](SubStr(x,3+i)) ; execute rightmost =, <> operator RegExMatch(x, "(.*)(?<![\<\>])(\<\>|=)(.*)", y) IfEqual y2,=, Return [email protected](y1) = [email protected](y3) IfEqual y2,<>, Return [email protected](y1) <> [email protected](y3) ; execute rightmost <,>,<=,>= operator RegExMatch(x, "(.*)(?<![\<\>])(\<=?|\>=?)(?![\<\>])(.*)", y) IfEqual y2,<, Return [email protected](y1) < [email protected](y3) IfEqual y2,>, Return [email protected](y1) > [email protected](y3) IfEqual y2,<=, Return [email protected](y1) <= [email protected](y3) IfEqual y2,>=, Return [email protected](y1) >= [email protected](y3) ; execute rightmost user operator (low precedence) RegExMatch(x, "i)(.*)«(.*?)»(.*)", y) If IsFunc(y2) Return %y2%([email protected](y1),[email protected](y3)) ; predefined relational ops StringGetPos i, x, |, R ; execute rightmost | operator IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) | [email protected](SubStr(x,2+i)) StringGetPos i, x, ^, R ; execute rightmost ^ operator IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) ^ [email protected](SubStr(x,2+i)) StringGetPos i, x, &, R ; execute rightmost & operator IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) & [email protected](SubStr(x,2+i)) ; execute rightmost <<, >> operator RegExMatch(x, "(.*)(\<\<|\>\>)(.*)", y) IfEqual y2,<<, Return [email protected](y1) << [email protected](y3) IfEqual y2,>>, Return [email protected](y1) >> [email protected](y3) ; execute rightmost +- (not unary) operator RegExMatch(x, "(.*[^!\~±¬\@\*/\\])(±|¬)(.*)", y) ; lower precedence ops already handled IfEqual y2,±, Return [email protected](y1) + [email protected](y3) IfEqual y2,¬, Return [email protected](y1) - [email protected](y3) ; execute rightmost */% operator RegExMatch(x, "(.*)(\*|/|\\)(.*)", y) IfEqual y2,*, Return [email protected](y1) * [email protected](y3) IfEqual y2,/, Return [email protected](y1) / [email protected](y3) IfEqual y2,\, Return Mod([email protected](y1),[email protected](y3)) ; execute rightmost power StringGetPos i, x, @, R IfGreaterOrEqual i,0, Return [email protected](SubStr(x,1,i)) ** [email protected](SubStr(x,2+i)) ; execute rightmost function, unary operator If !RegExMatch(x,"(.*)(!|±|¬|~|'(.*)')(.*)", y) Return x ; no more function (y1 <> "" only at multiple unaries: --+-) IfEqual y2,!,Return [email protected](y1 . !y4) ; unary ! IfEqual y2,±,Return [email protected](y1 . y4) ; unary + IfEqual y2,¬,Return [email protected](y1 . -y4) ; unary - (they behave like functions) IfEqual y2,~,Return [email protected](y1 . ~y4) ; unary ~ If IsFunc(y3) Return [email protected](y1 . %y3%(y4)) ; built-in and predefined functions(y4) Return [email protected](y1 . Eval1(RegExReplace(f%y3%__F, f%y3%__X, y4))) ; LAST: user defined functions } ToBin(n) { ; Binary representation of n. 1st bit is SIGN: -8 -> 1000, -1 -> 1, 0 -> 0, 8 -> 01000 Return n=0||n=-1 ? -n : ToBin(n>>1) . n&1 } ToBinW(n,W=8) { ; LS W-bits of Binary representation of n Loop %W% ; Recursive (slower): Return W=1 ? n&1 : ToBinW(n>>1,W-1) . n&1 b := n&1 . b, n >>= 1 Return b } FromBin(bits) { ; Number converted from the binary "bits" string, 1st bit is SIGN n = 0 Loop Parse, bits n += n + A_LoopField Return n - (SubStr(bits,1,1)<<StrLen(bits)) } Sgn(x) { Return (x>0)-(x<0) } MIN(a,b) { Return a<b ? a : b } MAX(a,b) { Return a<b ? b : a } GCD(a,b) { ; Euclidean GCD Return b=0 ? Abs(a) : GCD(b, mod(a,b)) } Choose(n,k) { ; Binomial coefficient p := 1, i := 0, k := k < n-k ? k : n-k Loop %k% ; Recursive (slower): Return k = 0 ? 1 : Choose(n-1,k-1)*n//k p *= (n-i)/(k-i), i+=1 ; FOR INTEGERS: p *= n-i, p //= ++i Return Round(p) } Fib(n) { ; n-th Fibonacci number (n < 0 OK, iterative to avoid globals) a := 0, b := 1 Loop % abs(n)-1 c := b, b += a, a := c Return n=0 ? 0 : n>0 || n&1 ? b : -b } fac(n) { ; n! Return n<2 ? 1 : n*fac(n-1) }

http://www.autohotke...ests-and-fixes/

https://dl.dropbox.c...kups/index.html

**AutoHotkey state, the forum, Poly, and Drainx1. The short story.**

**I love my wife, my life, my atomic-match; for giving me the greatest gift a man could ask for, such a perfect and beautiful little girl.**

New AI-Very simple

Input := "Is the sky blue?" Punct := SubStr(Input,0,1) If (Punct = ".") { Output := "That's nice to know." } Else If (Punct = "!") { Shouts := "Why are you shouting?|Stop shouting at me.|Stop shouting at me!|Quit shouting." StringSplit, Shout, Shouts,`| Random, ShoutNum, 1, %Shout0% OutPut := Shout%ShoutNum% } Else If (Punct = "?") { StringSplit, Words, Input,%a_space% If (Words1 = "Why") { Output := "Because it can." } Else If (Words1 = "What") { If (Words2 = "is") { Output := "That is something you are thinking about." } Else If (Words2 = "can") { Output := "Well everything is possible, so there is no answer to that." } Else If (Words2 = "would") { Output := "Well everything is possible, so there is no answer to that." } Else If (Words2 = "will") { Output := "Well everything is possible, so there is no answer to that." } Else If (Words2 = "might") { Output := "Well everything is possible, so there is no answer to that." } Else { Output := "I'm not sure." } } Else If (Words1 = "Who") { If (Words2 = "is") { Output := "I don't know them." } Else If (Words2 = "did") { Output := "I don't know, I wasn't there." } Else If (Words2 = "can") { Output := "Nobody comes to mind." } Else If (Words2 = "would") { Output := "The world may never know." } Else If (Words2 = "will") { Output := "Nobody comes to mind." } Else If (Words2 = "might") { Output := "Nobody comes to mind." } Else { Output := "I don't know." } } Else If (Words1 = "When") { If (Words2 = "is") { Output := "I'm not sure" } Else If (Words2 = "did") { Output := "I don't know, I wasn't there." } Else If (Words2 = "can") { Output := "When ever you are allowed to." } Else If (Words2 = "would") { Output := "I dont know." } Else If (Words2 = "will") { Output := "We'll just have to wait and see." } Else If (Words2 = "might") { Output := "Sometime in the future." } Else { Output := "Some time ago." } } Else If (Words1 = "Where") { If (Words2 = "is") { Output := "It's somewhere in the world." } Else If (Words2 = "did") { Output := "I don't know, I wasn't there." } Else If (Words2 = "can") { Output := "At a place that does that." } Else If (Words2 = "would") { Output := "At an appropriate location." } Else If (Words2 = "will") { Output := "Where ever it is fit." } Else If (Words2 = "might") { Output := "I don't know, there's a map over there." } Else { Output := "It's somewhere on Earth." } } Else If (Words1 = "How") { If (Words2 = "is") { Output := "Because it can." } Else If (Words2 = "did") { Output := "I don't know, I wasn't there." } Else If (Words2 = "can") { Output := "Read the manual, it tells you how." } Else If (Words2 = "would") { Output := "Read the manual, it tells you how." } Else If (Words2 = "will") { Output := "We'll just have to wait and see." } Else If (Words2 = "might") { Output := "Oh, there are many ways." } Else { Output := "I don't know, I wasn't there." } } Else If (Words1 = "Is") { Output := "Why yes it is." } Else If (Words1 = "Are") { Output := "Why yes they are." } Else { Output := "I believe so." } } Else { Output := "Use punctuation much?" } MsgBox, %Output%

http://www.autohotke...ests-and-fixes/

https://dl.dropbox.c...kups/index.html

Input := "What's one plus one plus one plus one plus one minus one plus one plus one times zero"Equals 5... Well, it passes my IQ test.

**AutoHotkey state, the forum, Poly, and Drainx1. The short story.**

**I love my wife, my life, my atomic-match; for giving me the greatest gift a man could ask for, such a perfect and beautiful little girl.**

"What's one plus one plus one plus one plus one minus one plus one plus one times zero"

1 * 0 = 0 + 1 = 1 + 1 = 2 + 1 = 3 + 1 = 4 - 1 = 3 + 1 = 4 + 1 = 5

or something like that.

EDIT: Yeah its doing pemdas. No wonder I kept getting weird results.

http://www.autohotke...ests-and-fixes/

https://dl.dropbox.c...kups/index.html

expert systems (domain problem solving & knowledge representation)

genetic algoritms (optimization problems)

fuzzy logic systems (control systems)

minmax with lookahead (game strategies)

neural networks (pattern recognition and predictive analysis, machine learning)

artificial reasoning (robotics, autonomous systems)

artificial life systems (cellular automatons, simulation)

There is definitely some overlap in these fields but in general you pick a problem domain then try to build a model (a sample environment) that simulates that domain to one degree or another). Then you provide an "intelligence" that explores that domain to come up with answers to domain problems. I've been thinking about some of these as a possible exercise. Be interesting to see what y'all think...

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.

I guarantee absolutely nothing about any code I provide except that it works in my machine. ●

MMO Fighter KeyLooperDemo Key Spammer TinyClickRecorder GGs Password Generator.ahk

For the newest version of AutoHotkey and some killer scripts go here.

*genetic algoritms*" script thing somewhere.

I'll try to find it when I'm back home.

~~-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------~~**Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org**

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.

(='.'=) Copy and paste Bunny onto your signature.

(")_(") Help Bunny gain World Domination.

About bot or in game we use AI word, but it's half true, in general it is a random part (choice, error) implied by stimulus (data, algo) who give an action (not resulted by experience or very rare exception, and no new problem)

For example we can use as life do <!-- m -->http://en.wikipedia....al_analysis<!-- m -->

Good luck

*"You annoy me, therefore I exist."*

**AutoHotkey state, the forum, Poly, and Drainx1. The short story.**