the cursus i'm taking on python (free on internet).
said i know enough and that i should try creating some simple games like oxo.
the problem is that i don't know how the create a framework for such a game
any help is welcome.

mathijs

p.s. my english may not be that wel :)
(i'm from belguim)

i think so.
the goal is to get 3 x's or o's on one line to win

A good framework is to play against yourself and pay attention to what you do.

Then write a plan that describes your steps in general terms.

Then refine those steps until you have code.

Jeff

A good framework is to play against yourself and pay attention to what you do.

Jeff

i actually meant that a don't know how to create the gamefield: 9 squares
i think framework wasn't really the right term

You can just use a 2D array to do this

twoDarr = (("x", "x", "x"), ("x", "x", "x"), ("x", "x", "x"))

After you have the empty array set up you can write a function to print it nicely.

Also, you could just use a single dimension array and parse it accordingly.

I am just thinking about a basic text based tic-tac-toe, it could print the current state and then you could put in an (x,y) of where you wanna make your mark, if you were thinking of a gui driven kinda thing with a clickable interface, then thats a whole different game.

The fun part will be the "AI"

I am just thinking about a basic text based tic-tac-toe, it could print the current state and then you could put in an (x,y) of where you wanna make your mark

me to
i started writing the code today but i don't have that much time or a clue how to make the code
but i will try and post what i can come up with

thanks,
mathijs

i came up with this to print the field

list = [["-","-","-"],["-","-","-"],["-","-","-"]]
def printschema():
	for x in list:
		print x[0],x[1],x[2]
printschema()
o - -
- - x
- - -

lijst[1][1]="o"
printschema()
o - -
- o x
- - -

i put it into a list to be able to edit the content

tested the codes but there was a SyntaxError: invalid syntax (line 6)

i came up with this to print the field

list = [["-","-","-"],["-","-","-"],["-","-","-"]]
def printschema():
	for x in list:
		print x[0],x[1],x[2]
printschema()
o - -
- - x
- - -

lijst[1][1]="o"
printschema()
o - -
- o x
- - -

i put it into a list to be able to edit the content

Comments
This thread was 2 years old! Plus of course there weas a syntax error, half of that script was him writing (intened?) his output. You obviously know very little about Python.

None of 6,7,8,12,13,14 are valid python statements. Perhaps they are meant to show the output from the printschema statement? Perhaps they are meant to show new values for the list array?

Line 10 seems to have a typo.

Using 'list' for a variable name is bad practice, as it redefines the type 'list'

i came up with this to print the field

list = [["-","-","-"],["-","-","-"],["-","-","-"]]
def printschema():
	for x in list:
		print x[0],x[1],x[2]
printschema()
o - -
- - x
- - -

lijst[1][1]="o"
printschema()
o - -
- o x
- - -

i put it into a list to be able to edit the content

That's good there. My only suggestion would be to not use the identifier 'list' as it's a built-in python type.

>>> my_tup = (1,2,3,4,5)
>>> list(my_tup)
[1, 2, 3, 4, 5]
>>> help(list)
Help on class list in module __builtin__:

class list(object)
 |  list() -> new list
 |  list(sequence) -> new list initialized from sequence's items
 |  
 |  Methods defined here:
#.... Snipped for brevity... you get the point

This thread is really old. Now i would never use list as a variable name.
And the 6,7,8 ... are indeed samples of the output. I finished the game a long time ago. but thx for the help anyway

This question has already been answered. Start a new discussion instead.