|
| 08 May 2015 10:20 PM |
This took me about 3 hours, but I came up with this:
speed = .2 -- How fast you want it to think? cantDo = {1, 1, 3} correct = 0 problems_done = 0 time_thought = 0 value = false isDone = true answer = 0 print("\n\n\n\n\n\n\n\n\n") function isCorrect(c1, c2, a) local c3 = c1 + c2 if (c3 == a) then return true else return false end return false end function canDo(c1, c2, a) for i = 3, #cantDo, 3 do if (cantDo[i] == a) then x = i if (cantDo[i-2] == c1) and (cantDo[i-1] == c2) then return false end end if (i >= #cantDo) then return true end end end function learn(c1, c2, a) if (c1+c2 ~= a) then problems_done = problems_done + 1 print("incorrect" .. " | " .. c1 .. " | " .. c2 .. " | " .. a .. " | " .. correct .. " / " .. problems_done.. " / " .. time_thought) cantDo[#cantDo+1] = c1 cantDo[#cantDo+1] = c2 cantDo[#cantDo+1] = a wait(speed) pie() else problems_done = problems_done + 1 correct = correct + 1 print("correct!" .. " | " .. c1 .. " | " .. c2 .. " | " .. a .. " | " .. correct .. " / " .. problems_done.. " / " .. time_thought) wait(speed) pie() end end function pie() local choice1 = math.random(1,9) local choice2 = math.random(1,9) if (isDone == true) then answer = math.random(2,18) time_thought = 0 isDone = false pie() end time_thought = time_thought + 1 if (canDo(choice1, choice2, answer)) then if not (isCorrect(choice1, choice2, answer)) then isDone = true learn(choice1, choice2, answer) else correct = correct + 1 print("correct!" .. " | " .. choice1 .. " | " .. choice2 .. " | " .. answer .. " | " .. correct .. " / " .. problems_done .. " / " .. time_thought) wait(spped) isDone = true pie() end else wait(speed) pie() end end pie()
Look in the output for the result, It's pretty simple the out put is:
(correct or not) | (choice 1) | (choice 2) | (answer) | (correct answers) | (problems solved) | (attempts to solve)
What does it do? Well it tries to find a way to solve the answers. It learns which ones are right and wrong, the incorrect answers are in an array, and it is unable to pick those, and it repeats many different random numbers until it picks one that will give it the correct answer.
How does it work? It learns by adding the first, and second number to the array, as well as the answer. Then it iterates through the array, looking for something to say it's wrong, but if it doesn't find anything it chooses new numbers, and repeats. The random number chosen for the answer stays until the problem is solved.
So yeah, it's actually kinda fun to watch. |
|
|
| Report Abuse |
|
|
|
| 08 May 2015 10:21 PM |
| I noticed I made a small mistake and I spelled spped instead of speed, but whatever just fix those small bugs and it should work. |
|
|
| Report Abuse |
|
|
|
| 08 May 2015 10:24 PM |
| It would be simpler to use a tokenizer then convert the tokens into a equation. That or it's just me... |
|
|
| Report Abuse |
|
|
|
| 08 May 2015 10:26 PM |
@BFFStick00
That's a pretty good idea, actually. I may update this tommorow, and make it more efficient and simple. |
|
|
| Report Abuse |
|
|
|
| 08 May 2015 10:28 PM |
| I used the same method in my admin script for multiple arguments in a command(like teleport). I am glad I helped! :D |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 May 2015 10:31 PM |
| Why did you say "No problem". I was the one who helped you! xD |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 May 2015 10:35 PM |
| xD No problem. Happens to the best of us. |
|
|
| Report Abuse |
|
|
| |
|