TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: pure client-side Connect Four AI with Web Workers, AngularJS, Firebase

39 点作者 hieu超过 11 年前

9 条评论

yareally超过 11 年前
Seeing this reminds me of a similar project I had to do as an undergrad, though nowhere as fun&#x2F;elegant as the submitter&#x27;s. Also nice to see web workers implemented for the AI as it&#x27;s a great usage example.<p>We were given the choice to alternatively implement a board game (pending approval) instead of taking a more formal final exam. The only catch was since it was a course focusing on Java, we had to use Swing (which if one has used Swing, the formal exam almost looks like the better option).<p>Figuring the game would be more fun, I ended up implementing connect four, thinking it would naively be easy enough to do the basics based on my previous GUI experience with Windows Forms and HTML&#x2F;CSS and add to it if I had time. Boy, was I wrong.<p>Writing the game engine&#x2F;logic was a great experience, but dealing with Swing took probably 70% of the time and had to ditch doing AI for a 2 player only approach. Just the quirky&#x2F;unintuitive nature of the Swing GUI builders in comparison to Visual Studio Windows GUI Forms made it easier to just write out the GUI by hand (which was not that much better). The issue of it isn&#x27;t even Swing itself causing headaches so much as the way the official Swing SDK written[1].<p>Code for it is on my Github still, but other than serving as a reference for anyone else (and warning in the readme), I think I would rather start over in a different language than contribute anymore to it :).<p>[1] A snippet of Qt Jambi and the same code written with the official Swing SDK (<a href="http://pastie.org/8324820" rel="nofollow">http:&#x2F;&#x2F;pastie.org&#x2F;8324820</a>)
chad_oliver超过 11 年前
Awesome work!<p>There&#x27;s a bug in the UI: placing a token should start the game in the same way as clicking &quot;OK, go&quot;. Currently, the game itself will work fine but the red arrows at the top don&#x27;t appear, and the text &quot;You will play first?&quot; doesn&#x27;t change.
mushishi超过 11 年前
Why was this posted again after one day? <a href="https://news.ycombinator.com/item?id=6376422" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6376422</a>
umutgultepe超过 11 年前
The AI is impressive, but it mostly fails when you just go for a horizontal four at the lowest row. I won 4 out of 3 games like that.<p>UI is good, gets the job done.
评论 #6385745 未加载
binofbread超过 11 年前
Very cool. Scanning the source code makes it look like you were using Alpha-Beta pruning[0], but I&#x27;m not totally sure why the function is named &#x27;pvs&#x27;. Does anyone have a quick explanation?<p>[0]: <a href="http://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Alpha%E2%80%93beta_pruning</a>
评论 #6384792 未加载
benatkin超过 11 年前
This game is not fun to play.<p>The graphics and the UI are solid. And apparently, the AI is also solid.<p>Good work. How about a human vs human version?
评论 #6384908 未加载
tedsanders超过 11 年前
Wow, great work. Does the AI play perfectly?<p>Edit: Looks like the answer is no, since I drew it while playing second. One option to improve the engine could be to give it an opening book (this is what they do with chess engines).
评论 #6384821 未加载
crystaln超过 11 年前
Filling in the first row from the center out beats the AI every time.... I&#x27;m sure the AI is a technical marvel - still needs some work though.
oakaz超过 11 年前
It&#x27;s quite strong. Thanks for creating this.