I can't find the error in my code?

I’m very new to this and I feel stupid but I can’t for the love of me find what the mistake is in this code
also I’m not sure how to quote it correctly so sorry!
i get “missing ) after argument list”

Int aichoice;
boolean AIpaper;
boolean AIrock;
boolean AIscissors;
boolean PlayerRock;
boolean PlayerPaper;
boolean PlayerScissors;
void setup(){
background(254,251,251)
textSize(35,35)
fill(0,0,0)

text("Would you like to play a game?",10,50);
}

void draw(){
fill(255,255,255)
rect(50,150,75,100)
fill(122,122,122)
ellipse(250,200,100,100)
fill(214,201,201);
rotate(3.0,3.0);
rect(300,290,100,25)
fill(255,215,0)
ellipse(300,280,50,50)
fill(255,255,255)
ellipse(300,280,30,30)
fill(255,215,0)
ellipse(300,320,50,50)
fill(255,255,255)
ellipse(300,320,30,30)

}
set aichoice = random(1,4);


if(aichoice = 1){
set AIpaper = true;
}
if(aichoice = 2){
set AIrock = true;
}
if(aichoice = 3){
set AIscissors = true;
}


if(keypressed){
    if(key = '1'){
set PlayerPaper = true;
}
}
if(keypressed){
    if(key = '2'){
set PlayerRock = true;
}
}
if(keypressed){
    if(key = '3'){
set PlayerScissors = true;
}
}


if((AIpaper = true) && (PlayerPaper = true)){
text("Tie!",30,50);
}
if((AIpaper = true) && (PlayerRock = true)){
text("Sorry, you lose!",30,50);
}
if((AIpaper = true)  && (PlayerScissors = true)){
text("Win!!!",30,50);
}
if((AIrock = true) && (PlayerPaper = true)){
text("Win!!!",30,50);
}
if((AIrock = true) && (PlayerRock = true)){
text("Tie!",30,50);
}
if((AIrock = true)&& (PlayerRock = true)){
text("Sorry, you lose!",30,50);
}
if((AIscissors = true) && (PlayerRock = true)){
text("Win!!!",30,50);
}
if((AIscissors = true) && (PlayerPaper = true)){
text("Sorry, you lose!" 30,50);
}
if((AIscissors = true) && (PlayerScissors = true)){
text("Tie!",30,50);
}
1 Like

that is an assignment not a comparison. and you could change them all to

if((AIpaper == true) && (PlayerPaper == true)){ text("Tie!",30,50); }

but you can take that further and just do

if(AIpaper && PlayerPaper){ text("Tie!",30,50); }

so basically there is instantiation

boolean someValue = true;

assigment

someValue = false;

and comparison

if(someValue) { do something )

the last one has a few variations. In its current state if someValue is true then it will “do something” you can also negate that boolean value like

if(!someValue) { do something )

now if someValue is false it will do something.

if you go through your code and fix those comparisons you should be fine i think

1 Like

here is a working version just to see how things might work. there is alot you could improve but this is a good first effort. well done. keep at it.

int aichoice;
boolean AIpaper;
boolean AIrock;
boolean AIscissors;
boolean PlayerRock;
boolean PlayerPaper;
boolean PlayerScissors;

void setup() {
  size(640, 480, P2D);
  textSize(24);
  reset();
}

void reset() {
  AIpaper = false;
  AIrock = false;
  AIscissors = false;
  PlayerRock = false;
  PlayerPaper = false;
  PlayerScissors = false;

  background(254, 251, 251);  
  fill(0, 0, 0);
  text("Choose - Rock(1) Paper(2) Scissors(3)", 10, 50);
}

void draw() {
  /*
  fill(255, 255, 255);
  rect(50, 150, 75, 100);
  fill(122, 122, 122);
  ellipse(250, 200, 100, 100);
  fill(214, 201, 201);
  rotate(3.0);
  rect(300, 290, 100, 25);
  fill(255, 215, 0);
  ellipse(300, 280, 50, 50);
  fill(255, 255, 255);
  ellipse(300, 280, 30, 30);
  fill(255, 215, 0);
  ellipse(300, 320, 50, 50);
  fill(255, 255, 255);
  ellipse(300, 320, 30, 30);
  */
}

void keyPressed() {
  reset();
  
  switch(key) {
  case '1':
    PlayerPaper = true;
    play();
    break;
  case '2':
    PlayerRock = true;
    play();
    break;
  case '3':
    PlayerScissors = true;
    play();
    break;
  }
}

void play() {
  aichoice = (int)random(1, 4);
  println(aichoice);
  
  if (aichoice == 1) {
    AIpaper = true;
  }
  if (aichoice == 2) {
    AIrock = true;
  }
  if (aichoice == 3) {
    AIscissors = true;
  }
  
  if (AIpaper && PlayerPaper) {
    text("Tie!", 30, 100);
  } else if (AIpaper && PlayerRock) {
    text("Sorry, you lose!", 30, 100);
  } else if (AIpaper && PlayerScissors) {
    text("Win!!!", 30, 100);
  } else if (AIrock && PlayerPaper) {
    text("Win!!!", 30, 100);
  } else if (AIrock && PlayerRock) {
    text("Sorry, you lose!", 30, 100);
  } else if (AIrock && PlayerScissors) {
    text("Sorry, you lose!", 30, 100);
  }else if (AIscissors && PlayerRock) {
    text("Win!!!", 30, 100);
  } else if (AIscissors && PlayerPaper) {
    text("Sorry, you lose!", 30, 100);
  } else {
    text("Tie!", 30, 100);
  }
}
1 Like

there are a lot of small mistakes

like missing ; at end of line

keypressed instead of keyPressed…

misplaced }

Regards, Chrisir

1 Like

Whaaa… ?
I feel so confused and stupid…

I also don’t want to copy paste since this is an assignment

Thanks but I don’t get why I get that error…

I tried the double equals and it said that it didn’t work but this time i get an error message that said "unexpected token ‘=’ "

i didn’t realise this is homework and it’s good that you don’t want to just copy paste. you definitely also need to make note and adjustments according to Chrisir’ comment. Best of luck with it all practice makes perfect and soon enough it will all make sense.

1 Like

You can just slowly proofread your code. Instead of trying to run it.

at the end of command lines there must be a ; (not when‘s if or { } line though)

Check the == versus =

There is one } that belongs at the very end of the code (it’s closing draw()). You misplaced this, it’s way too early.

See my post above

Please post your entire code in every post, otherwise we can’t help you really

We can’t see where your error is.

But we are happy to help you.

Chrisir

1 Like

That was the entire code for the program.

No, I mean after you corrected your code and still had errors:

  • post the new version of your code again

Otherwise we can’t see what you have changed and what not (and where still errors are)

Regards, Chrisir