SetWindowSize(1024, 768, 0) global Sum as float Sum = 0 global Error as float Error = 0 global Actual_Result as float Actual_Result = 0 global Desired_Result as float Desired_Result = 1 global Learning_Rate as float Learning_Rate = 0.1 global Trials as integer Trials = 10 global Inputs as float[4] Inputs[1] = 0 Inputs[2] = 1 Inputs[3] = 0 Inputs[4] = 0 global Weights as float[4] Weights[1] = 0 Weights[2] = 0 Weights[3] = 0 Weights[4] = 0 global Results as float[4] Results[1] = 0 Results[2] = 0 Results[3] = 0 Results[4] = 0 function NeuralNetwork() Sum = 0 for x = 1 to 4 Results[x] = 0 Results[x] = Inputs[x] * Weights[x] Sum = Results[x] + Sum next x endfunction function Evaluate_NeuralNetwork() for i = 1 to 4 Actual_Result = Results[i] + Actual_Result next i Error = Desired_Result - Actual_Result endfunction function Learn_NeuralNetwork() for j = 1 to 4 if Inputs[j] > 0 Weights[j] = Weights[j] + Learning_Rate endif next j endfunction function Train_NeuralNetwork() while Trials > 0 NeuralNetwork() Learn_NeuralNetwork() Trials = Trials - 1 endwhile while Trials = 0 NeuralNetwork() Evaluate_NeuralNetwork() Trials = Trials - 1 endwhile endfunction do Train_NeuralNetwork() printC("Neural network output: ") print(Sum) printC("Error: ") print(Error) print("") Print("Inputs: ") for i = 1 to 4 Printc(i) printc(": ") Print(Inputs[i]) next i Print("") Print("Weights: ") for i = 1 to 4 Printc(i) printc(": ") print(Weights[i]) next i Print("") Print("Results: ") for i = 1 to 4 Printc(i) printc(": ") print(Results[i]) next i Print("") Print("Actual Result: ") Printc("1: ") Print(Actual_Result) Print("") Print("Desired Result: ") Printc("1: ") Print(Desired_Result) sync() loop