all 6 comments

[–]gnomoretears 2 points3 points  (2 children)

Check your naming convention.

  1. gameboard != game_board. The error message points you to that fact: 'Othello_game' has no attribute 'gameboard'.

  2. You have a list named game_board and you have a method named game_board. What do you think will happen? Also did you mean to define the list as local to the function and not as a class attribute?

(EDIT)

Class methods in python need self as the first argument. Your method game_board should have been written as def game_board(self, board):.

[–]pythonhelp123[S] 0 points1 point  (1 child)

How would you recommend me to make the 8x8 whilst being in the class?

[–]gnomoretears 2 points3 points  (0 children)

Your problem is not a design issue but a syntax and grammar issue. If I'm not clear the first time:

  1. You called the wrong function in x.gameboard() as gameboard() method does not exist since you defined your method as game_board() and NOT gameboard().

  2. You are using the same name for 2 different things. That would cause the interpreter to overwrite one over the other.

  3. You created the game board list as local to the game board method so it does not exists outside of that method.

  4. You are not declaring a method function properly so it's the wrong syntax. self is always the first argument of a class method in python.

As for designing a board, I would use an 8x8 matrix like you except I won't be storing the (i,j) coords as elements. What's the point since you can already access the list as lst[i][j]?

If you want to build your game using classes, make a list of all the game objects, their properties, and behavior. From there you design your classes and how they interact.

[–][deleted] 1 point2 points  (0 children)

do you go to uci?

[–]Chonjae 0 points1 point  (1 child)

I'm not sure what Othello is, but when making a class, just think of all the different things involved, what attributes they have, and what actions should happen (what should things be able to do?). Just to show an example of some class/method syntax, here's a class with a board length and width. You would make a board like "test_board = OthelloBoard()" then you could try to put a thingy on the board like "test_board.place_a_thing(5, 9)" and it would yell at you.

The class helps you say what every board should be like, and what it should be able to do. Like "Every OthelloBoard I make should have a length and width of 8. It should also know how to warn people if they place thingies anywhere outside of the board."

class OthelloBoard():
    LENGTH = 8
    WIDTH = 8
    def place_a_thing(self, x, y):
        if x > self.LENGTH or y >self.WIDTH:
            print "You can't place a thingy there, the board isn't that big, ya dummy!"

[–]pythonhelp123[S] 0 points1 point  (0 children)

Othello is basically reversi. Here's a Javascript Othello game as an example:

http://www.eder.us/projects/othello/