generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Learning AI That learns to add

Previous Thread :: Next Thread 
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
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
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
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
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
08 May 2015 10:30 PM
@BFFStick00
No problem
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
08 May 2015 10:31 PM
Why did you say "No problem". I was the one who helped you! xD
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
08 May 2015 10:33 PM
LOL I mean to say thx.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
08 May 2015 10:35 PM
xD No problem. Happens to the best of us.
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
23 May 2015 08:06 PM
Updated majorly!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image