Giter VIP home page Giter VIP logo

lil-square-of-eight's People

Contributors

diteix avatar igorrozani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

igorrozani

lil-square-of-eight's Issues

Develop game AI with Tensorflow.js

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.