SlideShare a Scribd company logo
1 of 46
Download to read offline
Hacking JavaScript Games
Cellular Automata
Alan Richardson
www.eviltester.com
We will Hack This Game
Cellular Automata Life Game Suitable for Hacking
http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
Supporting Videos
Change Colour of Cells
https://youtu.be/gWnvKQOb2yc
Change Colour Automatically
https://youtu.be/hfE99d4Slck
Create a Glider Invasion
https://youtu.be/CeOzcn7pBQY
Change Size of the World
https://youtu.be/lLnyNP33S_Q
Create a Randomly Generated World
https://youtu.be/uZv2s5QjPps
History Of The Game of Life
https://youtu.be/H1rMF7SnGn8
Bonus: Making Text With Cellular Automata
https://youtu.be/YAgBeG53lVI
Challenge ‐ Change Colour in Cellular
Automata
The simplest thing we can do to this game of life is to change the
colour.
It is also the most visible thing.
Using the game:
http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
Colour in the Game
In the code we have the  World function ‐ which is an object  class .
And the  World object has an  entityColour .
If we can change that, then we can change the colour.
I could use any six values from 0‐9, A‐F to make an HTML colour
code
e.g. http://htmlcolorcodes.com
Change colour by debugging
I set a break point on the line where the colour is set in the sources
view.
Line 153
 this.entityColour = "#FF0000"; 
Then:
Step over that line so the colour is set.
press  esc to get the console up.
change the colour in the console:
this.entityColour = "#111111";
Change colour from console when runnning game
change the colour using the console
inspect element and find where  World is instantiated with
 new . i.e.  ctrl+F and search for  new World .
var world = new World(worldSizes.myWorldWidth, 
                      worldSizes.myWorldHeight);
And I can change that whenever I want:
world.entityColour = "#111111";
Watch The Video
https://youtu.be/gWnvKQOb2yc
Change Colour Automatically
Simple ‐ have a bot to change colour every set time interval ‐ say
1000 milliseconds.
The challenge is that I need to use a hex value to do that. So let's
figure that out first.
Random Hex Value
I can use  0xFF as a Hex integer value, and it is 255
I can use the  toString method on a  Number to convert a
number to a base e.g. base 2 for binary or base 16 for hex:
I need to get a 6 character string, even if my hex value is only
 FF and I can do that by creating a string and using the last 6
characters e.g.
And I want my string to be  "0" padded at the front so I'll just
add  "000000" at the front of any string:
And I want a Hash  # in front
var myNum=3;
"#" + (("000000" + myNum.toString(16)).substr(‐6))
Use Game Random Int Code
The game already has a random number generator:
getRandomInt(0, 0xFFFFFF);
Use that
"#" + (("000000" + 
getRandomInt(0, 0xFFFFFF).toString(16)).substr(‐6))
And I have a way to generate a random HTML hex colour value.
Randomly set the colour every second
Create a bot to change the colour every 1000 milliseconds.
var colourChangeBot = setInterval(function() {
    world.entityColour = "#" + (("000000" + 
        getRandomInt(0, 0xFFFFFF).toString(16)).substr(‐6));
}, 1000);
Stop the bot with:
clearInterval(colourChangeBot);
Make Bot Faster or Slower
Change the value 1000, to make it faster, or slower:
500 ‐ every half second
200 ‐ every 200 milliseconds
Danger Flashing Lights.
Just be careful you don't make it so fast that you have a seizure.
Cycle over all the colours
This is a bit slower:
var currColour = 0;
var colourChangeBot = setInterval(function() {
    world.entityColour = "#" + ("000000" + 
          currColour.toString(16)).substr(‐6);
    currColour++;
    if (currColour >= 0xFFFFFF) {
        currColour = 0;
    }
}, 1)
Watch The Video
https://youtu.be/hfE99d4Slck
References
http://www.w3schools.com/jsref/jsref_tostring_number.asp
http://www.w3schools.com/jsref/jsref_substr.asp
An Invasion Challenge
Control the Invasion
Stop the invasion by calling:
stopInvasion();
Start an invasion with:
startInvasion(100);
Where  100 is the amount of milliseconds before the next lifeform
is added.
Create a Glider
addLifeForms.glider(world,10,0);
Which creates a glider at position  (10,0) 
I could create an invasion of gliders like that
var gliderInvasion = setInterval(function() {
    addLifeForms.glider(world, 10, 0);
}, 1000);
But an invasion should be random
First stop the old invasion:
clearInterval(gliderInvasion)
Then start our new invasion:
var gliderInvasion = setInterval(function() {
    addLifeForms.glider(world, 
       getRandomInt(0, world.xSize ‐ 50), 
       getRandomInt(0, world.ySize ‐ 50));
}, 100);
Watch The Video
https://youtu.be/CeOzcn7pBQY
Change World Size
One of the challenges in the Cellular Automata game is changing
the world size.
There is a clue in the game code, because we know that it does
some resizing when we change the window size.
 worldSizes.calculateScales();
And...
var world = new World(
            worldSizes.myWorldWidth, 
            worldSizes.myWorldHeight);
Let's Change the World ‐ Make is smaller
worldSizes.myWorldWidth=100; 
worldSizes.myWorldHeight=100;
worldSizes.calculateScales();
Let's Change the World ‐ Make is bigger
worldSizes.myWorldWidth=1000;
worldSizes.myWorldHeight=1000;
worldSizes.calculateScales();
Nope, that didn't work
Let's Change the World ‐ Make is bigger
tell the  world that it is bigger
worldSizes.myWorldWidth=1000;
worldSizes.myWorldHeight=1000;
world.xSize=1000; world.ySize=1000;
worldSizes.calculateScales();
That worked ‐ and its a little slower now, because thats 1000 x 1000
grid, which is 1,000,000 ﴾1 million﴿ cells!
Simulate ZX‐81
The ZX‐81 had a resolution of 64x48, and it was black and white, so
let's simulate that.
worldSizes.myWorldWidth=64; worldSizes.myWorldHeight=48;
world.xSize=worldSizes.myWorldWidth; 
world.ySize=worldSizes.myWorldHeight;
world.entityColour="#000000";
worldSizes.calculateScales();
And slow it down:
stopInvasion();
stopGame();
startGame(1000);
startInvasion(3000);
Watch The Video
https://youtu.be/lLnyNP33S_Q
Create A Random World
We first want total control over the game.
start game
 startGame(5) 
stop game
 stopGame() 
stop invasion
 stopInvasion() 
Stop the Game and Clear the world
stopGame();
stopInvasion();
It would be useful to also clear the display.
world.nukeEmAll();
But we'll only see the results if we start & stop the game again:
startGame(5);
stopGame();
Randomly generate stuff
Reset the population:
world.population = [];
I'll add items in a loop, and create 100 of them:
for(var itemLoop=0; itemLoop < 100; itemLoop++){
  world.addToPopulation(new LifeForm().move(0,
  getRandomInt(0, world.xSize), 
  getRandomInt(0, world.ySize)));
}
Start the game, we should see the results:
startGame(5);
100 might not actually be big enough, you might need to create
more for a viable world.
Experiment and Watch the Video
Experiment with different loop sizes to see what works for your
world ‐ remember its a harsh world out there for these cells so
sometimes you need to start with a lot of them.
https://youtu.be/uZv2s5QjPps
History of Game Of Life
John Horton Conway's Game of Life
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Rule
s
http://conwaylife.com/
Programs to download, install and experiment
with:
Golly
http://golly.sourceforge.net/
Also available on IPad and Android
online games of life:
Cellular Automata Life Game Suitable for Playing
https://bitstorm.org/gameoflife/
http://pmav.eu/stuff/javascript‐game‐of‐life‐v3.1.1/
Cellular Automata Life Game Suitable for Hacking
http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
Related References:
Good simple Overview
http://www.math.com/students/wonders/life/life.html
Good set of resources
http://www.ibiblio.org/lifepatterns/
http://www.ibiblio.org/lifepatterns/october1970.html
Wolfram description
http://mathworld.wolfram.com/GameofLife.html
History of Computer Game Design ‐ Stanford
http://web.stanford.edu/class/sts145/
http://web.stanford.edu/class/sts145/html/library.htm
Recommended Books
Artificial Life ‐ by Stephen Levy
The Garden in the Machine by Clause Emmeche
Watch A Video on the History of the
Game of Life
https://youtu.be/H1rMF7SnGn8
Other Contributions
Danny Dainton experimented with the Game of life and created a
'text' image.
https://twitter.com/DannyDainton/status/789499155785842688
And he has released thecode for it on github.
https://github.com/DannyDainton/Cellular_Automata_Hacking
How to Create Text
I took a different approach to Danny for the text creation:
I thought it would be easier to write text to the screen
scrape the pixels
add the pixels as blocks to the world
First Write the Text
// stop the world and clear the world and screen
stopInvasion();
stopGame();
world.population = [];
clearCanvas();
// plot the text we want
context.font = "14px verdana";
context.strokeStyle="#FF0000";
// kerning hack
// http://stackoverflow.com/questions/8952909/letter‐spacing‐in‐canva
var padding = String.fromCharCode(8202)+String.fromCharCode(8202
context.strokeText("Thank".split("").join(padding), 0, 15);
context.strokeText("You".split("").join(padding), 0, 30);
context.strokeText("Danny".split("").join(padding), 0, 45);
Then get the pixels and add them to the world
var imageData = context.getImageData(0,0,200,60);
var scale=4; // less than 4 and it will evolve
var imageX=0;var imageY=0;
for (var i=0;i<imageData.data.length;i+=4)
  {
  if(imageData.data[i]!==0 ||
     imageData.data[i+1]!==0 || 
     imageData.data[i+1] !== 0){
    addLifeForms.block(world, imageX*scale,imageY*scale);
   }
 
    imageX++;
  if(imageX>=200){
     imageX=0;
     imageY++;
  }
}
Then  startGame(5); 
Uses?
We could use this for image generation, just with the canvas.
resize canvas
create a border
plot text that shows the size
save the image
And we could create custom sized images for testing.
Resize Canvas
canvas.width=500;
canvas.height=500;
Create a Border
context.rect(0,0,canvas.width, canvas.height);
context.stroke();
Add Text
context.font = "80px verdana";
var padding = String.fromCharCode(8202)+
              String.fromCharCode(8202);
context.strokeText("500px".split("").join(padding), 0, 80);
context.strokeText("500px".split("").join(padding), 0, 160);
Watch A Bonus Video ‐ Create Text For
Cellular Automata
https://youtu.be/YAgBeG53lVI
What can you do with it?
Experiment and see what you come up with
Alan Richardson
Read my writing and blogs at:
http://www.compendiumdev.co.uk
http://blog.eviltester.com/
http://www.seleniumsimplified.com
http://blog.javafortesters.com/
Follow me on social media:
https://uk.linkedin.com/in/eviltester
https://twitter.com/eviltester ‐ @eviltester
YouTube
https://www.youtube.com/user/EviltesterVideos
https://www.instagram.com/eviltester/
Books And Training
"Java For Testers" ‐ Learn to code in Java with
http://javafortesters.com/page/about/
"Dear Evil Tester" ‐ Enjoy your testing
http://eviltester.com/page/dearEvilTester/
Online Training in Technical Testing, Selenium WebDriver, Java
and more
http://www.compendiumdev.co.uk/page/online_training

More Related Content

Viewers also liked

Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογία
Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογίαΜοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογία
Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογίαKonstantinos Giannakis
 
Quantum automata for infinite periodic words
Quantum automata for infinite periodic wordsQuantum automata for infinite periodic words
Quantum automata for infinite periodic wordsKonstantinos Giannakis
 
Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Alan Richardson
 
Technical Testing Webinar
Technical Testing WebinarTechnical Testing Webinar
Technical Testing WebinarAlan Richardson
 
Confessions of an Accidental Security Tester
Confessions of an Accidental Security TesterConfessions of an Accidental Security Tester
Confessions of an Accidental Security TesterAlan Richardson
 
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...Editor IJCATR
 
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile Projects
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile ProjectsAgile Testing Days 2014 Keynote - Helping Testers Add Value on Agile Projects
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile ProjectsAlan Richardson
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with UnitilsMikalai Alimenkou
 
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...Alan Richardson
 
Checklist - How to install Java, Maven Intellij on Windows & Mac
Checklist - How to install Java, Maven Intellij on Windows & MacChecklist - How to install Java, Maven Intellij on Windows & Mac
Checklist - How to install Java, Maven Intellij on Windows & MacAlan Richardson
 
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...Alan Richardson
 
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...Alan Richardson
 
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017Alan Richardson
 
TDD in functional testing with WebDriver
TDD in functional testing with WebDriverTDD in functional testing with WebDriver
TDD in functional testing with WebDriverMikalai Alimenkou
 
Appium: Prime Cuts
Appium: Prime CutsAppium: Prime Cuts
Appium: Prime CutsSauce Labs
 
Cellular Automata for Pathfinding
Cellular Automata for PathfindingCellular Automata for Pathfinding
Cellular Automata for PathfindingSteve Wilson
 

Viewers also liked (18)

Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογία
Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογίαΜοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογία
Μοντέλα υπολογισμού επηρεασμένα από την ϕύση και τη βιολογία
 
Quantum automata for infinite periodic words
Quantum automata for infinite periodic wordsQuantum automata for infinite periodic words
Quantum automata for infinite periodic words
 
Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014
 
Technical Testing Webinar
Technical Testing WebinarTechnical Testing Webinar
Technical Testing Webinar
 
Confessions of an Accidental Security Tester
Confessions of an Accidental Security TesterConfessions of an Accidental Security Tester
Confessions of an Accidental Security Tester
 
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...
A New Security Level for Elliptic Curve Cryptosystem Using Cellular Automata ...
 
Ca model presentation
Ca model presentationCa model presentation
Ca model presentation
 
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile Projects
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile ProjectsAgile Testing Days 2014 Keynote - Helping Testers Add Value on Agile Projects
Agile Testing Days 2014 Keynote - Helping Testers Add Value on Agile Projects
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with Unitils
 
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
 
Checklist - How to install Java, Maven Intellij on Windows & Mac
Checklist - How to install Java, Maven Intellij on Windows & MacChecklist - How to install Java, Maven Intellij on Windows & Mac
Checklist - How to install Java, Maven Intellij on Windows & Mac
 
CELLULAR AUTOMATA TRAFFIC FLOW MODEL
CELLULAR AUTOMATA TRAFFIC FLOW MODELCELLULAR AUTOMATA TRAFFIC FLOW MODEL
CELLULAR AUTOMATA TRAFFIC FLOW MODEL
 
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
 
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...
Technical Mobile Testing - Risks, Issues and Experiences (EuroSTAR Mobile Dee...
 
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
 
TDD in functional testing with WebDriver
TDD in functional testing with WebDriverTDD in functional testing with WebDriver
TDD in functional testing with WebDriver
 
Appium: Prime Cuts
Appium: Prime CutsAppium: Prime Cuts
Appium: Prime Cuts
 
Cellular Automata for Pathfinding
Cellular Automata for PathfindingCellular Automata for Pathfinding
Cellular Automata for Pathfinding
 

Similar to Hacking JavaScript Games - Cellular Automata

Cross platform html5 games
Cross platform html5 gamesCross platform html5 games
Cross platform html5 gamesVikek Kalra
 
Cheating in Computer Games
Cheating in Computer GamesCheating in Computer Games
Cheating in Computer GamesIftach Ian Amit
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with GroovyJames Williams
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
 
Unity3D Basic Concepts by: shamal aryan
Unity3D Basic Concepts by: shamal aryan Unity3D Basic Concepts by: shamal aryan
Unity3D Basic Concepts by: shamal aryan Shamal Aryan
 
Getting Started.docx - Unreal Tournament 3 Bots for .NET
Getting Started.docx - Unreal Tournament 3 Bots for .NETGetting Started.docx - Unreal Tournament 3 Bots for .NET
Getting Started.docx - Unreal Tournament 3 Bots for .NETbutest
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyYodalee
 
Jake hyatt Y1 gd engine_terminology
Jake hyatt Y1 gd engine_terminologyJake hyatt Y1 gd engine_terminology
Jake hyatt Y1 gd engine_terminologyJakeyhyatt123
 
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME gamersjot8
 
Mistakes I Made Building Netflix for the iPhone
Mistakes I Made Building Netflix for the iPhoneMistakes I Made Building Netflix for the iPhone
Mistakes I Made Building Netflix for the iPhonekentbrew
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityKobkrit Viriyayudhakorn
 
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon runMaja Kraljič
 
Progressive transpilation and the road to ES2015 in production
Progressive transpilation and the road to ES2015 in productionProgressive transpilation and the road to ES2015 in production
Progressive transpilation and the road to ES2015 in productionJacques Favreau
 
Android game development
Android game developmentAndroid game development
Android game developmentdmontagni
 
Connor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyConnor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyKalen612
 
VR digest. June 2018
VR digest. June 2018VR digest. June 2018
VR digest. June 2018ElifTech
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endThibault Imbert
 
Technology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertTechnology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertFITC
 

Similar to Hacking JavaScript Games - Cellular Automata (20)

Cross platform html5 games
Cross platform html5 gamesCross platform html5 games
Cross platform html5 games
 
Cheating in Computer Games
Cheating in Computer GamesCheating in Computer Games
Cheating in Computer Games
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
 
Unity3D Basic Concepts by: shamal aryan
Unity3D Basic Concepts by: shamal aryan Unity3D Basic Concepts by: shamal aryan
Unity3D Basic Concepts by: shamal aryan
 
Mixed reality
Mixed realityMixed reality
Mixed reality
 
Getting Started.docx - Unreal Tournament 3 Bots for .NET
Getting Started.docx - Unreal Tournament 3 Bots for .NETGetting Started.docx - Unreal Tournament 3 Bots for .NET
Getting Started.docx - Unreal Tournament 3 Bots for .NET
 
Gameboy emulator in rust and web assembly
Gameboy emulator in rust and web assemblyGameboy emulator in rust and web assembly
Gameboy emulator in rust and web assembly
 
Jake hyatt Y1 gd engine_terminology
Jake hyatt Y1 gd engine_terminologyJake hyatt Y1 gd engine_terminology
Jake hyatt Y1 gd engine_terminology
 
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
Gamers In THE OVERALL GAME
 
Mistakes I Made Building Netflix for the iPhone
Mistakes I Made Building Netflix for the iPhoneMistakes I Made Building Netflix for the iPhone
Mistakes I Made Building Netflix for the iPhone
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in Unity
 
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
 
Progressive transpilation and the road to ES2015 in production
Progressive transpilation and the road to ES2015 in productionProgressive transpilation and the road to ES2015 in production
Progressive transpilation and the road to ES2015 in production
 
Street runner final
Street runner finalStreet runner final
Street runner final
 
Android game development
Android game developmentAndroid game development
Android game development
 
Connor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyConnor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine Terminology
 
VR digest. June 2018
VR digest. June 2018VR digest. June 2018
VR digest. June 2018
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an end
 
Technology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertTechnology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault Imbert
 

More from Alan Richardson

Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Alan Richardson
 
Automating to Augment Testing
Automating to Augment TestingAutomating to Augment Testing
Automating to Augment TestingAlan Richardson
 
Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Alan Richardson
 
Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020Alan Richardson
 
The Future of Testing Webinar
The Future of Testing WebinarThe Future of Testing Webinar
The Future of Testing WebinarAlan Richardson
 
Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesAlan Richardson
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Alan Richardson
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonAlan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsAlan Richardson
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based TestingAlan Richardson
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAlan Richardson
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST APIAlan Richardson
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameAlan Richardson
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzAlan Richardson
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to codeAlan Richardson
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With AgilityAlan Richardson
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyAlan Richardson
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.Alan Richardson
 

More from Alan Richardson (20)

Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021
 
Automating to Augment Testing
Automating to Augment TestingAutomating to Augment Testing
Automating to Augment Testing
 
Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009
 
Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020
 
The Future of Testing Webinar
The Future of Testing WebinarThe Future of Testing Webinar
The Future of Testing Webinar
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
 
Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slides
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based Testing
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil Tester
 
Shift left-testing
Shift left-testingShift left-testing
Shift left-testing
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST API
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" Game
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzz
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to code
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With Agility
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be Flaky
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.
 

Recently uploaded

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Hacking JavaScript Games - Cellular Automata

  • 1. Hacking JavaScript Games Cellular Automata Alan Richardson www.eviltester.com
  • 2. We will Hack This Game Cellular Automata Life Game Suitable for Hacking http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
  • 3. Supporting Videos Change Colour of Cells https://youtu.be/gWnvKQOb2yc Change Colour Automatically https://youtu.be/hfE99d4Slck Create a Glider Invasion https://youtu.be/CeOzcn7pBQY Change Size of the World https://youtu.be/lLnyNP33S_Q Create a Randomly Generated World https://youtu.be/uZv2s5QjPps History Of The Game of Life https://youtu.be/H1rMF7SnGn8 Bonus: Making Text With Cellular Automata https://youtu.be/YAgBeG53lVI
  • 4. Challenge ‐ Change Colour in Cellular Automata The simplest thing we can do to this game of life is to change the colour. It is also the most visible thing. Using the game: http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
  • 5. Colour in the Game In the code we have the  World function ‐ which is an object  class . And the  World object has an  entityColour . If we can change that, then we can change the colour. I could use any six values from 0‐9, A‐F to make an HTML colour code e.g. http://htmlcolorcodes.com
  • 6. Change colour by debugging I set a break point on the line where the colour is set in the sources view. Line 153  this.entityColour = "#FF0000";  Then: Step over that line so the colour is set. press  esc to get the console up. change the colour in the console: this.entityColour = "#111111";
  • 7. Change colour from console when runnning game change the colour using the console inspect element and find where  World is instantiated with  new . i.e.  ctrl+F and search for  new World . var world = new World(worldSizes.myWorldWidth,                        worldSizes.myWorldHeight); And I can change that whenever I want: world.entityColour = "#111111";
  • 9. Change Colour Automatically Simple ‐ have a bot to change colour every set time interval ‐ say 1000 milliseconds. The challenge is that I need to use a hex value to do that. So let's figure that out first.
  • 10. Random Hex Value I can use  0xFF as a Hex integer value, and it is 255 I can use the  toString method on a  Number to convert a number to a base e.g. base 2 for binary or base 16 for hex: I need to get a 6 character string, even if my hex value is only  FF and I can do that by creating a string and using the last 6 characters e.g. And I want my string to be  "0" padded at the front so I'll just add  "000000" at the front of any string: And I want a Hash  # in front var myNum=3; "#" + (("000000" + myNum.toString(16)).substr(‐6))
  • 11. Use Game Random Int Code The game already has a random number generator: getRandomInt(0, 0xFFFFFF); Use that "#" + (("000000" +  getRandomInt(0, 0xFFFFFF).toString(16)).substr(‐6)) And I have a way to generate a random HTML hex colour value.
  • 12. Randomly set the colour every second Create a bot to change the colour every 1000 milliseconds. var colourChangeBot = setInterval(function() {     world.entityColour = "#" + (("000000" +          getRandomInt(0, 0xFFFFFF).toString(16)).substr(‐6)); }, 1000); Stop the bot with: clearInterval(colourChangeBot);
  • 13. Make Bot Faster or Slower Change the value 1000, to make it faster, or slower: 500 ‐ every half second 200 ‐ every 200 milliseconds Danger Flashing Lights. Just be careful you don't make it so fast that you have a seizure.
  • 14. Cycle over all the colours This is a bit slower: var currColour = 0; var colourChangeBot = setInterval(function() {     world.entityColour = "#" + ("000000" +            currColour.toString(16)).substr(‐6);     currColour++;     if (currColour >= 0xFFFFFF) {         currColour = 0;     } }, 1)
  • 17. An Invasion Challenge Control the Invasion Stop the invasion by calling: stopInvasion(); Start an invasion with: startInvasion(100); Where  100 is the amount of milliseconds before the next lifeform is added.
  • 18. Create a Glider addLifeForms.glider(world,10,0); Which creates a glider at position  (10,0)  I could create an invasion of gliders like that var gliderInvasion = setInterval(function() {     addLifeForms.glider(world, 10, 0); }, 1000);
  • 19. But an invasion should be random First stop the old invasion: clearInterval(gliderInvasion) Then start our new invasion: var gliderInvasion = setInterval(function() {     addLifeForms.glider(world,         getRandomInt(0, world.xSize ‐ 50),         getRandomInt(0, world.ySize ‐ 50)); }, 100);
  • 21. Change World Size One of the challenges in the Cellular Automata game is changing the world size. There is a clue in the game code, because we know that it does some resizing when we change the window size.  worldSizes.calculateScales(); And... var world = new World(             worldSizes.myWorldWidth,              worldSizes.myWorldHeight);
  • 22. Let's Change the World ‐ Make is smaller worldSizes.myWorldWidth=100;  worldSizes.myWorldHeight=100; worldSizes.calculateScales();
  • 23. Let's Change the World ‐ Make is bigger worldSizes.myWorldWidth=1000; worldSizes.myWorldHeight=1000; worldSizes.calculateScales(); Nope, that didn't work
  • 24. Let's Change the World ‐ Make is bigger tell the  world that it is bigger worldSizes.myWorldWidth=1000; worldSizes.myWorldHeight=1000; world.xSize=1000; world.ySize=1000; worldSizes.calculateScales(); That worked ‐ and its a little slower now, because thats 1000 x 1000 grid, which is 1,000,000 ﴾1 million﴿ cells!
  • 25. Simulate ZX‐81 The ZX‐81 had a resolution of 64x48, and it was black and white, so let's simulate that. worldSizes.myWorldWidth=64; worldSizes.myWorldHeight=48; world.xSize=worldSizes.myWorldWidth;  world.ySize=worldSizes.myWorldHeight; world.entityColour="#000000"; worldSizes.calculateScales(); And slow it down: stopInvasion(); stopGame(); startGame(1000); startInvasion(3000);
  • 27. Create A Random World We first want total control over the game. start game  startGame(5)  stop game  stopGame()  stop invasion  stopInvasion() 
  • 28. Stop the Game and Clear the world stopGame(); stopInvasion(); It would be useful to also clear the display. world.nukeEmAll(); But we'll only see the results if we start & stop the game again: startGame(5); stopGame();
  • 29. Randomly generate stuff Reset the population: world.population = []; I'll add items in a loop, and create 100 of them: for(var itemLoop=0; itemLoop < 100; itemLoop++){   world.addToPopulation(new LifeForm().move(0,   getRandomInt(0, world.xSize),    getRandomInt(0, world.ySize))); } Start the game, we should see the results: startGame(5); 100 might not actually be big enough, you might need to create more for a viable world.
  • 30. Experiment and Watch the Video Experiment with different loop sizes to see what works for your world ‐ remember its a harsh world out there for these cells so sometimes you need to start with a lot of them. https://youtu.be/uZv2s5QjPps
  • 31. History of Game Of Life John Horton Conway's Game of Life https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Rule s http://conwaylife.com/ Programs to download, install and experiment with: Golly http://golly.sourceforge.net/ Also available on IPad and Android
  • 32. online games of life: Cellular Automata Life Game Suitable for Playing https://bitstorm.org/gameoflife/ http://pmav.eu/stuff/javascript‐game‐of‐life‐v3.1.1/ Cellular Automata Life Game Suitable for Hacking http://compendiumdev.co.uk/apps/games/ca/ca_v1.html
  • 33. Related References: Good simple Overview http://www.math.com/students/wonders/life/life.html Good set of resources http://www.ibiblio.org/lifepatterns/ http://www.ibiblio.org/lifepatterns/october1970.html Wolfram description http://mathworld.wolfram.com/GameofLife.html History of Computer Game Design ‐ Stanford http://web.stanford.edu/class/sts145/ http://web.stanford.edu/class/sts145/html/library.htm
  • 34. Recommended Books Artificial Life ‐ by Stephen Levy The Garden in the Machine by Clause Emmeche
  • 35. Watch A Video on the History of the Game of Life https://youtu.be/H1rMF7SnGn8
  • 36. Other Contributions Danny Dainton experimented with the Game of life and created a 'text' image. https://twitter.com/DannyDainton/status/789499155785842688 And he has released thecode for it on github. https://github.com/DannyDainton/Cellular_Automata_Hacking
  • 37.
  • 38. How to Create Text I took a different approach to Danny for the text creation: I thought it would be easier to write text to the screen scrape the pixels add the pixels as blocks to the world
  • 39. First Write the Text // stop the world and clear the world and screen stopInvasion(); stopGame(); world.population = []; clearCanvas(); // plot the text we want context.font = "14px verdana"; context.strokeStyle="#FF0000"; // kerning hack // http://stackoverflow.com/questions/8952909/letter‐spacing‐in‐canva var padding = String.fromCharCode(8202)+String.fromCharCode(8202 context.strokeText("Thank".split("").join(padding), 0, 15); context.strokeText("You".split("").join(padding), 0, 30); context.strokeText("Danny".split("").join(padding), 0, 45);
  • 40. Then get the pixels and add them to the world var imageData = context.getImageData(0,0,200,60); var scale=4; // less than 4 and it will evolve var imageX=0;var imageY=0; for (var i=0;i<imageData.data.length;i+=4)   {   if(imageData.data[i]!==0 ||      imageData.data[i+1]!==0 ||       imageData.data[i+1] !== 0){     addLifeForms.block(world, imageX*scale,imageY*scale);    }       imageX++;   if(imageX>=200){      imageX=0;      imageY++;   } } Then  startGame(5); 
  • 41. Uses? We could use this for image generation, just with the canvas. resize canvas create a border plot text that shows the size save the image And we could create custom sized images for testing.
  • 42. Resize Canvas canvas.width=500; canvas.height=500; Create a Border context.rect(0,0,canvas.width, canvas.height); context.stroke(); Add Text context.font = "80px verdana"; var padding = String.fromCharCode(8202)+               String.fromCharCode(8202); context.strokeText("500px".split("").join(padding), 0, 80); context.strokeText("500px".split("").join(padding), 0, 160);
  • 43. Watch A Bonus Video ‐ Create Text For Cellular Automata https://youtu.be/YAgBeG53lVI
  • 44. What can you do with it? Experiment and see what you come up with
  • 45. Alan Richardson Read my writing and blogs at: http://www.compendiumdev.co.uk http://blog.eviltester.com/ http://www.seleniumsimplified.com http://blog.javafortesters.com/ Follow me on social media: https://uk.linkedin.com/in/eviltester https://twitter.com/eviltester ‐ @eviltester YouTube https://www.youtube.com/user/EviltesterVideos https://www.instagram.com/eviltester/
  • 46. Books And Training "Java For Testers" ‐ Learn to code in Java with http://javafortesters.com/page/about/ "Dear Evil Tester" ‐ Enjoy your testing http://eviltester.com/page/dearEvilTester/ Online Training in Technical Testing, Selenium WebDriver, Java and more http://www.compendiumdev.co.uk/page/online_training