SubSet - combining & mixing three sets of three variables

So, I've received an assignment for school and it's doing my head in. Basically, we need to design and create a cardgame (SubSet, based on the game 'Set'; Marsha Falco). There is a total of 27 unique cards, each with a different image on it. The image consists out of three elements, each with three variations - so 3^3 = 27. The first element is the amount of objects (1, 2 or 3), the second element is the shape of the object (triangular, rectangular or circular) and the third element is the color of the objects (red, green or blue). So, card 1 has one red triangle, card 2 has two red triangles, card 3 has three red triangles, card 4 has 1 blue triangle, ...

At any given time, there will be a maximum of 9 cards on the table, face up. It's the player's job to select three cards to make a set. Three cards are a set when either all three of the elements are different or (at least) one of the elements is the same on all three. Example 1: 1 rectangle red // 2 rectangles red // 3 rectangles red (shape is the same, color is the same) Example 2: 1 circle blue // 2 triangles green // 3 rectangles red (every element is different) Example 3: 1 circle blue // 1 triangle green // 1 rectangle red (amount is the same) And so on...

As soon as a set has been found, it has to be 'removed' from the table and three new cards need to be pulled from the stack, onto the table, as long as there are cards to pull from the stack. Also, the cards need to appear 'shuffled', so in different order every time the game is played.

But to be honest, I have no idea how to go about this. Do I create three different arrays for each of the elements and somehow try to combine them? My knowledge in regards to arrays is quite limited, so any push in the right direction would be greatly appreciated!

Tagged:

Answers

  • edited October 2015 Answer ✓

    yes you can have 3 arrays

    each is a list

    • the first array is the amount of objects (1, 2 or 3),

    • the second array is the shape of the object (triangular, rectangular or circular) and

    • the third element is the color of the objects (red, green or blue).

    now, the idea is that the first card is represented by the first line (line 0 in processing) in the 3 arrays.

    • The card knows its amount from list 1, the shape from list 2 and the col from list 3

    • the 2nd card is represented by the 2nd line (line 1 in processing) in the 3 arrays.

    So to look up the properties of one card, look in line 0 in all 3 arrays.

    So when doing this start by setting up your deck of cards:

    int[] amountOfObjects = new int [27]; // (1, 2 or 3), 
    int[] shapeType= new int [27]; // see below 
    color colorOfObjects = new color[27];  // see below 
    
    // to make your code better readable, you can define int constants for the shapeType 
    // to use later int the array number 2 : 
    final int shapeTypeTriangular = 0;
    final int shapeTypeRectangular = 1; 
    final int shapeTypeCircular = 2; 
    
    // same for colors
    final color RED = color(255,0,0); 
    final color GREEN = color(0,255,0); 
    final color BLUE = color(0,0,255); 
    
    // now the first card is #0 : 
    amountOfObjects [0] = 1; 
    shapeType [0] = shapeTypeTriangular;
    colorOfObjects  [0] = RED; 
    
    // and now the other cards ................
    // ..............
    // ....................
    

    other idea

    when you are into object oriented programming / OOP / objects and classes, you can make a better solution

  • Thank you for your response and apologies for my late reply! Your post definitely helped me along the way, but left that assignment for what it is, for now.

Sign In or Register to comment.