data structures - I need help organizing/planning a C# Tic Tac Toe Application -


i'm university student has experience in c++ , new c#. wanted feedback how approach building c# form application 5x5 tic tac toe game.

the specifics of program require user enters time player make move choice. player selects whether or computer go first. player clicks start button game commence.

so far figured i'd created 'move' class x , y coordinate representing location on game grid, , 'player' class contains list of 'move' objects have made in game. planning on adding grid of clickable labels add move players list of moves. ai, think pretty easy create algorithm block human player completing row, i'm not sure data structure efficient this. perhaps i'm thinking wrong begin with.

any thoughts?

in ui, use 5 * 5 tablelayoutcontrol button in each cell. can set flatstyle these button flat look.

now, far maintaining model concerned, have single class represent players. this:

class player : inotifypropertychanged     {         list<point> _selectedcells = new list<point>();          public list<point> selectedcells         {                         {                 return _selectedcells;             }             set             {                 if (value != _selectedcells)                 {                     _selectedcells = value;                     raisepropertychange(new propertychangedeventargs("selectedcells"));                 }             }         }          public event propertychangedeventhandler propertychanged;          protected void raisepropertychange(propertychangedeventargs e)         {             if (propertychanged != null)             {                 propertychanged(this, e);             }         }     } 

now, there 2 instances of class. 1 human , 1 computer. on button click, can set selectedcells property. now, changing property raise propertychanged event. handler can placed checks victory.

if user has not won yet, generate computer move , set same property on computer instance. again check victory.

as , when user wins, can display appropriate message. can add string property name player class ease victory message display mechanism.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -