atrigent / ai Goto Github PK
View Code? Open in Web Editor NEWCode that I wrote in my AI class (CS 4100).
Code that I wrote in my AI class (CS 4100).
My tic-tac-toe game uses the minimax algorithm. It is capable of using the multiplayer formulation described in the textbook, with a vector of utilities at each node. It is slow to start up because it generates the entire game tree at the beginning. This allows gameplay to be smooth. Theoretically, this code could use more than two players or more than 3x3 boards. However, memory usage and CPU time limitations make that pretty impractical. For the simple 3x3 case, this program takes about 5 seconds to start on my machine and uses about 26MB of RAM. I have not gotten it to successfully generate the tree for a 4x4 game yet - it requires multiple gigabytes of RAM and multiple minutes of time at least. One thing that I added to the minimax algorithm was the concept of "distance" - how many turns will be required to reach a state. By including this information, it is possible to prefer paths that more quickly result in an endgame. I added this when I observed the AI making unintuitive moves when it could always win but when one win state would take more moves to get to than the other win state. It should prefer the one with fewer moves (for example, if it can win on the next move), but it was sometimes choosing the longer path. While this property could be interpreted as being "sadistic" and therefore possibly a desireable trait for an adversarial AI to have, I thought that it should try to favor fast games. I did not separate the AI algorithm kernels out of the rest of the game code, so in that sense it might not be as general as it could be. However, the algorithms are sufficiently simple that I don't think there would be much value to that. As I've said before, the algorithm can be used with any board size and any number of players. I thought about supporting non-square boards, but I ultimately decided against it. I don't think it would be very difficult to support though - the main difference would be that there are no diagonals. This code also implements all of the optimizations having to do with equivalent rotations and reflections of the game board. This allows the game tree to be as small as possible. It also stops expanding the game tree when a win or tie is encountered. Gameplay is simple - just enter your move by entering the coordinates. The game will figure it out, as long as there are two numbers in your input somewhere. As a bonus, you can also play this game by sshing to [email protected], password threeinarow. Again, this was written using Python 3.2. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.