# CodeJourney_TicTacToe

# AutoTicTacToe

For The Game Jam. "TicTacToeRag": <https://itch.io/jam/megamitts-mega-jam-20> , **AutoTicTacToe** uses *L5lua* that explores a version of TicTacToe that is scored automatically when you are able to get 3 of a kind within a square.

## TicTacToe Simulator

<https://illestpreacha.itch.io/autotictactoe-cubes>

## L5Lua Code

```lua
require ("L5")


function setup()
  size(800, 800)
  
  describe('Auto TicTacToe Simulator that checks TicTacToe within the squares themself')
end

colors = {"red", "green", "blue","orange","aqua","black","pink","yellow","purple","teal","grey"}
bits = {"X","O"}

--Wincombos = {{1,2,3}, {4,5,6}, {7,8,9},{1,4,7},{2,5,8},{3,6,9},{1,5,9},{3,5,7}}


count = 0



-- random text generator form one

function draw()
  
  
  frameRate(2)
  background(150)
  textAlign(CENTER)
  
  
  for i = 1, 3 do
  for j = 1, 3 do
    textSize(125)
    cells = {}
    x = bits[ math.random(1, 2)]
    fill(colors[ math.random(1, 11)])
    cells[#cells + 1] = x
      text(x, 200* i + 5, 150 * j + random(15,45), 100)
    end
end


  for i = 1, 3 do
  for j = 1, 3 do
    textSize(50)
    cells1 = {}
    x = bits[ math.random(1, 2)]
    fill(colors[ math.random(1, 11)])
    cells1[#cells1 + 1] = x
      text(x, 205* i + 5, 135 * j + random(20,25), 100)
    end
end



  for i = 1, 3 do
  for j = 1, 3 do
    textSize(25)
    cells2 = {}
    x = bits[ math.random(1, 2)]
    fill(colors[ math.random(1, 11)])
    cells2[#cells2 + 1] = x
      text(x, 215* i + 5, 115 * j + random(30,35), 100)
end
end

counter()


 

end

  -- Auto TicTacToe  Counter
function counter()


for i = 1, 9 do
    if cells[i] == cells1[i] and cells2[i] then
          count = count + 1
    end
  end
  
    
  textSize(35)
  fill('black')
  rect(105,700,550,50)
  rect(105,50,550,50)
  fill('white')
  text("Internal TicTacToe Score: "..tostring(count),105,700, 1000)
  textSize(45)
  text("AutoTicTacToe Cubed",105,50, 1000) 

end


```
