CharlieMay:- I ref you to the content in post 9
23 Replies - 2736 Views - Last Post: 18 March 2013 - 02:24 PM
#17
Re: Tic tac toe old project
Posted 18 March 2013 - 01:42 PM
AdamSpeight2008, on 18 March 2013 - 01:28 PM, said:
Stop thinking about vb.net code for moment, and think conceptually.
In my written example (in a prior) do you see any actual code?
For example create and define the definition you are going to use, for different aspects of the game.
In my written example (in a prior) do you see any actual code?
Spoiler
For example create and define the definition you are going to use, for different aspects of the game.
Spoiler
Yes, but how would i make it so i know there's no more winning lines? Like i have them all in a "Victory-True" case... not counting them all...(8) as you said. ( I think i'm not thinking wrong) Contradicted a little bit on that : D
IronRazer, on 18 March 2013 - 01:30 PM, said:
Sorry for butting in but, cant you just use an If ElseIf if you don`t want to change the way you have the game set up already and don`t want to use any more variables as you said in other posts ?
/>/>/>
If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
'If player wins it does this
ElseIf Count = 9 Then
'If Tie Game it does this
End If
Oh yes, I didn't think about that, don't use much ElseIf statements, but i do have to change them all... anyway thanks for the solution, though i maybe overthink this question and that's why i'm a little (or was until now) confused.
This post has been edited by HeBTeMy: 18 March 2013 - 01:43 PM
#18
Re: Tic tac toe old project
Posted 18 March 2013 - 01:49 PM
Quote
but i do have to change them all
And that is precisely on of the problems.
You should not be doing the same check in 9 different areas.
#19
Re: Tic tac toe old project
Posted 18 March 2013 - 01:49 PM
Why do need a Count? What is the definition of drawn game?
#20
Re: Tic tac toe old project
Posted 18 March 2013 - 01:54 PM
Quote
Oh yes, I didn't think about that, don't use much ElseIf statements, but i do have to change them all... anyway thanks for the solution, though i maybe overthink this question and that's why i'm a little (or was until now) confused.[/
They come in handy sometimes but, It will add a lot more code to the program. As you said you have 2000 lines and now you will have more because you will have to set all your buttons and whatever else in both cases. It would be worth thinking about putting some repeated commands in each button event in one Sub() and calling the sub from the If ElseIf statments.
This post has been edited by IronRazer: 18 March 2013 - 01:54 PM
#21
Re: Tic tac toe old project
Posted 18 March 2013 - 01:56 PM
Sorry IronRazer I don't agree with that. If anything those 9 buttons could call a single subroutine to determine the state of the game. Which also means, the handles could be combined since you don't really actually care what button is clicked at the time the routine is called. The only issue with combining the handles is that you would have to access the sender to determine what button was clicked for the X or O to be set to it.
This post has been edited by CharlieMay: 18 March 2013 - 01:58 PM
#22
Re: Tic tac toe old project
Posted 18 March 2013 - 01:59 PM
You shouldn't even be think about a gui yet, get the kernal of game logic sorted first.
#23
Re: Tic tac toe old project
Posted 18 March 2013 - 02:07 PM
#24
Re: Tic tac toe old project
Posted 18 March 2013 - 02:24 PM
Why it i better to have a separate kernel, independent of the GUI. I've written Tutorial Example:- Guessing Game (1 Game, 3 GUIS)
You'll see a console app, a winforms app and WPF app all use the same kernel code.
Start by doing it as a CONSOLE application so no fancy controls or forms.
This help you focus and think on the key parts of the design.
This is how way I start and experiment with code.
My Tic-Tac-Toe kernel (which just focused on controlling the game play) is ~68 LoC.
It could be even smaller <60LoC but I left some of the single methods in the aid readability of code.
You'll see a console app, a winforms app and WPF app all use the same kernel code.
Start by doing it as a CONSOLE application so no fancy controls or forms.
This help you focus and think on the key parts of the design.
This is how way I start and experiment with code.
My Tic-Tac-Toe kernel (which just focused on controlling the game play) is ~68 LoC.
It could be even smaller <60LoC but I left some of the single methods in the aid readability of code.
This post has been edited by AdamSpeight2008: 18 March 2013 - 02:30 PM
|
|

New Topic/Question
Reply





MultiQuote





|