I plan to reinvent the wheel. More exactly, I would like to set up a site where visitors can play Nim, both against each other and against a computer. Some such sites exist but I haven't seen one that allows both play against a computer and two person (and maybe three person) play. Also I would like to vary the rules some and give folks the option of the version that they wish to play. I am no longer young so I am hoping that I do not need to take too many programming courses for this.
Assume that I know very little about websites. I can do simple html and such. But I don't even know if I want Java, JavaScript, or something entirely different here.
Nim Examples:
Standard:
A person selects a starting position, say (7,5,4,2). Visualize four stacks of tokens having heights 7,5,4 and 2. The computer makes a move, meaning that one of the four heights is reduced. Say the computer removes 4 tokens from the pile of height 5. This gives heights (7,4,2,1). The live player makes his move, perhaps to (5,4,2,1). The computer removes the stack of height 2, getting heights (5,4,1,0). And so on, back and forth between the players. The person taking the last token wins.
Variant: A person may take tokens from either one or two stacks. Thus the computer, from the same beginning (7,5,4,2) , moves (7,5,4,2)-> (5,5,4,1) and so on. (Jonathan King showed me this variation).
There are many variants, including some where I don't understand the general algorithm for finding winning moves.
If you can point me in the right direction on how to do the programming w/o devoting my life to CS I would appreciate it. The math here is integer computation, I assume something like JavaScript has that built in. It's the interactive part that I am totally ignorant of.
In the back of my mind I have some thoughts of luring young people into mathematics with this. My eleven year old grandson was over yesterday and I might try him on some of these games. But my track record is not good. When my younger daughter was learning subtraction I made up a game. She liked games. When I got to the part of the rules that involved subtraction she announced in a loud voice "I'm not playing any stupid subtraction game" and stomped out of the room. Much to my admiring approval. Teach your parents well...
Page 1 of 1
Java? Or what? Teachnical advice sought
#2
Posted 2010-April-27, 15:19
The usual cheap hosting offers do not support server side java, forget about that.
If you do everything in Javascript, it will run on the client computer only. If there are more than one player they have to sit in front of the same computer. Another problem is that Javascript behaves different on different browsers, using the right libraries might help there.
If you want to target more than one player on different computer you need to run some part of it at a server. Most hosting packages offer PHP for that some have Perl and others too.
So I would suggest PHP. If your former programming experience is in C you might recognize a lot of the PHP syntax.
If you do everything in Javascript, it will run on the client computer only. If there are more than one player they have to sit in front of the same computer. Another problem is that Javascript behaves different on different browsers, using the right libraries might help there.
If you want to target more than one player on different computer you need to run some part of it at a server. Most hosting packages offer PHP for that some have Perl and others too.
So I would suggest PHP. If your former programming experience is in C you might recognize a lot of the PHP syntax.
#3
Posted 2010-May-02, 15:02
I've never done this kind of programming. I forwarded your post to Andrew Davison, author of Killer Game Programming in Java. His advice:
The MIT Scratch Project looks interesting. I see they have NIM already. But I don't see a multi-player version. Maybe Scratch does not support this.
As for your time budget, take your most conservative estimate, in hours, and multiply it by 8. You can use this technique for estimating do-it-yourself remodeling tasks too.
Quote
Since your colleague doesn't have much background in programming, he should start by finding some examples that come close to what he wants. Then he should start studying the language behind those examples, building towards his Nim application.
Nim is going to be quite a challenge because of the two-player networking involved. I suggest he start by writing a non-Web version, and some simpler Web-based applications first. He should browse through some textbooks for examples.
Nim is going to be quite a challenge because of the two-player networking involved. I suggest he start by writing a non-Web version, and some simpler Web-based applications first. He should browse through some textbooks for examples.
The MIT Scratch Project looks interesting. I see they have NIM already. But I don't see a multi-player version. Maybe Scratch does not support this.
As for your time budget, take your most conservative estimate, in hours, and multiply it by 8. You can use this technique for estimating do-it-yourself remodeling tasks too.
If you lose all hope, you can always find it again -- Richard Ford in The Sportswriter
#4
Posted 2010-May-02, 15:57
y66, on May 2 2010, 01:02 PM, said:
As for your time budget, take your most conservative estimate, in hours, and multiply it by 8. You can use this technique for estimating do-it-yourself remodeling tasks too.
The best estimating that I've seen for programming tasks in a full time job context is similar, but slightly more pessimistic, than what you suggest. Take your best conservative natural estimate. Double the number and increase the unit by 1 to show the calendar time to complete the task.
2 hours -> 4 days
2 days -> 4 weeks
1 week -> 2 months
Things like broken development/test environments, high priority bugs, checking email, meetings, design time, qa cycles, that last bug fix somehow rarely make it into even a developer's conservative estimate. I think it is because the developer remembers most clearly the time it takes to type the 100 lines of code to do the task at hand, not the time it took to figure out which 100 lines of code they were or where they belonged (and forgets about the other half-dozen 100 lines of code that existed at stages along the process) or that they were in fact the right 100 lines of code.
#5
Posted 2010-May-02, 16:31
Hey Mbodell that model actually fits my programming achievements quite well! I knew I was not at fault.
... and I can prove it with my usual, flawless logic.
George Carlin
George Carlin
#6
Posted 2010-May-03, 13:40
I thought I had replied and thanked you folks but I don't see it here. Anyway, thanks greatly. Maybe my note ended up on another thread.t
I went to the MIT scratch site. Very interesting. I first played Wizard Nim and then Mortimer's Nim which seems to allow for more variation. I found another site, http://education.jla.../nim/index.html at Jefferson Lab. This allows for two players but, as mentioned, they must both be at the same computer.
OK, maybe the two player at two computers version is a bit much for me, at least until I learn a lot more than I know now..
All three sites offer fairly basic versions. Wizard and Mortimer offer a three stack game [Added: also four or five stacks after you play a while] with small stacks. At each turn, any number of tokens can be removed from any one stack. Jefferson offers one stack with ten tokens. At each turn you remove one or two tokens. I am hoping that it will be possible to offer several stacks with decent heights and with various rules regarding removal of tokens. At various levels this gives: a game, an algorithm, a theorem, a research project.
I won't be doing this within the next week or the next month but I am pretty interested in trying to do it. We shall see.
Thanks again,
Ken
I went to the MIT scratch site. Very interesting. I first played Wizard Nim and then Mortimer's Nim which seems to allow for more variation. I found another site, http://education.jla.../nim/index.html at Jefferson Lab. This allows for two players but, as mentioned, they must both be at the same computer.
OK, maybe the two player at two computers version is a bit much for me, at least until I learn a lot more than I know now..
All three sites offer fairly basic versions. Wizard and Mortimer offer a three stack game [Added: also four or five stacks after you play a while] with small stacks. At each turn, any number of tokens can be removed from any one stack. Jefferson offers one stack with ten tokens. At each turn you remove one or two tokens. I am hoping that it will be possible to offer several stacks with decent heights and with various rules regarding removal of tokens. At various levels this gives: a game, an algorithm, a theorem, a research project.
I won't be doing this within the next week or the next month but I am pretty interested in trying to do it. We shall see.
Thanks again,
Ken
Ken
Page 1 of 1