
-----------------------------------
NovaK
Mon Feb 01, 2016 4:37 pm

tic tac to assignment help
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using



http://s000.tinyupload.com/index.php?file_id=14942235473859021802 if u wanna dload it thx for the help fyi this is for a school course im only posting here because my teacher has not emailed me back its been 2 weeks :(

-----------------------------------
Insectoid
Mon Feb 01, 2016 6:06 pm

RE:tic tac to assignment help
-----------------------------------
You've got a lot of code that does nothing here. Look at this loop. How many times will it execute?
[code]loop
        pmove := 0

        put "Where would you like to place your X 1 to 9"
        get x

        squares (x) := 1
        played (x) := 1
        pmove := 1
        exit when pmove = 1
        cls
    end loop[/code]

What is the played variable? Does it need to exist? Can you accomplish what you're trying to do with it without using it?


You have a lot of lines that look like this:[code]
 compmve := 1 
 exit when compmve = 1 [/code]

When will this ever return false? It won't. If a condition always returns true, then why have a condition at all?

Your AI checks if the player has played, for example, squares 1 and 2, and will select square 3 if he has. But if never checks if square 3 was already played, so on its next turn it will play that square again, so it looks like it doesn't do anything. 



I strongly suggest you break up your big loop into a few procedures. A draw procedure, that draws the board and all of the x's and o's, a player turn procedure that processes the player's input and an AI procedure that controls the AI, so your main loop just looks like this:
[code]loop
    drawBoard
    playerMove
    drawBoard
    checkWin
    AIMove
    drawBoard
   checkWin
end loop[/code]

This will make it much, much easier to read and debug.

-----------------------------------
NovaK
Wed Feb 03, 2016 3:00 pm

Re: tic tac to assignment help
-----------------------------------
Thanks for your reply i am using the played variable to tell if it is the computer that filled that spot or human so i know who to say wins and im putting it all into procedures and 1 big loop thx for the advice

-----------------------------------
Insectoid
Wed Feb 03, 2016 5:20 pm

RE:tic tac to assignment help
-----------------------------------
Doesn't the variable squares store who filled that spot?
