librelist archives

« back to archive

tic-tac-toe game

tic-tac-toe game

From:
Jana Hechelmann
Date:
2014-02-05 @ 10:25
<html><head></head><body><div style="font-family: Verdana;font-size: 
12.0px;"><div style="font-family: Verdana;font-size: 12.0px;">
<div>Dear Shoes-Team,</div>

<div> </div>

<div>I am a student from Germany. My problem is, that I must programming a
Tic-Tac-Toe Game. The user plays against the computer. We have already a 
two-dimensional array...but now, we dont now, whats the next 
step? </div>

<div>How can I do a "X" or "O" in one domain of the 
array? How can I say, when the user want to click at a domain "The 
domain is already taken"? Please help me, I dont know what to do! Can
you send me the code or a little something else?</div>

<div> </div>

<div>Thank you so much,</div>

<div><br/>
Jana H.</div>
</div></div></body></html>

Re: [shoes] tic-tac-toe game

From:
Tobias Pfeiffer
Date:
2014-02-05 @ 12:16
Hi there,

a quick google turned up 2 shoes tic tac toe implementations:
* https://github.com/phpperu/tic-tac-toe
* https://github.com/bret/tictactoe

I'd still recommend you to build it yourself.  So first you need some 
kind of visual representation for Xs and Os.. you could go with 
standard text, images or graphics. Such as lines, or circles. I think 
for starters circles with different colors could be best.

I can recommend you to have a look at the shoes manual: 
http://shoesrb.com/manual/Hello.html and of course the amazing nobody 
knows shoes: http://cloud.github.com/downloads/shoes/shoes/nks.pdf (yes 
it is a programming book although it does not look like one)

Here are some docs on how to draw a circle: 
http://shoesrb.com/manual/Art.html#oval
How to get click events: 
http://shoesrb.com/manual/Events.html#click{|button,left,top|...}
You can also pass in a click event handler for elements on their 
creation (e.g. this one checks if the element itself has been clicked): 
http://shoesrb.com/manual/Styles.html#:click

The click handler could then decide, based on some state, whether or 
not this is a valid move right now.

And may I ask, which awesome university in Germany allows you to do 
stuff in shoes?

Cheers,
Tobi

On Wed 05 Feb 2014 11:25:07 AM CET, Jana Hechelmann wrote:
> <html><head></head><body><div style="font-family: Verdana;font-size: 
12.0px;"><div style="font-family: Verdana;font-size: 12.0px;">
> <div>Dear Shoes-Team,</div>
>
> <div> </div>
>
> <div>I am a student from Germany. My problem is, that I must programming
a Tic-Tac-Toe Game. The user plays against the computer. We have already a
two-dimensional array...but now, we dont now, whats the next 
step? </div>
>
> <div>How can I do a "X" or "O" in one domain of the 
array? How can I say, when the user want to click at a domain "The 
domain is already taken"? Please help me, I dont know what to do! Can
you send me the code or a little something else?</div>
>
> <div> </div>
>
> <div>Thank you so much,</div>
>
> <div><br/>
> Jana H.</div>
> </div></div></body></html>