Recent submissions

Comment · 4 years ago
Step-by-step instructions on setting up an API endpoint running on AWS Lambda, storing data in DynamoDB, with a React static site hosted on S3.
Comment · 4 years ago
It's pretty cool for light work, but I imagine you would be better off doing native ES queries so when you need more complex queries, weighted searches, and optimizations, you will be in a better place to do that.
Comment · 4 years ago
Should be fixed now - an off by one error checking diagonals that hit the top of the board. Thanks!
Comment · 4 years ago
Yes, I may do a minimax version with a difficulty setting. That would be fun to do.
Comment · 4 years ago
Yes, I need a bug report button.
Comment · 4 years ago
With perfect play the first player will always win. My AI is not perfect and you can win as the second player.
Comment · 4 years ago
The computer AI code is in this file: http://flydaddy.net/games/connect-four/js/computerOpponent.j...

Basically when it’s the computer’s turn it evaluates every possible move and assigns an attack and defense value for each move. The attack value is based on how many in a row and whether it can win on next turn, and the defense value is how many opponent’s chips in a row and whether it will lose on opponent’s turn. And if 2 or more moves are equal, favor the move closest to the center of the board.

It's fairly difficult, but not perfect, and you can win as the second player.

Comment · 4 years ago
The computer AI code is in this file: http://flydaddy.net/games/connect-four/js/computerOpponent.j...

Basically when it’s the computer’s turn it evaluates every possible move and assigns an attack and defense value for each move. The attack value is based on how many in a row and whether it can win on next turn, and the defense value is how many opponent’s chips in a row and whether it will lose on opponent’s turn. And if 2 or more moves are equal, favor the move closest to the center of the board.

Comment · 4 years ago
Good idea. Done.
Comment · 4 years ago
Just a fun little project I did. It's beatable, but not easy.
Comment · 4 years ago
My first thought as well. Why even provide a response?
Comment · 4 years ago
ElasticSearch is not to be used as your primary data store. It's a search tool and you should have a process to rebuild an index from your primary data store.

Outside of that, I highly recommend using a managed service, either AWS ElasticSearch service, or Elastic.co to make recovery and management easy. AWS does a snapshot on every index every couple hours and it's relatively simple to restore a deleted index.

Also, I'm sure the author knows this now, but don't ever run any command on a live production data store without triple checking it.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton