Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Feedback very new any help appreciated

Discussion in 'Scripting' started by Penkine, Jan 10, 2020.

  1. Penkine

    Penkine

    Joined:
    Jun 5, 2019
    Posts:
    15
    Overview
    • Tic Tac Toe clone.
    • Expandable grid size (by code).
    • 2 players (in future, an algorithm for a pc opponent).
    Problem
    I was struggling to think of a method for storing the information needed.
    Current assumption of information needed to be stored:
    • (x, y) coordinates
    • bool for if a cell is empty (and so is free for a player choice)
    • store which player has a cell
    Maybe I am approaching this completely wrong? or is there some way to create a solution with the current idea. Many thanks, sorry if it's confusing, I am happy to explain further in replies if I have missed important details.
     
  2. adi7b9

    adi7b9

    Joined:
    Feb 22, 2015
    Posts:
    181
    to store data use variables. An easy approach is by making a table:
    Code (CSharp):
    1. int[,] table = new int[3, 3];
    In each "cell" of the table you know that 0 is free, 1 - player1, 2 - player2
     
    Penkine and Dextozz like this.
  3. Penkine

    Penkine

    Joined:
    Jun 5, 2019
    Posts:
    15
    Thanks a lot, that helps
     
    Last edited: Jan 11, 2020