Jump to content



Photo
- - - - -

Need Help With Tic Tac Toe Game - Probably Matrix Error

help matrix tic tac toe

  • Please log in to reply
6 replies to this topic

#1 Scott

Scott

    Newbie

  • Members
  • Pip
  • 16 posts
  • Gender:Male
  • Location:Wellington, New Zealand
  • Interests:I like programing.

  • Calculators:
    Cfx-9750 GA+ (AKA Cfx-9750 G+)
    Brain (a little faulty)
    Some one dollar piece of *****

Posted 21 September 2012 - 11:41 AM

OK I've decided to make a tic tac toe game for my fx-9750g+ using a matrix to store the positions, the only problem was that I didn't know how to use a matrix.

So far I've worked out that you can:

  • Set a matrix using {x,y}->Dim Mat A.
  • Use Mat A[2,3]->Z to get the value at 2 across, 3 down, stored under Z.
  • Set a number on the Matrix using x->Mat A[2,3]

My code I've got so far is basically as follows:
 

1->B ----- B determines whether its a O or X
{3,3}->Dim Mat A. ----- To set a 3x3 grid to store which squares have been taken.
Using F-lines to draw the grid on the screen
start loop
    If getkey=71 and Mat A[1,3]=0 ----- If key '1' is pressed and the according square is free:
        then 1->Mat A[1,3] ----- Change the matrix value to show that it is now taken
        B=1=>Circle (co-ordinates) ----- If it's 'O' turn then draw a circle
        B=2=>F-line to draw cross ----- If it's 'X' turn draw a cross
        3-B->B ----- Changing the turn e.g. Making B=2 if it previously equaled 1
    IfEnd ----- This is repeated for each of the keys 1->9
Endloop

I'm getting a Syntax error after the graph is drawn, so once the loop has started. I'm guessing it's to do with the matrix.

Any help would be much appreciated.



#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 21 September 2012 - 06:32 PM

Where does the cursor go after you exit from the error? That would show you where the problem is.

Also, you can use bbcode code tags for displaying code on the forums, like this:

<pre class='_prettyXprint _lang-auto _linenums:0'>
if blah then blahblah end
</pre>


#3 Scott

Scott

    Newbie

  • Members
  • Pip
  • 16 posts
  • Gender:Male
  • Location:Wellington, New Zealand
  • Interests:I like programing.

  • Calculators:
    Cfx-9750 GA+ (AKA Cfx-9750 G+)
    Brain (a little faulty)
    Some one dollar piece of *****

Posted 21 September 2012 - 09:06 PM

The cursor goes to the end of the loop. Thanks for the tip.

#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 21 September 2012 - 11:56 PM

You're welcome.

Are you sure you have all the proper IfEnds and WhileEnds are in the code?

#5 Scott

Scott

    Newbie

  • Members
  • Pip
  • 16 posts
  • Gender:Male
  • Location:Wellington, New Zealand
  • Interests:I like programing.

  • Calculators:
    Cfx-9750 GA+ (AKA Cfx-9750 G+)
    Brain (a little faulty)
    Some one dollar piece of *****

Posted 22 September 2012 - 03:30 AM

Ahh, found a missing Ifend. thanks for the help.

#6 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 23 September 2012 - 04:30 PM

You're welcome. Looking forward to seeing your tic-tac-toe game. :)

Also, most of the time if after a syntax error the cursor is at an IfEnd/WhileEnd or if it is at the very end of the program, it means you are missing an IfEnd or WhileEnd.

These little bits of knowledge make debugging much easier. ;)

#7 2MB26

2MB26

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    fx9750gii Casio Graphical Calculator

Posted 24 November 2016 - 06:46 PM

Hi, is there any way you could send me the skeleton code for your game? I've been struggling making my own for a while and am interested in how you did it. Sorry I'm new to this! XD





Also tagged with one or more of these keywords: help, matrix, tic tac toe

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users