python - Connect 4 Horizontal Victory Checking Error -


I'm trying to solve this issue for a few days ... here's the code ...

... Here is an error

  / "/ home / firearrow5235 / PycharmProjects / Connect 4 / Connect 4.P ", line 132, & lt; Module & gt; If Exchange (F): File "/ Home / FireRoro 5235 / PKARAM Project / Connect 4 / Connect 4.P", line 77, in Checkhouse (array [x] == array [(x + 1)] and ( Array [x] == array [(x + 2)] and (array [x] == array [(x + 3)]: index error: index index outside of class   < P> Points which populate this error are actually sporadic ... I can insert pieces in some of the seven slots without any problems ... I keep my last input The word 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o' 'O', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o' , 'O', 'o', 'o', 'o', 'o', 'o'] ['e', '@', '@', 'o' , '#', '#', '#', 'O'] ['O', 'O', 'O', 'O'] ['F', '@', '#' Enter the column that you want to leave in your piece 4, '1', '2', '3', '4', '5', '6', '7']   

And I also show that this is not the case where this problem is that

  enter the column that you want to leave in your piece 5 [A 'O' , 'O', 'o', 'o', 'o', 'o', 'o'] ['b 'O', 'o' ['c', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o' O ',' o ',' o 'o', 'o' ['d', 'o', 'o', 'o', 'o', 'o', 'o', 'o'] ['E', 'o', 'o', 'o', 'o', '@', 'o', 'o', 'o', 'o', 'o', 'o ',' O ',' o '] [', '1', '2', '3', '4', '5', '6', '7']    

I believe this is some things with your conditional:

  if (array [x] = = "#") or (array [x] == "@") and (array [x] & lt; = 4):   

If I correctly understand your code, then the final check should be done to ensure that you do x & gt; = 4 , but you have array [x]> = 4 instead.

Additionally, you can or :

  & gt; & Gt; & Gt; Want to throw some extra brackets around True or False and True True & gt; & Gt; (True or False) and false mistake.   

The conditional of both of them can contribute to the passing, and then you can get your IndexError when you Try the index X + 3

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -