AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
How to make your own tic tac toe board1/10/2024 Width : w-2 +"px", // -2 is to account 1px borderįield. Var field = document.createElement("div"), Select.addEventListener("change", createMap, false) In any case here's an example using DIV as you do:įunction el(id)įor(var key in prop) el.style = prop Main.innerHTML = "" // Clear first, not afterwards! Use the Math.random () method to generate an integer 0 or 1, which corresponds to displaying an X or O image icon. A label may display an image icon for X or and image icon for O. You can simply create a single one oneField(i, j, n) and pass to that function the number of iterations you need to apply like: select.addEventListener("change", createMap, false) My problem is this: (Game: display a tic-tac-toe board) Display a frame that contains nine labels. It's cause you're first drawing your elements applying the desired fn loop, but afterwards you're clearing the whole #mainDiv using main.innerHTML = "" Īlso, instead of creating different functions like three(), four(), five(). But for me and couple of other friends it doesn't.Īnd my problem is that small div's don't draw in the mainDiv Strange thing is that on PC of one of my friends it works perfectly. Var main = document.getElementById("mainDiv") Īnd my problem is that small div's don't draw in the mainDiv. Var select = document.getElementById("mySelect").value select.addEventListener("change", onChange, false) Var mainDiv = document.getElementById("mainDiv") However this one only prints out the number I selected in my input(), eg 3, and not the ("load", onLoad, false) My first task was to create an empty board and I managed to do that with the following code: (this one also prints ut the board) import numpy as npīut then I wanted the program to be able to perform tic tac toe on three different sized boards (3x3, 5x5 and 7x7) so I redid the code and created a main() function with an input() that asks for the desired size. I am trying to create a program of tic tac toe in python where only the computer will perform the moves, ie it will play against itself. I want to be able to choose between three different boards, but only the code for one board works for me. I am having trouble with creating a specific board for a tic tac toe game in Python and I hope that one of you could help me find what is wrong.
0 Comments
Read More
Leave a Reply. |