Tic tac toe old project

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 12426 Views - Last Post: 18 March 2013 - 02:24 PM Rate Topic: -----

#16 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Tic tac toe old project

Posted 18 March 2013 - 01:39 PM

CharlieMay:- I ref you to the content in post 9
Was This Post Helpful? 0
  • +
  • -

#17 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Tic tac toe old project

Posted 18 March 2013 - 01:42 PM

View PostAdamSpeight2008, 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?
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

View PostIronRazer, 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 ? :unsure:/>/>/>
        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

Was This Post Helpful? 0
  • +
  • -

#18 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,919
  • Joined: 25-September 09

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.
Was This Post Helpful? 0
  • +
  • -

#19 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

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?
Was This Post Helpful? 0
  • +
  • -

#20 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 154
  • View blog
  • Posts: 570
  • Joined: 01-February 13

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. :bigsmile:/>

This post has been edited by IronRazer: 18 March 2013 - 01:54 PM

Was This Post Helpful? 0
  • +
  • -

#21 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,919
  • Joined: 25-September 09

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

Was This Post Helpful? 0
  • +
  • -

#22 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

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.
Was This Post Helpful? 0
  • +
  • -

#23 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Tic tac toe old project

Posted 18 March 2013 - 02:07 PM

View PostAdamSpeight2008, on 18 March 2013 - 01:59 PM, said:

You shouldn't even be think about a gui yet, get the kernal of game logic sorted first.


Could you explain? I didn't understand what you meant..
Was This Post Helpful? 0
  • +
  • -

#24 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

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.

This post has been edited by AdamSpeight2008: 18 March 2013 - 02:30 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2