ACCAPTSO / TicTacToe.js

Because, why not?
1 stars 0 forks source link

Let's make a plan #1

Open josefvin opened 10 years ago

josefvin commented 10 years ago

So, what are you thinking for the basic implementation? The first thing that comes to my mind would be some kind of table like structure, perhaps just laid out with a nested loop, and then menu driven options to make your next move.

If the opponent is the computer, it should try to connect three obviously, as one tactic. It's been a while since I played TTT, but as I recall there is a guaranteed more or less way to win if you start. I don't remember though, so a basic connect-three would be the easiest implementation to start with. Maybe there could be two difficulties: easy just tries to connect three, and hard tries to use more advanced tactics.

If you wanted to make it an online person-to-person game, that would be interesting, but above my level at the moment. It would be a good exercise though.

derekalvarado commented 10 years ago

I think I know what I'm talking about when I say that Javascript can detect when a user clicks on something, through an event listener. If we structured that table you're referencing by creating HTML divs with a height and width of, say, 25 pixes, we could use CSS to arrange them as a TTT board would be arrange, then the divs could detect when they've been clicked.

My mind usually jumps to more advanced implementations. What if we just had 2 input boxes where the user wants to place the next 'X' (ie. Row 1, Column 2) and a submit button. It'd be easy to take that information and insert an h1 X /h1 in the appropriate place.

There would have to be some sort of master record that keeps track of which boxes already have an X or O, and then something that detects end of game scenarios after each move.

josefvin commented 10 years ago

Your idea sounds better than mine. I've been in a console window mentality since I've been programming python and C++ with no GUI lately. I have however covered a lot of ground on JS and HTML/CSS in the past though, so it'll come back.

[Edit] JQuery might be a nice way to add some simple animation to the board without too much effort.

derekalvarado commented 10 years ago

here's a cool way of viewing any HTML file in the repo: Normally, you click the file and it takes you to a page where you can view the source code. If you click the "Raw" button, you'll end up at an address that looks like this:

https://raw.githubusercontent.com/ACCAPTSO/TicTacToe.js/master/GameBoard.html

Simply change the address to this: https://rawgit.com/ACCAPTSO/TicTacToe.js/master/GameBoard.html

and rawgit.com will render the HTML for you. Not sure if it will work when/if we move the Javascript to an external file.