(Aug-14-2019, 03:41 PM)Help_me_Please Wrote: I want to create a 4 in a row game which I can adapt to make it harder, but I want to create a game board using a 2D array, I want to create a validation method by checking the column selected is within the correct parameters. I need to fix the error given.
I concur with jefsummers and suggest of doing some planning.
For me there is still ambiguity:
- what is '4 in a row game'?
- for what and how game board will be used?
- do you need check only columns (and not rows)?
EDIT:
Some additional observations to jefsummers: at any cost try to avoid this:
# code columns = 6 # some more code def is_valid_location(board, column): if column > 6 or column <= 0: invalid = TrueAt some point in future you decide that board should have 8 columns instead of 6. You will change 'columns' value and expect your code to work same. But validation function doesn't know anything about columns. There is hardcoded 6 which is checked. As this is buried in body of function this bug will be hard to trace. Never hardcode.
For readability purposes you can instead of
if column > 6 or column <=0:
write if columns < column <= 0
.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.