Jump to content

Search the Community

Showing results for tags 'ai'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 5 results

  1. SciTE AI assistant The first approach, to integrate an AI assistant into SciTE works directly with the ollama. I use a small model qwen2.5-coder:3b as default, so that I don't have to wait too long for a response. However, I have set as a parameter which model it calls, so that it changes the model per job if necessary The first job is to make function headers Simply run the script, select a function body within SciTE and press the {F10} key It's not perfect, but it's a template. ; https://www.autoitscript.com/forum/topic/212888-scite-ai-assistant ;---------------------------------------------------------------------------------------- ; Title...........: SciTE_AI_Assistant.au3 ; Description.....: SciTE AI assistant - first feature: Function headers generator ; Simply select a function within SciTE and press the {F10} key. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.7 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <File.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Global $DebugInfo = True ; True = debug info * <-- HotKeySet("{F10}", "GenerateFunctionHeader") ; * <-- While 1 Sleep(100) WEnd ;--------------------------------------------------------------------------------------- Func GenerateFunctionHeader() HotKeySet("{F10}") Local $hWnd = WinActivate("[CLASS:SciTEWindow]") If Not $hWnd Then Return SetError(HotKeySet("{F10}", "GenerateFunctionHeader")) Local $sSelected = _SciteIO() ;Get Selection If @error Then ToolTip(" Copy failed.") Else If StringLeft($sSelected, 4) = "func" Then Send('{UP}') Local $sOut = AI_GenerateFunctionHeader($sSelected) If @error Then ToolTip(@error) Else _SciteIO(@CRLF & @CRLF & $sOut & @CRLF & @CRLF) EndIf Else ToolTip("No Func selected") EndIf EndIf Sleep(2000) ToolTip("") HotKeySet("{F10}", "GenerateFunctionHeader") EndFunc ;==>GenerateFunctionHeader ;--------------------------------------------------------------------------------------- Func AI_GenerateFunctionHeader($sFullFunction, $sAssistant = -1) If $sAssistant = -1 Then $sAssistant = "qwen2.5-coder:3b" Local $sInstruction, $sSystem, $sOut $sInstruction = "Generate a function header for the given AutoIt function." & @CRLF $sInstruction &= "Use the exact standard UDF comment format, as shown in the example." & @CRLF $sInstruction &= "DO NOT invent or assume any parameters, return values, or behavior not explicitly visible in the function." & @CRLF $sInstruction &= "If the function has no parameters, leave 'Parameters' empty." & @CRLF $sInstruction &= "If it does not return a value, then in 'Return values' write 'None'." & @CRLF $sInstruction &= "Align all parameter names to the same column width using consistent spaces. The hyphen (-) must appear in the same column for all parameters." & @CRLF $sInstruction &= "If the function interacts with GUI elements, include that in the 'Remarks' section." & @CRLF $sInstruction &= "If the 'Remarks' line exceeds 130 characters, break it into multiple lines starting each with '; ' like in the example." & @CRLF $sInstruction &= "Optional parameters must be shown using nested brackets as per the example." & @CRLF $sInstruction &= "Match spacing exactly as in the example (e.g., align parameter names and descriptions)." & @CRLF $sInstruction &= "Use concise, factual language—do not embellish or rephrase beyond what's explicit in the function." & @CRLF $sInstruction &= "In 'Return values', include detailed descriptions of any @error values that may be set." & @CRLF $sInstruction &= "Use the following format for @error documentation: '@error = X: Explanation' as shown in the example." & @CRLF $sInstruction &= "If applicable, describe both the success and failure outcomes clearly, using 'Success:' and 'Failure:'." & @CRLF $sInstruction &= "The 'Author' is ioa747. Dependencies must match actual function calls only. Do not invent links or libraries." & @CRLF $sInstruction &= "Avoid unnecessary technical jargon. Keep lines compact and accurate." & @CRLF & @CRLF $sInstruction &= "Example format:" & @CRLF $sInstruction &= "; #FUNCTION# ====================================================================================================================" & @CRLF $sInstruction &= "; Name...........: StreamToEdit" & @CRLF $sInstruction &= "; Description....: Generate response from the AI assistant with streaming support." & @CRLF $sInstruction &= "; Syntax.........: StreamToEdit( $sPrompt [, $sAssistant = ""qwen2.5-coder:1.5b"" [, $sSystem = ""You are an AI assistant."" [, $fTemperature = 0.3 [, $iSeed = 0]]]] )" & @CRLF $sInstruction &= "; Parameters.....: $sPrompt - The prompt to be sent to the assistant." & @CRLF $sInstruction &= "; $sAssistant - [optional] The name of the AI assistant. (Default is ""qwen2.5-coder:3b"")" & @CRLF $sInstruction &= "; $sSystem - [optional] The system instruction provided by the user. (Default is ""You are an AI assistant."")" & @CRLF $sInstruction &= "; $fTemperature - [optional] The temperature value for the assistant's output. (Default is 0.3)" & @CRLF $sInstruction &= "; $iSeed - [optional] The seed value for the assistant's response. (Default is 0)" & @CRLF $sInstruction &= "; Return values .: Success: Returns the available models if the specified model is found." & @CRLF $sInstruction &= "; Failure: Sets @error and returns an empty string with a custom message." & @CRLF $sInstruction &= "; @error = 1: Ollama is not running at the default URL." & @CRLF $sInstruction &= "; @error = 2: The specified model was not found." & @CRLF $sInstruction &= "; Author ........: ioa747" & @CRLF $sInstruction &= "; Modified ......: " & @CRLF $sInstruction &= "; Remarks .......: This function uses a WinHttp request to communicate with the Ollama API." & @CRLF $sInstruction &= "; Related .......: " & @CRLF $sInstruction &= "; Link ..........: " & @CRLF $sInstruction &= "; Example .......: " & @CRLF $sInstruction &= "; ===============================================================================================================================" & @CRLF & @CRLF $sInstruction &= "Now generate a header comment for the following function:" & @CRLF $sInstruction &= "```AutoIt" & @CRLF $sInstruction &= $sFullFunction & @CRLF $sInstruction &= "```" & @CRLF Local $hTimer = TimerInit() $sOut = AskToAI($sInstruction, $sAssistant, $sSystem, 0, 1) If @error Then Return SetError(@error, 0, $sOut) Return "> " & $sAssistant & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @CRLF & $sOut EndFunc ;==>AI_GenerateFunctionHeader ;--------------------------------------------------------------------------------------- Func AskToAI($sPrompt, $sAssistant = -1, $sSystem = -1, $iTemperature = -1, $iSeed = -1) If $sSystem = "" Or $sSystem = -1 Or $sSystem = Default Then $sSystem = "You are an AI assistant designed to analyze AutoIt code." ; best mini models result with: qwen2.5-coder:1.5b ; qwen2.5-coder:3b 1.8 GB ; llama3.2:3b-instruct-q8_0 3.2 GB If $sAssistant = "" Or $sAssistant = -1 Or $sAssistant = Default Then $sAssistant = "qwen2.5-coder:3b" If $iTemperature = "" Or $iTemperature = -1 Or $iTemperature = Default Then $iTemperature = 0.3 If $iSeed = "" Or $iSeed = -1 Or $iSeed = Default Then $iSeed = 0 Json_EscapeString($sAssistant) Json_EscapeString($sSystem) Json_EscapeString($sPrompt) Local $sRequest = '{' $sRequest &= '"model": "' & $sAssistant & '", ' $sRequest &= '"system": "' & $sSystem & '", ' $sRequest &= '"prompt": "' & $sPrompt & '", ' $sRequest &= '"stream": false, ' $sRequest &= '"temperature": ' & $iTemperature & ', ' $sRequest &= '"seed": ' & $iSeed $sRequest &= '}' DW("$sRequest=>" & $sRequest & @CRLF) ;_FileWriteLog(StringTrimRight(@ScriptFullPath, 4) & ".log", $sRequest) Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") ; ResolveTimeout: 5 sec ; ConnectTimeout: 10 sec ; SendTimeout: 30 sec ; ReceiveTimeout: 120 sec $oHttp.SetTimeouts(5000, 10000, 30000, 120000) $oHttp.Open("POST", "http://localhost:11434/api/generate", False) $oHttp.SetRequestHeader("Content-Type", "application/json") $oHttp.Send($sRequest) ; Check if request was successful If $oHttp.Status <> 200 Then Local $aErr = HTTP_STATUS_CODES($oHttp.Status, $oHttp.ResponseText) MsgBox(16, " ( " & $aErr[0] & " ) " & $aErr[1], $aErr[2]) Return SetError(1, 0, $oHttp.ResponseText) EndIf Local $sResponse = $oHttp.ResponseText DW("$sResponse=>" & $sResponse & @CRLF) ; Parse response => suporting value: .model ; .created_at ; .response ; .done_reason Local $mJson = Json_Map($sResponse) ; DW("$mJson.response=" & $mJson.response & @CRLF) MapExists($mJson, "response") If @error Then MsgBox(16, "AskToAI() l: " & @ScriptLineNumber, "_JsonMap() fail to response") Return SetError(2, 0, "_JsonMap() fail to response") EndIf $sResponse = $mJson.response Return $sResponse EndFunc ;==>AskToAI ;--------------------------------------------------------------------------------------- Func _SciteIO($sTxt = "") Local $hWnd = WinActivate("[CLASS:SciTEWindow]") If Not $hWnd Then Return SetError(1) Local $ClipBack = ClipGet() ; backup clip data Local $hCtrlHnd, $ClipData, $iTimeout = 2000 ClipPut("<empty>") Local $iStartTime = TimerInit() If $sTxt = "" Then ; ### get selection to clip ### $hCtrlHnd = ControlGetHandle($hWnd, '', 'Scintilla1') _SendMessage($hCtrlHnd, $WM_COPY) While TimerDiff($iStartTime) < $iTimeout ; Wait until the timeout $ClipData = ClipGet() If $ClipData <> "<empty>" Then ExitLoop Sleep(10) WEnd Else ; ### set Txt to Console ### $hCtrlHnd = ControlGetHandle($hWnd, '', 'Scintilla2') ClipPut($sTxt) While TimerDiff($iStartTime) < $iTimeout ; Wait until the timeout $ClipData = ClipGet() If $ClipData <> "<empty>" Then ExitLoop Sleep(10) WEnd If $ClipData <> "<empty>" Then Local $iWndHeight = ControlGetPos ($hWnd, "", $hCtrlHnd) If $iWndHeight[3] = 0 Then WinMenuSelectItem($hWnd, "", "&View", "&Output") Sleep(10) ControlSend($hWnd, "", $hCtrlHnd, "^{DOWN}") If Not $DebugInfo Then WinMenuSelectItem($hWnd, "", "&Tools", "Clear &Output") ;* Clear console Output Sleep(10) _SendMessage($hCtrlHnd, $WM_PASTE) EndIf EndIf ClipPut($ClipBack) ; Restore clip data Return ($ClipData = "<empty>" ? SetError(2) : $ClipData) EndFunc ;==>_SciteIO ;--------------------------------------------------------------------------------------- Func HTTP_STATUS_CODES($iStatus, $sResponseText = "") Local $aResult[3] = [$iStatus, "Unknown Status", "An unknown HTTP status code was returned."] Local $HTTP_STATUS_CODES[41][3] = [[40, "HTTP status", "description"] _ , [100, "HTTP_STATUS_CONTINUE", "The request can be continued."] _ , [101, "HTTP_STATUS_SWITCH_PROTOCOLS", "The server has switched protocols in an upgrade header."] _ , [200, "HTTP_STATUS_OK", "The request completed successfully."] _ , [201, "HTTP_STATUS_CREATED", "The request has been fulfilled and resulted in the creation of a new resource."] _ , [202, "HTTP_STATUS_ACCEPTED", "The request has been accepted for processing, but the processing has not been completed."] _ , [203, "HTTP_STATUS_PARTIAL", "The returned meta information in the entity-header is not the definitive set available from the originating server."] _ , [204, "HTTP_STATUS_NO_CONTENT", "The server has fulfilled the request, but there is no new information to send back."] _ , [205, "HTTP_STATUS_RESET_CONTENT", "The request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action."] _ , [206, "HTTP_STATUS_PARTIAL_CONTENT", "The server has fulfilled the partial GET request for the resource."] _ , [207, "HTTP_STATUS_WEBDAV_MULTI_STATUS", "During a World Wide Web Distributed Authoring and Versioning (WebDAV) operation, this indicates multiple status codes for a single response. The response body contains Extensible Markup Language (XML) that describes the status codes."] _ , [300, "HTTP_STATUS_AMBIGUOUS", "The requested resource is available at one or more locations."] _ , [301, "HTTP_STATUS_MOVED", "The requested resource has been assigned to a new permanent Uniform Resource Identifier (URI), and any future references to this resource should be done using one of the returned URIs."] _ , [302, "HTTP_STATUS_REDIRECT", "The requested resource resides temporarily under a different URI."] _ , [303, "HTTP_STATUS_REDIRECT_METHOD", "The response to the request can be found under a different URI and should be retrieved using a GET HTTP verb on that resource."] _ , [304, "HTTP_STATUS_NOT_MODIFIED", "The requested resource has not been modified."] _ , [305, "HTTP_STATUS_USE_PROXY", "The requested resource must be accessed through the proxy given by the location field."] _ , [307, "HTTP_STATUS_REDIRECT_KEEP_VERB", "The redirected request keeps the same HTTP verb. HTTP/1.1 behavior."] _ , [400, "HTTP_STATUS_BAD_REQUEST", "The request could not be processed by the server due to invalid syntax."] _ , [401, "HTTP_STATUS_DENIED", "The requested resource requires user authentication."] _ , [402, "HTTP_STATUS_PAYMENT_REQ", "Not implemented in the HTTP protocol."] _ , [403, "HTTP_STATUS_FORBIDDEN", "The server understood the request, but cannot fulfill it."] _ , [404, "HTTP_STATUS_NOT_FOUND", "The server has not found anything that matches the requested URI."] _ , [405, "HTTP_STATUS_BAD_METHOD", "The HTTP verb used is not allowed."] _ , [406, "HTTP_STATUS_NONE_ACCEPTABLE", "No responses acceptable to the client were found."] _ , [407, "HTTP_STATUS_PROXY_AUTH_REQ", "Proxy authentication required."] _ , [408, "HTTP_STATUS_REQUEST_TIMEOUT", "The server timed out waiting for the request."] _ , [409, "HTTP_STATUS_CONFLICT", "The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with more information."] _ , [410, "HTTP_STATUS_GONE", "The requested resource is no longer available at the server, and no forwarding address is known."] _ , [411, "HTTP_STATUS_LENGTH_REQUIRED", "The server cannot accept the request without a defined content length."] _ , [412, "HTTP_STATUS_PRECOND_FAILED", "The precondition given in one or more of the request header fields evaluated to false when it was tested on the server."] _ , [413, "HTTP_STATUS_REQUEST_TOO_LARGE", "The server cannot process the request because the request entity is larger than the server is able to process."] _ , [414, "HTTP_STATUS_URI_TOO_LONG", "The server cannot service the request because the request URI is longer than the server can interpret."] _ , [415, "HTTP_STATUS_UNSUPPORTED_MEDIA", "The server cannot service the request because the entity of the request is in a format not supported by the requested resource for the requested method."] _ , [449, "HTTP_STATUS_RETRY_WITH", "The request should be retried after doing the appropriate action."] _ , [500, "HTTP_STATUS_SERVER_ERROR", "The server encountered an unexpected condition that prevented it from fulfilling the request."] _ , [501, "HTTP_STATUS_NOT_SUPPORTED", "The server does not support the functionality required to fulfill the request."] _ , [502, "HTTP_STATUS_BAD_GATEWAY", "The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request."] _ , [503, "HTTP_STATUS_SERVICE_UNAVAIL", "The service is temporarily overloaded."] _ , [504, "HTTP_STATUS_GATEWAY_TIMEOUT", "The request was timed out waiting for a gateway."] _ , [505, "HTTP_STATUS_VERSION_NOT_SUP", "The server does not support the HTTP protocol version that was used in the request message."]] For $i = 1 To $HTTP_STATUS_CODES[0][0] If $HTTP_STATUS_CODES[$i][0] = $iStatus Then ;$aResult[0] = $HTTP_STATUS_CODES[$i][0] $aResult[1] = $HTTP_STATUS_CODES[$i][1] $aResult[2] = $HTTP_STATUS_CODES[$i][2] ExitLoop EndIf Next ConsoleWrite("! $aResult[0]=" & $aResult[0] & ", [1]=" & $aResult[1] & ", [2]=" & $aResult[2] & @TAB & "( " & $sResponseText & " )" & @CRLF) $aResult[2] &= @CRLF & @CRLF & "Details: " & $sResponseText Return $aResult EndFunc ;==>HTTP_STATUS_CODES ;--------------------------------------------------------------------------------------- Func DW($sString, $iLine = @ScriptLineNumber) If Not $DebugInfo Then Return ConsoleWrite("(" & $iLine & ") " & $sString) EndFunc ;==>DW ;--------------------------------------------------------------------------------------- Func Json_EscapeString(ByRef $sString) ;=== Converts normal string to a JSON-safe string === ; Escape backslashes first to avoid double-processing $sString = StringReplace($sString, '\', '\\', 0, 1) ; Escape known JSON control characters $sString = StringReplace($sString, Chr(8), '\b', 0, 1) ; Backspace $sString = StringReplace($sString, Chr(12), '\f', 0, 1) ; Formfeed $sString = StringReplace($sString, @CRLF, '\n', 0, 1) ; CRLF → \n $sString = StringReplace($sString, @LF, '\n', 0, 1) ; LF → \n $sString = StringReplace($sString, @CR, '\r', 0, 1) ; CR → \r $sString = StringReplace($sString, @TAB, '\t', 0, 1) ; Tab → \t ; Escape double quotes $sString = StringReplace($sString, '"', '\"', 0, 1) ; Escape \u00XX characters ; nothing yet Return $sString EndFunc ;==>Json_EscapeString ;--------------------------------------------------------------------------------------- Func Json_UnEscapeString(ByRef $sString) ;=== Converts a JSON-escaped string back into normal string === If StringInStr($sString, '\') = 0 Then Return $sString ; Unescape quotes and backslashes first $sString = StringReplace($sString, '\"', '"', 0, 1) $sString = StringReplace($sString, '\\', '\', 0, 1) ; Unescape standard control characters $sString = StringReplace($sString, '\b', Chr(8), 0, 1) $sString = StringReplace($sString, '\f', Chr(12), 0, 1) $sString = StringReplace($sString, '\n', @LF, 0, 1) $sString = StringReplace($sString, '\r', @CR, 0, 1) $sString = StringReplace($sString, '\t', @TAB, 0, 1) ; Unescape \u00XX characters $sString = StringReplace($sString, '\u003c', '<', 0, 1) $sString = StringReplace($sString, '\u003e', '>', 0, 1) Return $sString EndFunc ;==>Json_UnEscapeString ;--------------------------------------------------------------------------------------- Func Json_Map($sJson) ;=== It not support numbers, booleans, arrays or nested objects. === Local $mJson[] ; Remove curly braces and trim $sJson = StringStripWS(StringTrimLeft(StringTrimRight($sJson, 1), 1), 3) ; Match all "key": "value" pairs Local $aPairs = StringRegExp($sJson, '"([^"]+)"\s*:\s*"((?:\\.|[^"\\])*)"', 3) If @error Then Return SetError(2, 0, 0) For $i = 0 To UBound($aPairs) - 1 Step 2 Local $sKey = $aPairs[$i] Local $sVal = $aPairs[$i + 1] Json_UnEscapeString($sVal) $mJson[$sKey] = $sVal ;ConsoleWrite("$sKey=" & $sKey & @CRLF) Next Return $mJson EndFunc ;==>Json_Map ;--------------------------------------------------------------------------------------- I will update the thread as soon as anything new comes up. Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
  2. From MiniMax to Machine Learning ... Tic Tac Toe is a good game for studying AI algorithm because it's simple! I use Tabular Q Learning to implement this game, Every time a game finished, it will use the Q function to update the score of each steps it played. Q(S,A) = Q(S,A) + α ∗ (γ ∗ maxaQ(S′,a) − Q(S,A)) S being the current state, A the current action, S′ the state after doing A, α being the learning rate, γ being the discount factor, and maxaQ(S′,a) the highest Q value of any move in the next state S′, i.e. the Q value of the best move in the following state. It's funny to see that it plays better and better. That's why people were charmed by Machine Learning! Thank you! Download: tic_tac_toe.zip
  3. Hello, I'm building whit mine limited coding know-how a AI in Autoit.... Just because..... why not It's not doing what i tought it would do. I hope somebody could help me whit this script? so far : -building an learning grid --> AI needs to guess the label in the grin whit only the X and Y value. -Building an array filled whit random values as weights. -quess the label -learn - if quess not the same as the label go change the weights At this point (the changing of the weights) I've some strange result and hope somebody could point me in the right direction I think that the problem is in the formula for changing the weights. PS. I'm also open for good coding practice I'm learning coding as i go #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <MsgBoxConstants.au3> #include <Array.au3> build_grid_list() build_neurons() _ArrayDisplay($gridlist,"$gridlist 0","",32) _ArrayDisplay($neurons,"$neurons 0","",32) For $i = 1 To UBound($gridlist,1) - 1 If $gridlist[$i][3] = 1 Then go_learn($neurons[1][0],$gridlist[$i][0]) EndIf Next _ArrayDisplay($gridlist,"$gridlist 1","",32) _ArrayDisplay($neurons,"q$neurons 1","",32) Func go_learn($neuron_ID,$gridlist_ID) Local $test = guess($gridlist_ID , $neuron_ID ) For $i = 1 To 5000 If $test <> $gridlist[$gridlist_ID][4] Then change_wieght($neuron_ID , $gridlist_ID ) $test = guess($gridlist_ID , $neuron_ID ) Else ExitLoop EndIf Next EndFunc Func guess($gridlist_ID , $neuron_ID = 1 ,$raw = 0);, $loop = 0 ) Local $temp = 0 ;~ For $i = 1 To ubound($neurons,1) -1 ; input1 * W1 + input2 * W2 + Bias(1) * W3 $temp = $gridlist[$gridlist_ID][1] * $neurons[$neuron_ID][1] + $gridlist[$gridlist_ID][2] * $neurons[$neuron_ID][2] + 1 * $neurons[$neuron_ID][3] ;activate (sign) If $temp >= 0 Then $neurons[$neuron_ID][6] = 1 Else $neurons[$neuron_ID][6] = -1 EndIf $gridlist[$gridlist_ID][5] = $neurons[$neuron_ID][6] $gridlist[$gridlist_ID][6] = $gridlist[$gridlist_ID][6] + 1 $neurons[$neuron_ID][9] = $neurons[$neuron_ID][9] + 1 If $raw = 0 Then Return $neurons[$neuron_ID][6] Else Return $temp EndIf EndFunc Func build_neurons($needed_neurons = 10 ) Global $neurons[$needed_neurons + 1][10] $neurons[0][0] = "id" $neurons[0][1] = "wieght1" $neurons[0][2] = "wieght2" $neurons[0][3] = "wieght3" $neurons[0][4] = "input1" $neurons[0][5] = "input2" $neurons[0][6] = "output" $neurons[0][7] = "tweak_counter" $neurons[0][8] = "not_tweak_counter" $neurons[0][9] = "quess_counter" Local $temp = 1 For $i = 1 To $needed_neurons; -1 $neurons[$i][0] = $i ;id Do ;zero_check output wieght1 $temp = Random(-1 , 1) Until $temp <> 0 $neurons[$i][1] = $temp ;wieght1 Do ;zero_check output wieght2 $temp = Random(-1 , 1) Until $temp <> 0 $neurons[$i][2] = $temp ;wieght2 Do ;zero_check output wieght3 $temp = Random(-1 , 1) Until $temp <> 0 $neurons[$i][3] = $temp ;wieght3 $neurons[$i][4] = 0 ;input1 $neurons[$i][5] = 0 ;input2 Do ;zero_check output $temp = Random(-1 , 1 , 1) Until $temp <> 0 $neurons[$i][6] = $temp ;output +1 / -1 ;~ $neurons[$i][6] = 0 ;output $neurons[$i][7] = 0 ;tweak_counter $neurons[$i][8] = 0 ;not_tweak_counter $neurons[$i][9] = 0 ;quess_counter Next EndFunc Func build_grid_list($grid_x = 10 ,$grid_y = 10 ) Global $gridlist[($grid_x * $grid_y) + 1 ][7] Local $counter = 1 $gridlist[0][0] = "ID" $gridlist[0][1] = "X" $gridlist[0][2] = "Y" $gridlist[0][3] = "Active" $gridlist[0][4] = "Label" $gridlist[0][5] = "quessed" $gridlist[0][6] = "quessed_counter" For $x = 0 to $grid_x - 1 For $y = 0 to $grid_y - 1 $gridlist[$counter][0] = $counter $gridlist[$counter][1] = $x $gridlist[$counter][2] = $y If Random(-1 , 1) >= 0 Then $gridlist[$counter][3] = 0 Else $gridlist[$counter][3] = 1 EndIf If $x > $y Then $gridlist[$counter][4] = 1 Else $gridlist[$counter][4] = -1 EndIf $gridlist[$counter][5] = -99 $gridlist[$counter][6] = 0 $counter = $counter + 1 Next Next EndFunc Func change_wieght($neuron_id , $grid_id );, $W1 , $W2 ) ;W1 = W1 + ^W1 (some change in W1) ;^W = err(known) * input ($neurons[$id][3] = "output") * learningrate ;$neurons[$id][1] = $neurons[$id][1] + "wieght1" Local $iReturn = False ; Desired | Quess | Error ; -1 -1 0 ; -1 +1 -2 ; +1 -1 +2 ; +1 +1 0 Local $error = $gridlist[$grid_id][4] - $neurons[$neuron_id][6] If $error <> 0 Then Local $learningrate = 0.1 Local $str_len1 = StringLen($neurons[$neuron_id][1]) Local $str_len2 = StringLen($neurons[$neuron_id][2]) Local $str_len3 = StringLen($neurons[$neuron_id][3]) Local $dif_weights1 = $error * $neurons[$neuron_id][1] * $learningrate Local $dif_weights2 = $error * $neurons[$neuron_id][2] * $learningrate Local $dif_weights3 = $error * $neurons[$neuron_id][3] * $learningrate Local $verschil1 = StringLeft($dif_weights1,$str_len1) Local $verschil2 = StringLeft($dif_weights2,$str_len2) Local $verschil3 = StringLeft($dif_weights3,$str_len3) Local $new_wieght1 = $neurons[$neuron_id][1] + $verschil1 Local $new_wieght2 = $neurons[$neuron_id][2] + $verschil2 Local $new_wieght3 = $neurons[$neuron_id][3] + $verschil3 $neurons[$neuron_id][1] = StringLeft($new_wieght1,$str_len1) $neurons[$neuron_id][2] = StringLeft($new_wieght2,$str_len2) $neurons[$neuron_id][3] = StringLeft($new_wieght3,$str_len3) $neurons[$neuron_id][7] = $neurons[$neuron_id][7] + 1 ;"counter" $iReturn = False Else $neurons[$neuron_id][8] = $neurons[$neuron_id][8] + 1 ;"not counter" $iReturn = True EndIf Return $iReturn EndFunc thanks in advanced.
  4. Hi guys, I just finished a Connect 4 game by using MiniMax with Alpha Beta Pruning. I haven't written a program for a long time, but writing an AI program is always funny! I have to learn how the algorithm works and try to optimize the code to run faster. Let's play and have fun! Oops, I lost the game ... Thanks guys! Download: Connect 4.zip
  5. Hi everyone i am creating a speech recognition pc assistant,could any one recommend any ideas regarding what i should include in my project like playing music,telling time and date etc.Thanks in advance.Screenshot of the program gui included as below. Rec013_001.bmp Rec013_002.bmp Rec013_004.bmp
×
×
  • Create New...