> On Sep 11, 2017, at 3:58 AM, Paul Moore <p.f.mo...@gmail.com> wrote:
> 
> I'm doing some training for a colleague on Python, and I want to look
> at a bit of object orientation. For that, I'm thinking of a small
> project to write a series of classes simulating objects moving round
> on a chess-style board of squares.
> 
> I want to concentrate on writing the classes and their behaviour, and
> not on display issues, but I would like it if the resulting program
> was reasonably interesting. To that end, I was thinking of putting
> together a frontend that displayed the objects moving round on a board
> (rather than, for example, just printing out lists of co-ordinates).
> I'd build the frontend, then my student could write the object classes
> and drop them into the framework.
> 
> My problem is that I've never written any sort of game code for
> Python, which is basically what this is. And I don't have a lot of
> time to develop something. So I was wondering - are there any
> ready-made examples of the sort of driver I'm thinking of? Something
> like a framework for a Chess or Othello game, but with the actual game
> logic isolated so I could easily rip it out and replace it with my
> own. I've done some searching around, but most of the examples I've
> seen seem to have the display and game logic intermingled (at least to
> my untrained eye).
> 
> Any suggestions? If not, I guess I'll just have to write my own. I'm
> sure I could - it's just that I don't want my training to be messed up
> because of bugs in my code...
> 
> Thanks,
> Paul
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I started something similar to this and didn't get far. I wrote a base class 
called Piece that had common attributes (I.e., color and position) and abstract 
methods (i.e., move). From the base class I derived all the piece types. That's 
the easy part.

The board is a bit tricky, depending on how you set it up. The board of 64 
squares could be a list, a dictionary or a class. I went with a Board class 
that used a coordinate system (i.e., bottom row first square was (0, 0) and top 
row last square (7, 7)) and kept track of everything on the board.

The furthest I got with this was a simple text display and interface to move 
pawns and bishops forward.

Chess may look straight forward but it can get complicated in a hurry. If you 
look at the computing literature, chess has been a never ending rabbit hole for 
50+ years. 

Chris R.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to