Jump to content

Barney

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Barney

  1. 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
  2. Hi, I just upload a new version 2.0 to solve a problem, In version 1.0 when we reach an end position(either CPU or Player win) with two groups of "connect 4" pieces join together, the program just highlight one group, now both groups will be highlighted, and I change the search algorithm from MiniMax to NegaMax, it's a bit faster now.
  3. Thanks UEZ! Oh, a bug found?! I will try to fix it.
  4. Hi Chimp, nice play! If we play carefully, we have the chance to win. I set the $MAX_DEPTH to 4, If it's bigger then 4, it's slow ... the evaluation function is the key!
  5. Thanks aiter! If I can write a faster evaluation function then the AI can search the tree much deeper or write code to do Threat Analysis to make the AI much stronger.
  6. 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
  7. Hi smashly, Thanks for your help Long long time didn't write any programs and I am new to AutoIt too. Many things to learn
  8. <% ss = "one,two,three,four,five,six,seven,eight,nine" ds = "ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen," & _ "seventeen,eighteen,nineteen" ts = "twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety" qs = ",thousand,million,billion" Function nnn2words(iNum) a = split(ss,",") i = iNum mod 10 if i > 0 then s = a(i-1) ii = int(iNum mod 100)\10 if ii = 1 then s = split(ds,",")(i) elseif ((ii>1) and (ii<10)) then s = split(ts,",")(ii-2) & " " & s end if i = (iNum \ 100) mod 10 if i > 0 then s = a(i-1) & " hundred " & s nnn2words = s End Function Function num2words(iNum) i = iNum if i < 0 then b = true: i = i*-1 if i = 0 then s="zero" elseif i <= 2147483647 then a = split(qs,",") for j = 0 to 3 iii = i mod 1000 i = i \ 1000 if iii > 0 then s = nnn2words(iii) & _ " " & a(j) & " " & s next else s = "out of range value" end if if b then s = "negative " & s num2words = trim(s) End Function I tried but it didn't work ... $ss = "one,two,three,four,five,six,seven,eight,nine" $ds = "ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen" $ts = "twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety" $qs = ",thousand,million,billion" Func nnn2words($iNum) $a = StringSplit($ss, ",") $i = Mod($iNum, 10) If $i > 0 Then $s = $a($i - 1) EndIf $ii = int(Mod($iNum, 100)) / 10 If $ii = 1 Then $s = StringSplit($ds, ",")($i) ElseIf (($ii > 1) And ($ii < 10)) Then $s = StringSplit($ts, ",")($ii - 2) & " " & $s EndIf $i = Mod(($iNum / 100), 10) If $i > 0 Then $s = $a($i - 1) & " hundred " & $s $nnn2words = $s EndFunc Func num2words($iNum) $i = $iNum If $i < 0 Then $b = True $i = $i * -1 EndIf If $i = 0 Then $s = "zero" ElseIf $i <= 2147483647 Then $a = StringSplit($qs, ",") For $j = 0 to 3 $iii = Mod($i, 1000) $i = $i / 1000 If $iii > 0 Then $s = nnn2words($iii) & " " & $a($j) & " " & $s Next Else $s = "out of range value" EndIf If $b Then $s = "negative " & $s num2words = StringTrimLeft($s) EndFunc Thanks for your help!
×
×
  • Create New...