Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 24
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
All today's birthdays', congrats!
Mathias (41)
slash128v6 (52)


Next birthdays
01/31 Mathias (41)
01/31 slash128v6 (52)
02/01 Barry (70)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

Tic-Tac-Toe :: Learning

Move Thread LAN_403
rp181
Fri Jan 02 2009, 05:58PM Print
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
For a project, i am attempting to make a program to 'learn'. To start of with, i made 2 tic-tac-toe programs. 1 goes randomly, and 1 picks "winning" spots more frequently. The 2 programs are here:
Link2
The first one is with learning, 2nd one with random. The mini ttt board on the learning one shows the ranges, ranges get bigger as spot is used more(winning). The 2nd one shows wins when somone wins as a coordinate (X,O).

Can you guys play a few games and tell me if the "learning" one is any better? The learning one is simply randomly choosing, but based on the range, more of a chance of being accepted. The random one has 1/10th of a chance of being accepted, and keeps going until a move is accepted.

The random will be a bit flickery, but its fine, i just made that one constantly repaint (it wont erase when taken off screen for a moment like the random one).

Tell me what you guys think.

Forgot to mention, you click the square to go there, sometimes you may have to click twice.

EDIT: I added a new one. This has a different way of deciding where to go. Each square has a rank 1-10 (look on mini board) starting on five. If its winning square it goes up (2 wins). It then goes to the highest rank square, and gets rank*10 times to try and get 2 random numbers (1-3) matching up with the square position (upper right is 1,1).
Back to top
Backyard Skunkworks
Sat Jan 03 2009, 12:26AM
Backyard Skunkworks Registered Member #1262 Joined: Fri Jan 25 2008, 05:22AM
Location: Maryland, USA
Posts: 451
First one:
Won 8, lost 1, 1 tie
Second one:
5 wins, 5 ties
Third one:
4 wins, 4 losses, 2 ties

I suck at tic-tac toe. You'll need a bigger sample to really know if these work well...
Back to top
rp181
Sat Jan 03 2009, 12:52AM
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
Do you mean first as in first on the page or first version (bottom page). If its the top one, that means "learning" is working worse ;(.

try the first one on the page some more, when i do it, it gets alot better after awhile.
Back to top
Backyard Skunkworks
Sat Jan 03 2009, 01:23AM
Backyard Skunkworks Registered Member #1262 Joined: Fri Jan 25 2008, 05:22AM
Location: Maryland, USA
Posts: 451
Yeah, the top one. I just played it more and went 17 and 3. Of course I think its because the learning is somewhat predictable, where as the random one does weird stuff and is hard to anticipate.
Back to top
Myke
Sat Jan 03 2009, 02:38AM
Myke Registered Member #540 Joined: Mon Feb 19 2007, 07:49PM
Location: MIT
Posts: 969
hmm
I think there is a bug in the random one because sometimes when it is
o o _
x x _
o _ x
and I move
o o _
x x x
o _ x

it adds a winning count to the comp's score.
Also, I think that if the last move were to be a winning move for me, it doesn't count it.
For some reason though, it doesn't seem to be the case all the time. I donno though...
Back to top
aonomus
Sat Jan 03 2009, 03:24AM
aonomus Registered Member #1497 Joined: Thu May 22 2008, 05:24AM
Location: Toronto, Ontario, Canada
Posts: 801
This is almost like one of those 'genetic algorithm' processes no?

Do random moves on both parts, but track the most successful positions and play those preferentially.
Back to top
rp181
Sat Jan 03 2009, 02:40PM
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
aonomus, thats what i do. For the 2nd one, it chooses randomly, but has a certain chance that its accepted. Succeessfull positions have moreof a chance.

The 1st one takes the highest ranked position, and uses Math.random to get to x,y coords. It gets 10*rank tries to get the random X,Y to the coords its on now, and it works its way down the ladder.

Yep, they are buggy, sometimes it gives you a free win, sometimes O a free win, but i cant figure out why =p. I did some more research and i found that Tic-Tac-Toe is a really bad game to try out neural networks because

1) such a limited playing board nothing to 'learn'
2) If playing the simple optimal strategy, its impossible to loose

Myke: It does add the winning move, but its gotta win twice to go up 1 rank, because it does Math.round((max[x][y] - min [x][y])/10), so the rounding makes it not 1 every time.

Rather than try Connect 4 next, i am going to try planning out and making one for GO. This one will have to be mor efficient coding. My tic tac toe program is ~ 1,000 lines of code (with alot of commenting) so its difficult to debug.
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.