SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
with PHP on a
Symfony Console
TicTacToe game
Artificial
Neural
Networks
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Agenda
1. Demo
2. Symfony Console
3. ANN Theory
4. PHP + FANN
5. Show me the code
6. Demo
7. Q&A
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Demo
vs.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Symfony Console
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Symfony Console - Installation
$~> composer require symfony/console
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Symfony Console - Usage
#!/usr/bin/env php
<?php
require __DIR__ . ‘/../vendor/autoload.php';
use SymfonyComponentConsoleApplication;
$app = new Application();
$app->run();
bin/console
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Symfony Console - Usage
#!/usr/bin/env php
<?php
require __DIR__ . ‘/../vendor/autoload.php';
use SymfonyComponentConsoleApplication;
$app = new Application();
$app->run();
bin/console
$ chmod +x bin/console
$ bin/console
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Symfony Console - Usage
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Symfony console style guide
https://github.com/symfony/symfony-docs/issues/4265
Created by @javiereguiluz
Improved by Symfony community
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Symfony Console - Helpers
Progress bar
Table
Question
Formatter
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
<?php
// create a new progress bar (10 units)
$progress = new ProgressBar($output, 10);
// start and displays the progress bar
$progress->start();
$i = 0;
while ($i++ < 10) {
// ... do some work
// advance the progress bar 1 unit
$progress->advance();
}
// ensure that the progress bar is at 100%
$progress->finish();
Command.php
Progress bar
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Table
<?php
$table = new Table($output);
$table
->setHeaders(array('Component', 'Package'))
->setRows(array(
array('Console', 'symfony/console'),
array('Form', 'symfony/form'),
array('Finder', 'symfony/finder'),
array('Config', 'symfony/config'),
array('...', '...'),
))
;
$table->render();
Command.php
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Question
<?php
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion(
'Do you want to play again? ',
false
);
if (!$helper->ask($input, $output, $question)) {
$output->writeln("Bye bye!");
return;
}
$output->writeln("Let's play again!");
Command.php
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Formatter
<?php
$formatter = $this->getHelper('formatter');
$formattedLine = $formatter->formatSection(
'Game finished',
'Player one wins.'
);
$output->writeln($formattedLine);
$errorMessages = array(
'Error!',
'Move already done.’
);
$formattedBlock = $formatter
->formatBlock($errorMessages, 'error');
$output->writeln($formattedBlock);
Command.php
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Helper helpers
$~> composer require phpgames/board-helper
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Board
<?php
// Board example usage
$board = new Board(
$output,
$this->getApplication()
->getTerminalDimensions(),
3, // Board size
false // Don’t override the screen
);
// Update and display the board status
$board->updateGame(0,0,1);
Command.php
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Board
<?php
// Board example - four in a row
$board = new BoardHelper(
$output,
$this->getApplication()
->getTerminalDimensions(),
4, // Board size
false // Don’t override screen
true // Board with backgrounded cells
);
// Update the board status (Player 1)
$board->updateGame(0,0,1);
// Update the board status (Player 2)
$board->updateGame(0,1,2);
Command.php
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Board
<?php
// Example TicTacToe with overwrite
$board = new TicTacToeHelper(
$output,
$this->getApplication()
->getTerminalDimensions(),
3, // Board size
true // Overwrite screen
);
// Update the board status and display
$board->updateGame(1,1,1);
$board->updateGame(0,0,2);
$board->updateGame(2,0,1);
$board->updateGame(0,2,2);
$board->updateGame(0,1,1);
$board->updateGame(2,1,2);
$board->updateGame(1,0,1);
$board->updateGame(1,2,2);
$board->updateGame(2,2,1);
Command.php
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Board
<?php
namespace PHPGamesConsoleHelper;
class Board
{
/**
* @var SymfonyComponentConsoleOutputOutputInterface
*/
private $output;
/**
* Clears the output buffer
*/
private function clear()
{
$this->output->write("e[2J");
}
// ...
Board.php
Instruction that
clears the
screen
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
There is a bonus helper
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Symfony Console - HAL
<?php
$hal = new HAL($output);
$hal->sayHello();
Command.php
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Computer model that intends to simulate how the brain works
Artificial
Neural
Networks
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Input neuron
A typical ANN
Hidden neuron
Output neuron
Signal & weight
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Activation Functions
Functions to process the input and produce a signal as output
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Activation Functions
• Step - output is 0 or 1
• Linear Combination - output is input sum plus
a linear bias
• Continuous Log-Sigmoid
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Activation Functions
• Step - output is 0 or 1
• Linear Combination - output is input sum plus
a linear bias
• Continuous Log-Sigmoid
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Activation Functions
• Step - output is 0 or 1
• Linear Combination - output is input sum plus
a linear bias
• Continuous Log-Sigmoid
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Backpropagation
Backward propagation of errors
Passes error signals backwards through the network during training to update the weights of the network
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN Types
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN types
• Feedforward neural network
Information goes only in one direction, forward.
• Radial basis function network (RBF)
Interpolation in multidimensional space.
• Kohonen self-organizing network
A set of artificial neurons learn to map points in an input space to
coordinates in an output space.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN types
• Feedforward neural network
Information goes only in one direction, forward.
• Radial basis function network (RBF)
Interpolation in multidimensional space.
• Kohonen self-organizing network
A set of artificial neurons learn to map points in an input space to
coordinates in an output space.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN types
• Feedforward neural network
Information goes only in one direction, forward.
• Radial basis function network (RBF)
Interpolation in multidimensional space.
• Kohonen self-organizing network
A set of artificial neurons learn to map points in an input space to
coordinates in an output space.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN Learning
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN Learning
• Supervised
• Unsupervised
• Reinforcement
• Supervised
• Unsupervised
• Reinforcement
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN Learning
• Supervised
• Unsupervised
• Reinforcement
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
ANN Learning
• Supervised
• Unsupervised
• Reinforcement
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
With some slights adaptations to solve
We've used
Reinforcement Learning
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Temporal Credit Assignment
Problem
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
A word on Game Theory
and
Tic Tac Toe
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Don’t desperate, we are almost
there.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Tic Tac Toe
• Perfect Information
• Deterministic
• Complete
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Tic Tac Toe
• Perfect Information
• Deterministic
• Complete
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Tic Tac Toe
• Perfect Information
• Deterministic
• Complete
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
If you want to have a challenging Tic Tac Toe game
MiniMax
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
(WTF) ANN with
Artificial Neural Networks with PHP
What The
Fann
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Meet libfann & PECL fann
$~> sudo apt-get install libfann; sudo pecl install fann
(WTF) ANN with
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Enjoy!
(WTF) ANN with
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Show me the code!
(WTF) ANN with
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Demo
vs.
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
The two neurons behind this talk
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Ariel Ferrandini
• Symfony simple password encoder
service. (Symfony >=2.6).
• Symfony DX application
collaborator.
• PHPMad UG co-founder.
• Senior Backend Developer @
Lighthouse Guidance Systems Ltd.
@aferrandini
DPCon 2015Artificial Neural Networks
on a Tic Tac Toe
console application
Eduardo Gulias
• EmailValidator
(Symfony >= 2.5, Drupal 8,
Swiftmailer 6 & others).
• ListenersDebugCommandBundle
(ezPublish 5).
• PHPMad UG co-founder
(Former Symfony Madrid).
• Team leader at
@egulias
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Resources
• Wikipedia (http://en.wikipedia.org/wiki/Artificial_neural_network)
• Introduction for beginners (http://arxiv.org/pdf/cs/0308031.pdf)
• Introduction to ANN (http://www.theprojectspot.com/tutorial-
post/introduction-to-artificial-neural-networks-part-1/7)
• Reinforcement learning (http://www.willamette.
edu/~gorr/classes/cs449/Reinforcement/reinforcement0.html)
• PHP FANN (http://www.php.net/fann)
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Resources
• Repo PHPGames (https://github.com/phpgames/ANNTicTacToe)
• Repo Board helper (https://github.com/phpgames/BoardHelper)
• Repo HAL helper (https://github.com/phpgames/HALHelper)
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Thank you!
https://joind.in/14212
Artificial Neural Networks
on a Tic Tac Toe
console application
DPCon 2015
Questions?
https://joind.in/14212

Contenu connexe

En vedette

Indonesia infographic
Indonesia infographicIndonesia infographic
Indonesia infographicAsia Matters
 
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal..."Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...Asia Matters
 
Jun arima Jetro - Asia Business Week Dublin
Jun arima   Jetro - Asia Business Week DublinJun arima   Jetro - Asia Business Week Dublin
Jun arima Jetro - Asia Business Week DublinAsia Matters
 
DUJAT Company presentation
DUJAT Company presentationDUJAT Company presentation
DUJAT Company presentationRangemu
 
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...Rangemu
 
Abenomics - The Saviour of Japan.
Abenomics - The Saviour of Japan.Abenomics - The Saviour of Japan.
Abenomics - The Saviour of Japan.Archit Sharma
 
International business ppt1
International business ppt1International business ppt1
International business ppt1Nirmala Yadav
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging ChallengesAaron Irizarry
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 
Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)spartacus131211
 
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...aferrandini
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural networkDEEPASHRI HK
 

En vedette (19)

Indonesia infographic
Indonesia infographicIndonesia infographic
Indonesia infographic
 
ASEAN infographic
ASEAN infographicASEAN infographic
ASEAN infographic
 
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal..."Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...
"Ireland’s Competitive Edge Through Innovation in the AgriFood Sector" Cathal...
 
Jun arima Jetro - Asia Business Week Dublin
Jun arima   Jetro - Asia Business Week DublinJun arima   Jetro - Asia Business Week Dublin
Jun arima Jetro - Asia Business Week Dublin
 
Public Lecture PPT (6.6.2012)
Public Lecture PPT (6.6.2012)Public Lecture PPT (6.6.2012)
Public Lecture PPT (6.6.2012)
 
DUJAT Company presentation
DUJAT Company presentationDUJAT Company presentation
DUJAT Company presentation
 
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...
Japanese Economic Trends and JETRO's Activities to Attract Foreign Direct Inv...
 
Abenomics - The Saviour of Japan.
Abenomics - The Saviour of Japan.Abenomics - The Saviour of Japan.
Abenomics - The Saviour of Japan.
 
Japan's Abenomics
Japan's AbenomicsJapan's Abenomics
Japan's Abenomics
 
International business ppt1
International business ppt1International business ppt1
International business ppt1
 
Globalization
GlobalizationGlobalization
Globalization
 
Globalisation ppt 2
Globalisation ppt 2Globalisation ppt 2
Globalisation ppt 2
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)
 
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
Artificial Neural Network in a Tic Tac Toe Symfony Console Application - Symf...
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 

Similaire à Artificial Neural Networks on a Tic Tac Toe console application

Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOKris Findlay
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi boardThierry Gayet
 
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7Rapid7
 
Building your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiJeff Prestes
 
Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Cisco DevNet
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnelukdpe
 
Introduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendIntroduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendJoseluis Laso
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Daniel Luxemburg
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspectivekfrdbs
 
Shift-left SRE: Self-healing on OpenShift with Ansible
Shift-left SRE: Self-healing on OpenShift with AnsibleShift-left SRE: Self-healing on OpenShift with Ansible
Shift-left SRE: Self-healing on OpenShift with AnsibleJürgen Etzlstorfer
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Puppet
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Pythonpycontw
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorialSalah Amean
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoBrian Huang
 
Artificial Neural Networks with PHP & Symfony con 2014
Artificial Neural Networks with PHP & Symfony con 2014Artificial Neural Networks with PHP & Symfony con 2014
Artificial Neural Networks with PHP & Symfony con 2014Eduardo Gulias Davis
 
Lesson 2.5 Mobile Apps and Mobile Devices.pptx
Lesson 2.5 Mobile Apps and Mobile Devices.pptxLesson 2.5 Mobile Apps and Mobile Devices.pptx
Lesson 2.5 Mobile Apps and Mobile Devices.pptxTarOgre
 
Zen alert - Why You Need and How It Works
Zen alert - Why You Need and How It WorksZen alert - Why You Need and How It Works
Zen alert - Why You Need and How It WorksZenAlert
 

Similaire à Artificial Neural Networks on a Tic Tac Toe console application (20)

Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
Survey_Paper
Survey_PaperSurvey_Paper
Survey_Paper
 
Lecture11
Lecture11Lecture11
Lecture11
 
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
 
Building your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry Pi
 
Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!Automating with NX-OS: Let's Get Started!
Automating with NX-OS: Let's Get Started!
 
Pc54
Pc54Pc54
Pc54
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnel
 
Introduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backendIntroduction to Titanium and how to connect with a PHP backend
Introduction to Titanium and how to connect with a PHP backend
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspective
 
Shift-left SRE: Self-healing on OpenShift with Ansible
Shift-left SRE: Self-healing on OpenShift with AnsibleShift-left SRE: Self-healing on OpenShift with Ansible
Shift-left SRE: Self-healing on OpenShift with Ansible
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorial
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
 
Artificial Neural Networks with PHP & Symfony con 2014
Artificial Neural Networks with PHP & Symfony con 2014Artificial Neural Networks with PHP & Symfony con 2014
Artificial Neural Networks with PHP & Symfony con 2014
 
Lesson 2.5 Mobile Apps and Mobile Devices.pptx
Lesson 2.5 Mobile Apps and Mobile Devices.pptxLesson 2.5 Mobile Apps and Mobile Devices.pptx
Lesson 2.5 Mobile Apps and Mobile Devices.pptx
 
Zen alert - Why You Need and How It Works
Zen alert - Why You Need and How It WorksZen alert - Why You Need and How It Works
Zen alert - Why You Need and How It Works
 

Dernier

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Dernier (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Artificial Neural Networks on a Tic Tac Toe console application

  • 1. with PHP on a Symfony Console TicTacToe game Artificial Neural Networks
  • 2. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Agenda 1. Demo 2. Symfony Console 3. ANN Theory 4. PHP + FANN 5. Show me the code 6. Demo 7. Q&A
  • 3. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Demo vs.
  • 4. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Symfony Console
  • 5. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Symfony Console - Installation $~> composer require symfony/console
  • 6. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Symfony Console - Usage #!/usr/bin/env php <?php require __DIR__ . ‘/../vendor/autoload.php'; use SymfonyComponentConsoleApplication; $app = new Application(); $app->run(); bin/console
  • 7. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Symfony Console - Usage #!/usr/bin/env php <?php require __DIR__ . ‘/../vendor/autoload.php'; use SymfonyComponentConsoleApplication; $app = new Application(); $app->run(); bin/console $ chmod +x bin/console $ bin/console
  • 8. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Symfony Console - Usage
  • 9. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Symfony console style guide https://github.com/symfony/symfony-docs/issues/4265 Created by @javiereguiluz Improved by Symfony community
  • 10. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Symfony Console - Helpers Progress bar Table Question Formatter
  • 11. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application <?php // create a new progress bar (10 units) $progress = new ProgressBar($output, 10); // start and displays the progress bar $progress->start(); $i = 0; while ($i++ < 10) { // ... do some work // advance the progress bar 1 unit $progress->advance(); } // ensure that the progress bar is at 100% $progress->finish(); Command.php Progress bar
  • 12. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Table <?php $table = new Table($output); $table ->setHeaders(array('Component', 'Package')) ->setRows(array( array('Console', 'symfony/console'), array('Form', 'symfony/form'), array('Finder', 'symfony/finder'), array('Config', 'symfony/config'), array('...', '...'), )) ; $table->render(); Command.php
  • 13. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Question <?php $helper = $this->getHelper('question'); $question = new ConfirmationQuestion( 'Do you want to play again? ', false ); if (!$helper->ask($input, $output, $question)) { $output->writeln("Bye bye!"); return; } $output->writeln("Let's play again!"); Command.php
  • 14. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Formatter <?php $formatter = $this->getHelper('formatter'); $formattedLine = $formatter->formatSection( 'Game finished', 'Player one wins.' ); $output->writeln($formattedLine); $errorMessages = array( 'Error!', 'Move already done.’ ); $formattedBlock = $formatter ->formatBlock($errorMessages, 'error'); $output->writeln($formattedBlock); Command.php
  • 15. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Helper helpers $~> composer require phpgames/board-helper
  • 16. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Board <?php // Board example usage $board = new Board( $output, $this->getApplication() ->getTerminalDimensions(), 3, // Board size false // Don’t override the screen ); // Update and display the board status $board->updateGame(0,0,1); Command.php
  • 17. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Board <?php // Board example - four in a row $board = new BoardHelper( $output, $this->getApplication() ->getTerminalDimensions(), 4, // Board size false // Don’t override screen true // Board with backgrounded cells ); // Update the board status (Player 1) $board->updateGame(0,0,1); // Update the board status (Player 2) $board->updateGame(0,1,2); Command.php
  • 18. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Board <?php // Example TicTacToe with overwrite $board = new TicTacToeHelper( $output, $this->getApplication() ->getTerminalDimensions(), 3, // Board size true // Overwrite screen ); // Update the board status and display $board->updateGame(1,1,1); $board->updateGame(0,0,2); $board->updateGame(2,0,1); $board->updateGame(0,2,2); $board->updateGame(0,1,1); $board->updateGame(2,1,2); $board->updateGame(1,0,1); $board->updateGame(1,2,2); $board->updateGame(2,2,1); Command.php
  • 19. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Board <?php namespace PHPGamesConsoleHelper; class Board { /** * @var SymfonyComponentConsoleOutputOutputInterface */ private $output; /** * Clears the output buffer */ private function clear() { $this->output->write("e[2J"); } // ... Board.php Instruction that clears the screen
  • 20. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 There is a bonus helper
  • 21. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Symfony Console - HAL <?php $hal = new HAL($output); $hal->sayHello(); Command.php
  • 22. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Computer model that intends to simulate how the brain works Artificial Neural Networks
  • 23. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Input neuron A typical ANN Hidden neuron Output neuron Signal & weight
  • 24. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Activation Functions Functions to process the input and produce a signal as output
  • 25. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 26. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 27. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 28. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Backpropagation Backward propagation of errors Passes error signals backwards through the network during training to update the weights of the network
  • 29. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN Types
  • 30. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 31. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 32. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 33. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN Learning
  • 34. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN Learning • Supervised • Unsupervised • Reinforcement • Supervised • Unsupervised • Reinforcement
  • 35. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN Learning • Supervised • Unsupervised • Reinforcement
  • 36. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 ANN Learning • Supervised • Unsupervised • Reinforcement
  • 37. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 With some slights adaptations to solve We've used Reinforcement Learning
  • 38. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Temporal Credit Assignment Problem
  • 39. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 A word on Game Theory and Tic Tac Toe
  • 40. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Don’t desperate, we are almost there.
  • 41. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Tic Tac Toe • Perfect Information • Deterministic • Complete
  • 42. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Tic Tac Toe • Perfect Information • Deterministic • Complete
  • 43. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Tic Tac Toe • Perfect Information • Deterministic • Complete
  • 44. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 If you want to have a challenging Tic Tac Toe game MiniMax
  • 45. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 (WTF) ANN with Artificial Neural Networks with PHP What The Fann
  • 46. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015
  • 47. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Meet libfann & PECL fann $~> sudo apt-get install libfann; sudo pecl install fann (WTF) ANN with
  • 48. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Enjoy! (WTF) ANN with
  • 49. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Show me the code! (WTF) ANN with
  • 50. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Demo vs.
  • 51. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015
  • 52. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 The two neurons behind this talk
  • 53. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Ariel Ferrandini • Symfony simple password encoder service. (Symfony >=2.6). • Symfony DX application collaborator. • PHPMad UG co-founder. • Senior Backend Developer @ Lighthouse Guidance Systems Ltd. @aferrandini
  • 54. DPCon 2015Artificial Neural Networks on a Tic Tac Toe console application Eduardo Gulias • EmailValidator (Symfony >= 2.5, Drupal 8, Swiftmailer 6 & others). • ListenersDebugCommandBundle (ezPublish 5). • PHPMad UG co-founder (Former Symfony Madrid). • Team leader at @egulias
  • 55. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Resources • Wikipedia (http://en.wikipedia.org/wiki/Artificial_neural_network) • Introduction for beginners (http://arxiv.org/pdf/cs/0308031.pdf) • Introduction to ANN (http://www.theprojectspot.com/tutorial- post/introduction-to-artificial-neural-networks-part-1/7) • Reinforcement learning (http://www.willamette. edu/~gorr/classes/cs449/Reinforcement/reinforcement0.html) • PHP FANN (http://www.php.net/fann)
  • 56. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Resources • Repo PHPGames (https://github.com/phpgames/ANNTicTacToe) • Repo Board helper (https://github.com/phpgames/BoardHelper) • Repo HAL helper (https://github.com/phpgames/HALHelper)
  • 57. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Thank you! https://joind.in/14212
  • 58. Artificial Neural Networks on a Tic Tac Toe console application DPCon 2015 Questions? https://joind.in/14212