diteix / lil-square-of-eight Goto Github PK
View Code? Open in Web Editor NEWGame made with Javascript
Home Page: https://diteix.github.io/lil-square-of-eight/
License: MIT License
Game made with Javascript
Home Page: https://diteix.github.io/lil-square-of-eight/
License: MIT License
For study and joy purposes, I would like to create some AI with Tensorflow.js that can play the game and even win.
The game is simple, each turn a player click a square side and it's marked with player color. The player who closes the square do a score and can keep going with his turn.
I've done some tests with Tensorflow.js and I didn't understood it at all. All I could do was verify if one square has a side that can be clicked and don't give the oportunity to the other player score, or do a score itself.
const model = tf.sequential();
model.add(tf.layers.dense({ units: 16, inputShape: [8] }));
model.add(tf.layers.dense({ units: 16, inputShape: [16], activation: 'sigmoid' }));
model.add(tf.layers.dense({ units: 1, inputShape: [16] }));
model.compile({ optimizer: tf.train.adam(0.1), loss: 'meanSquaredError', lr: 0.3 });
const xs1 = tf.tensor2d([
[0, 1, 1, 1, 2, 0, 3, 0], [0, 1, 1, 0, 2, 1, 3, 0], [0, 1, 1, 0, 2, 0, 3, 1], [0, 0, 1, 1, 2, 1, 3, 0], [0, 0, 1, 1, 2, 0, 3, 1], [0, 0, 1, 0, 2, 1, 3, 1],
[0, 1, 1, 1, 2, 1, 3, 1],
[0, 0, 1, 0, 2, 0, 3, 0], [0, 1, 1, 0, 2, 0, 3, 0], [0, 0, 1, 1, 2, 0, 3, 0], [0, 0, 1, 0, 2, 1, 3, 0], [0, 0, 1, 0, 2, 0, 3, 1],
[0, 0, 1, 1, 2, 1, 3, 1], [0, 1, 1, 0, 2, 1, 3, 1], [0, 1, 1, 1, 2, 0, 3, 1], [0, 1, 1, 1, 2, 1, 3, 0]]);
await model.fit(xs1, tf.tensor2d([[0], [0], [0], [0], [0], [0], [0], [1], [1], [1], [1], [1], [2], [2], [2], [2]]), {epochs: 550});
console.log(model.predict(tf.tensor2d([[0, 1, 1, 0, 2, 0, 3, 0]])));
I would like help in how I can create an AI with Tensorflow.js that can think and play my game in a smart way. It can learn with previuos games and start to play the game.
I've read the tutorials already and I think it lacks some explain about some things. Anyway, I could understand some concepts about Tensorflow.js and I've read some concepts about create game AI. I would like some information on how proceed with Tensorflow.js and tranpose the game mechanics in some way to train it in a way it can start play the game.
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.