August 23, 2009Javascript ReversiThere should be more Javascript games. Programming in Flash requires either bushwhacking through tools like MTASC or buying a commercial tool from Adobe. Javascript is more like BASIC on the Apple II or TRS 80: it is a programming language that comes with every computer, that any kid can learn. Here is Javascript Reversi, an exercise in a basic turn-based board game. The computer player limits itself using wall time, so the faster the Javascript interpreter, the stronger the play. On Chrome, the Javascript opponent can beat me (though I am a very poor player). If you know how to write a good reversi position-evaluation function that would make the computer stronger, please let me know. Posted by David at August 23, 2009 09:21 PMComments
Flash is tough, but personally, I don't typically view Javascript as being much better. I mean, the reversi example requires 500 lines, and the use of two separate, somewhat clunky models -- one fragile document model (HTML), one not-terribly-intuitive abstract OO model (Javascript). For most people, you need to dive into a serverside technology and database to make JS worth using. Not that it can't do neat stuff on its own, just that most people view things like AJAX as worth the price of admission. And that's skipping over the use of JQuery to make the language palatable. (Which isn't and shouldn't be a dealbreaker -- everyone's got their stdlib. But still.) I think my 8-year-old self would still take QBASIC over JS. I have hope that the additions to HTML 5 will make simple procedural graphics easier, and it might solve some of the quibbles I have. But it's still a lot harder to go from nothing to something you want to do a second iteration of -- something that looks "grown up" -- in JS. All this said, I think you're right -- there's no language except JS any more that's more or less an out-of-the-box experience. I want to say Ruby on OS X, maybe, but even it's a stretch. Graphics and "game" programming are bigger deals to someone first getting into writing code, and as it stands, I really can't think of a single language where this isn't a huge pain in the ass. Posted by: Josh at August 24, 2009 03:17 AMIn terms of lines of code, Javascript isn't that bad - here's an QBasic Othello for comparison - at 488 lines, it's about the same size. It is more straightforward but less ambitious. http://tinyurl.com/n7xlo8 Maybe the problem with Javascript isn't the lack of specific technology like procedural graphics or persistent state, but the lack of the ability to do blocking programming - the equivalent to QBasic's "INKEY" or "INPUT". Javascript forces you into event-based programming from the start, which seems like it requires more planning. On the other hand, my son is doing great things in Scratch, which is also an event model. Also, in Scratch, he almost never uses line-drawing graphics, preferring to just move sprites around the screen. I wonder if it would be possible to make a javascript library that would give Javascript a Scratch-like accessibility for kids. Hey David, I'm trying to write some js games too, http://stcamp.net/games/sudoku/ and I'm kind growing a js-library that supposed to help in this process. Maybe you will take a look when you have time http://rightjs.org it is much faster than jquery, has advanced OOP features, plus things like observers, options, Array#shuffle etc. Just thought you might be interested, please make a multiplayer version Posted by: mahen23 at February 10, 2011 04:52 AMBug Report : When both players have no moves left, the game should end. Instead, the white player passes and my only choice is to pass too... Posted by: Jan at February 13, 2011 07:09 PMThere should be a restart button. Posted by: Reverser at March 10, 2011 04:09 AMSometimes the computer just won't move. Posted by: Reverser at March 10, 2011 04:11 AMthe computer won't do the last move :S Posted by: chris at May 22, 2011 05:28 PMis there a way to make the game easier? would love to be able to NOT got first and see how a game ends? Posted by: at June 20, 2011 12:51 PMGame is too difficult & becomes boring after about 10goes. Posted by: at June 28, 2011 03:54 PMThis game should be EXACTLY like Othello. Posted by: evilshorty38 at July 11, 2011 09:01 AMthis game is kinda boring ur clock is messed up this game needs multiplayer Posted by: its 7:04 and ur clock says 9:03 at July 11, 2011 09:07 AMMULTIPLAYER NEEDED Posted by: at July 11, 2011 09:08 AMComputer and the player pass at same time. The game is too easy. you should add a difficulty option. Posted by: George at August 17, 2011 08:04 AMGuide to the perfect game (starting bottom left A to H vertical, 1 to 8 horizontal) c5, f3, f6, d4, f4, d6, f5, e2, d8, g8, d8, b8, f7, c7, h7, h5, h4, d1, h8, b6, a5, b4, g4, a8, a6, b2, a1, a2, a4, c2, g2, h3, g1, h1 Note : sometimes the computer reacts differently. try it 2-3 times you will get there... Posted by: George at August 20, 2011 04:22 PMNão consigo ganhar uma.. sou burro mesmo Posted by: at September 27, 2011 09:38 PMje n'arrive pas a gagnée !!! trop chiant ! This game is very hard for me and needs multiplay mode essentially, Posted by: K at October 24, 2011 10:51 AMThis game cheats. the "computer" made a move where only one should have flipped. there were 26 piece on the board. Then it flipped over an entire diagonal line and there were 28 pieces on the board. I am glad to know this because I spent far too much time trying to beat this thing. Now I can chalk it up to not working properly! Posted by: Nikki at October 24, 2011 08:36 PMhi Posted by: habin at October 31, 2011 08:45 AMThis game is way too hard... I have only gotten 1 corner so far in many tries. I used to beat this game all the time on my phone... I may not be the best player, but Id like to think I know the basics. Posted by: matt at November 1, 2011 03:21 PMReally easy. You should make it to consider some basic strategies. Check this site. I'm sure it would help you a lot to improve your AI. It also helped me a lot, too. :D Just a small bug I noticed, the game can't recognize a draw. Posted by: at November 4, 2011 08:07 PMrubbish Posted by: at November 7, 2011 12:42 PMgreat to find a version that is actually a challenge. All the others I've played are too easy. Posted by: at November 18, 2011 08:02 PMLove it, love it, love it. The game is wonderful. I did see some issues when there is a draw, although hitting reset just has it start over. It does have a mild game play which I would rate between 1 and 10, in a 7 for the hardest play. I play every reversi game I can find and beat 99% of them. So this was a bit refreshing. I would love to see a copy of the source code as I'm a fellow programmer and I stick to VB.net. Not that I want to copy your program, but simply to see the logic you use for the AI part. I've considered to make my own reversi game, but what I fail to see is how to capture my method of beating people/programs. All the best. ddddd Posted by: miriam at January 28, 2012 06:22 PMI LIKE THAT GAME. Posted by: andrew at February 3, 2012 04:19 PMthis reversi isnt hard Posted by: a pro at March 13, 2012 04:03 AMIt'd be nice to see the available moves, ideally labelled with a single character, so that you could play via keyboard. We did this at Acornsoft for the BBC micro back in 1983, so I'm sure you could do it now... Posted by: Spikey at March 18, 2012 08:23 PMIt'd be nice to see the available moves, ideally labelled with a single character, so that you could play via keyboard. We did this at Acornsoft for the BBC micro back in 1983, so I'm sure you could do it now... Posted by: Spikey at March 18, 2012 08:24 PMHere I found a truly strong version.. Try playing the various modes... :) Posted by: Hans at April 28, 2012 12:33 PMComputer and the player pass at same time. Played it once, won 60-4. Reading the various comments, it looks like multiple levels of strength would be a good thing to have. I wrote my own reversi program in Qbasic, a program which has three levels of play. It is faster and much stronger than this program. Posted by: Husker at May 19, 2012 12:11 AMPlease please make a multi-player version where I can play someone who is not as good as this computer. Posted by: Sethero at June 21, 2012 06:39 PMtoo simple AI... i scored 64:0 3 times out of 10 plays.. game gets boring after awhile. needs more options for gameplay. Posted by: at November 18, 2012 09:59 PMthis game is to hard you should include some difficulty settings Perfect score F5, C4, F4, C5, E3, C3, B4, E6, B3, A6, A2, A1, D1, B6, F1, B1, A8, E2, G1, B7, C8, D8, F8, E7, G6, G5, G8, H7, H8, H3, H2, H1, H4, H6 The game is too predictable and makes stupid decisions. Posted by: ABooth at March 11, 2013 05:07 PMThe game will stuck forever once 2 players cannot move Posted by: Kris at May 9, 2013 03:28 PMAbooth, you are wrong. i tried that. it stops working at F4. THE THIRD MOVE. impossible to win. computer wont make a move if you are on the brink of victory. Posted by: youarewrong at July 21, 2013 10:53 PM@youarewrong. Try it a couple of times. Occasionally it deviates after a half dozen moves, but 9 times out of 10, my pattern will work. Posted by: ABooth at August 29, 2013 05:46 PM@youarewrong: I think you must have the orientation wrong. A-H are the rows, as in across, as in horizontal, as in from left to right ..A B C D E F G H NO!!! Columns are vertical, Rows horizontal ............COL1..COL2..COL3..COL4..COL5..COL6..COL7..COL8 Sometimes after A6 it moves differently, but the majority of times, the pattern works. Posted by: ABooth at August 29, 2013 06:20 PMthere should be an option for difficulty level. I use to be a VERY good othello player but I can barely beat this. I wish I could opt to go second. Posted by: Dave at May 2, 2014 08:11 PMit appears you may have missed a programming check to determine a situation where both players must 'pass' for eternity. i can provide a screenshot showing the case upon request. thanks for a great game. Posted by: Spence at August 3, 2014 02:18 PMHello loved the website would you mind helping me create a reversi, maybe send me the js file of this or just contact me (Thxx (:) Posted by: Zohar at September 3, 2019 04:20 AMHello loved the website would you mind helping me create a reversi, maybe send me the js file of this or just contact me (Thxx (:) Posted by: Zohar at September 3, 2019 04:20 AMthis game is a slap on my ass. Post a comment
|
Copyright 2009 © David Bau. All Rights Reserved. |