Jump to content

Recommended Posts

  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted (edited)

Very nice billthecreator ;)

Can you replicate that please? (sequence of moves?)

I don't want to be rude but that situation is 99.99% impossible - the reason being the first of script's move.

The script first move is done depending on player's first move:

- if the player clicks any square EXCEPT the center one -> the script will always take the center

- if the player clicks the center square -> the script will always click the upper left square

You can see now why this situation about the player holding BOTH positions (center and upper left) is impossible.

here is the code snippet about script's first move:

Case $moves = 1 
                    If $grid[2][2] = 5 Then                     ;if player clicked "CENTER" [2][2] in a [3][3] grid
                        GUICtrlSetData ($button[1][1], "O")     ;the script will click upper left [1][1]
                        GUICtrlSetState ($button[1][1], $gui_disable)
                        GUICtrlSetData ($Label1, "Your Turn...")
                        $grid[1][1] = 1
                        $moves +=1
                        If $moves = 9 Then Return
                        $turn = True
                        Return
                    EndIf
                    If $grid[2][2] = 0 Then                     ;if CENTER is not taken by player
                        GUICtrlSetData ($button[2][2], "O")     ;script takes the CENTER
                        GUICtrlSetState ($button[2][2], $gui_disable)
                        GUICtrlSetData ($Label1, "Your Turn...")
                        $grid[2][2] = 1
                        $moves +=1
                        If $moves = 9 Then Return
                        $turn = True
                        Return
                    EndIf

Sorry - until not proven, I can't believe you did it. :D

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted (edited)

well, i read the script over and over, and just changed it, so i really didnt beat yours.... sorry, but it IS impossible. i thought it would be funny....

HA!

i changed where button[2][2] is button[2][3] then i beat it

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Posted (edited)

Hah! I was going to post another way of beating it, but it's fixed now ;) With the old code it was like this:

Posted Image

With the current code, this doesn't work.

Edited by Nahuel
Posted

Well I still keep the first one you posted. A friend kept insisting he could beat it so I showed it to him and he actually did beat it... but now I'll show him this new code.

Great seeing you. Haven't posted much... damn university and my poverty.

Posted

Tic Tac Toe sounded boring to me, so I slapped together a Rock Paper Scissors, that works a let better then I thought it would just throwing it together so quick

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#Include <GuiListView.au3>
#Include <GuiListBox.au3>
#include <ListboxConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#Include <File.au3>
#include <Inet.au3>
#Include <GuiButton.au3>
#Include <Misc.au3>


$comp = "Rock"
$compi = 0
$compi2 = 0
$compi3 = 0
GUICreate("Rock Paper Scissors", 150, 200)
$Prompt = GUICtrlCreateLabel("Are you ready?", 40, 30)
$start = GUICtrlCreateButton("Start!!", 50, 50, 50, 20)
$r = GUICtrlCreateButton("O", 20, 75, 30, 20)
$p = GUICtrlCreateButton("--", 60, 75, 30, 20)
$x = GUICtrlCreateButton("X", 100, 75, 30, 20)

GUISetState(@sw_show)
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $start
        $comptest = ($compi + $compi2)/$compi3
        If $comptest < -2 or $comptest = @error Then
            $comp = "Paper"
        ElseIf $comptest > 2 Then
            $comp = "Rock"
        ElseIf $comptest > -2 and $comptest < 2 Then
            $comp = "Scissors"
        EndIf
        
        GUICtrlSetData($prompt, "Ready!!")
        GUICtrlSetPos($Prompt, 55, 30)
        Sleep(2000)
        GUICtrlSetData($prompt, "Set!!")
        GUICtrlSetPos($Prompt, 65, 30)
        Sleep(3000)
        GUICtrlSetData($prompt, "Shot!!")
        GUICtrlSetPos($Prompt, 60, 30)
        $time = @SEC + 2
        Do
            $msg = GUIGetMsg()
        If $msg = $x Then
            GUICtrlCreateLabel("Player picked: Scissors", 20, 100)
            GUICtrlCreateLabel("Computer picked: " & $comp, 20, 130)
            Select
                Case $comp = "Rock"
                $compi = $compi - 1
                Case $comp = "Scissors"
                $compi = $compi - 2
                Case $comp = "Paper"
                $compi = $compi + 2
                Case $prev = "Rock"
                $compi2 = $compi2 - 1
                Case $prev = "Scissors"
                $compi2 = $compi2 - 2
                Case $prev = "Paper"
                $compi2 = $compi2 + 2
            EndSelect
            $compi3 = $compi3 - 1
            $prev = "Scissors"  
            
        ElseIf $msg = $p Then
            GUICtrlCreateLabel("Player picked: Paper   ", 20, 100)
            GUICtrlCreateLabel("Computer picked: " & $comp, 20, 130)
            Select
                Case $comp = "Rock"
                $compi = $compi - 1
                Case $comp = "Scissors"
                $compi = $compi - 2
                Case $comp = "Paper"
                $compi = $compi + 2
                Case $prev = "Rock"
                $compi2 = $compi2 + 1
                Case $prev = "Scissors"
                $compi2 = $compi2 + 2
                Case $prev = "Paper"
                $compi2 = $compi2 - 1
            EndSelect
            $compi3 = $compi3 + 1
            $prev = "Paper" 
            
        ElseIf $msg = $r Then
            GUICtrlCreateLabel("Player picked: Rock  ", 20, 100)
            GUICtrlCreateLabel("Computer picked: " & $comp, 20, 130)
            Select
                Case $comp = "Rock"
                $compi = $compi - 1
                Case $comp = "Scissors"
                $compi = $compi - 2
                Case $comp = "Paper"
                $compi = $compi + 2
                Case $prev = "Rock"
                $compi2 = $compi2 
                Case $prev = "Scissors"
                $compi2 = $compi2 + 1
                Case $prev = "Paper"
                $compi2 = $compi2 - 1
            EndSelect
            $compi3 = $compi3
            $prev = "Scissors"  
        ElseIf $time = @SEC Then
            MsgBox(0, "Time", "Times up")
        EndIf
        Until $msg = $x or $msg = $p or $msg = $r or $time = @SEC
        GUICtrlSetData($prompt, "Are you ready?")
            GUICtrlSetPos($prompt, 40,30)
        
    Case $msg = $gui_event_close
        Exit
    EndSelect
WEnd

Giggity

Posted

In my haste to create it, I made an error that actually makes it better. If you select Rock, it stores it as a Scissor selection, which makes it work better then if it saved the Rock selection as Rock. Guess I have to fix it and change my numbers some so when it does the math that it's better at guessing what your going to pick.

Giggity

  • 9 months later...
Posted

Apologies for bringing up a thread... oh 9months old... but im trying to learn how you did this... and im curious as to WHY there is this.. i mean what does the numbers signify

$content[1] = "31,32,33"
$content[2] = "21,22,23"
$content[3] = "11,12,13"
$content[4] = "11,22,33"
$content[5] = "11,21,31"
$content[6] = "12,22,32"
$content[7] = "13,23,33"
$content[8] = "13,22,31"

GREAT script BTW truely unbeatable but im trying to learn from it without much success

Posted

There are 8 possible winning lines in t-t-t. I guess those are the coordinates of those lines.

WBD

Posted

coordinates?... im not sure what you mean... and aren't these the 8 winnning lines?

Func string_eval()
    For $j=1 To 8
        $string_eval[$j] = 0
    Next
    For $j=1 To 3
        $string_eval[1] +=  $grid[3][$j]
        $string_eval[2] +=  $grid[2][$j]
        $string_eval[3] +=  $grid[1][$j]
        $string_eval[5] +=  $grid[$j][1]
        $string_eval[6] +=  $grid[$j][2]
        $string_eval[7] +=  $grid[$j][3]
    Next
    $string_eval[4] =  $grid[1][1]+$grid[2][2]+$grid[3][3]
    $string_eval[8] =  $grid[1][3]+$grid[2][2]+$grid[3][1]
EndFunc
Posted

coordinates?... im not sure what you mean...

$content[1] = "31,32,33"
$content[2] = "21,22,23"
$content[3] = "11,12,13"
$content[4] = "11,22,33"
$content[5] = "11,21,31"
$content[6] = "12,22,32"
$content[7] = "13,23,33"
$content[8] = "13,22,31"

If we have a 3x3 grid and we call the cells xy where x is the horizontal coordinate and y is the vertical one then the top left cell is 11 and the bottom right is 33. The array above then contains the 8 possible winning lines : (3,1)-(3,2)-(3,3) (2,1)-(2,2)-(2,3) ... up to (1,3)-(2,2)-(3,1)

WBD

Posted

If we have a 3x3 grid and we call the cells xy where x is the horizontal coordinate and y is the vertical one then the top left cell is 11 and the bottom right is 33. The array above then contains the 8 possible winning lines : (3,1)-(3,2)-(3,3) (2,1)-(2,2)-(2,3) ... up to (1,3)-(2,2)-(3,1)

WBD

uhh, that makes more sense thanks... :) one problem down.. now an undetermined amount more haha

Posted (edited)

@CodyBarrett

Consider this:

. 1 2 3

1 x x x

2 x x x

3 x x x

and as WideBoyDixon these are coordinates: every element of the table can be identified as 11, 23 ...

Here is the way I did the evaluation: I've started by assigning a 0 value to every square (at the begining; a value of 0 means that the square is "empty")

If the player moves to that square its value will be 1 while if the computer moves there its value will be 5.

Next I have considered 8 possible "lines" ($content[1] to $content[8]); all other "possible lines" are only mirror images of these.

In order to have the value of these lines, all I needed is to add the value of the squares.

- If a line has a value of 0 then that whole line was empty

- If the value was 2 then the player has 2 positions on that line with the third square empty => a possible player win situation => need to block that

- If the value was 10 then the computer has 2 positions on that libne with the third square empty => a possible computer win situation => need to play there to win

- a value of 6 shows that both the player and the computer played that line

... and so on ...

That is the meaning of $string_eval -> stores the "line value" at any time.

@Godly

Sorry but the screenshot doesn't prove anything if you're not able to show your "winning" sequence. :party:

After a brief look over your screenshot I found the way you cheated :)

Have a look at the picture attached :idea:

post-18882-1243813642_thumb.jpg

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted

yeah haha enaiman i already figured that out... BTW im curious how long from sitting down... to posting the code, did it take you to write this.... im amazed at how efficient this is

and im not sure but the last 4 or so IF statements in the script are pretty much repetitive except with 1 or 2 different numbers in it... isn't there a way to clean this up and have like ONE if statement and use math formula?

im thinking MAYBE its possible if you make all the coords and values divible by 2? or 5? im not sure

and Godly i KNEW something was up.. because no matter how many times i tried i couldn't replicate your picture

Posted (edited)

It didn't take too long to write the code, maybe half a day ...

I did a little bit of "tunning" afterwards, when someone found a way to beat it (that's the reason behind these "IF statements" as you called them); actually it looks more like "patching" than "tunning" :idea:

The code is still in raw form; I didn't work on it anymore (not enough time for that). I know I can make it more efficient and shorter and cleaner ... just waiting for the time to do it :)

My favorite is still the one WideBoyDixon posted in your thread :party:

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Posted

right... sorry WBD i got caught up in enaimans script... ima gonna loook into that one now :)

and BTW this thread isn't dialup friendly haha takes 5+ mins to load on mine

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...