# I can't find the error in my code?

**URL:** <https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [October 17, 2019, 9:36pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771 "2019-10-17T21:36:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![someguy](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@someguy](https://discourse.processing.org/u/someguy)\
**Post date:** [October 17, 2019, 9:36pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/1 "2019-10-17T21:36:29Z")

</div>

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”

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)\
**Post date:** [October 17, 2019, 9:57pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/2 "2019-10-17T21:57:28Z")

</div>

> [@someguy](#):
>
> if((AIpaper = true) && (PlayerPaper = true)){ text(“Tie!”,30,50); }

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

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

```

but you can take that further and just do

```auto
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

---

<div class="post-metadata">

**Author:** ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)\
**Post date:** [October 17, 2019, 10:32pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/3 "2019-10-17T22:32:06Z")

</div>

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.

```auto
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);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 17, 2019, 10:33pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/4 "2019-10-17T22:33:32Z")

</div>

there are a lot of small mistakes

like missing ; at end of line

keypressed instead of keyPressed…

misplaced }

Regards, Chrisir

---

<div class="post-metadata">

**Author:** ![someguy](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@someguy](https://discourse.processing.org/u/someguy)\
**Post date:** [October 18, 2019, 2:01am UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/5 "2019-10-18T02:01:49Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![someguy](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@someguy](https://discourse.processing.org/u/someguy)\
**Post date:** [October 18, 2019, 2:05am UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/6 "2019-10-18T02:05:54Z")

</div>

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 ‘=’ "

---

<div class="post-metadata">

**Author:** ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)\
**Post date:** [October 18, 2019, 5:23am UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/7 "2019-10-18T05:23:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 18, 2019, 7:42am UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/8 "2019-10-18T07:42:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![someguy](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@someguy](https://discourse.processing.org/u/someguy)\
**Post date:** [October 18, 2019, 3:12pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/9 "2019-10-18T15:12:06Z")

</div>

That was the entire code for the program.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 18, 2019, 3:20pm UTC](https://discourse.processing.org/t/i-cant-find-the-error-in-my-code/14771/10 "2019-10-18T15:20:44Z")

</div>

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
