Almost done project (90%) - need quick help

hey, I know the code might look complicated at first, but it’s not! I figured out everything, and I`m trying to get working the very last feature of the game.
First of all the game is based on the real game called Checkers. almost everything is working except one thing :
After I destroied an opponent checker, I want to check if it’s possible to destroy another checker with the same conditions. ( which means, the conditional is that if there’s a checker in one of the 4 diagonal +1 + 1, -1 + 1 , +1 - 1, -1 -1. an opponent checker, it’ll check in the chosen newX,newY which is “replacing” all the “1” numbers above to 2. like jumping over them… my explanation is awful for people who never played this game before, this is a simple game btw. google it for more info.

so first of all I want to check if it’s possible to eat(destroy) again with normal(there’re also king) checkers, and then, with king checkers which is a bit harder because I need to loop all the 7 squares and to check the first element array that it found and to also check that there’re more of them before the newX,newY opponent checkers.

Anyways, Here’s the code :
http://pastie.org/778586
http://www.pasteit4me.com/99079
What I`m trying to do which also gives a bug starts from line 356.

the bug it gives me is simple :
after I destroied the opponent checker with my checker, it still keeps that checker selected and also, I must go with it once more even if the conditions that are set-uped aren’t true, which means, even if there’re no opponent checkers surronding it,etc… why? how to fix that so it’ll move again only if there’re opponent checkers surronding it and it’s possible to do a destroy opponent move.

*Note :No errors! It’s just a non-completed code, and I tried for many hours to finish that code, but everything I tried to add from the current code has failed.

I hope Ill get some help from you guys.. also, you'll be credited in the tutorial Ill release to the unity community. thank you!

bump

Weren’t you banned?

–Eric

Eric, Yes, my previous account was banned because of something that is illegial to do.

Please next time, keep your thoughts to yourself or just pm me and ask me those questions.

I`d like to get some support about the project, Especially from you. Thanks!

bump

bumping :frowning: :shock: :x :?: :!: :idea:

AnaRhisT12 will you write my game for me? I have no initiative or desire to learn.


I’ll even give you $3 if you write my code for me.

Here’s what I have so far.

10 ? "HELLO WORLD "
20 GOTO 10

BUMP
BUMP
BUMP
BUMP

Quietus,
Why do you refer to my request like that?
I didn’t ask to write my code.
I`m having difficulties to finish it, and np, I can give u the whole codes I try to add to the current code to fix it, so I don’t understand, is that so hard to give ideas,suggestions,psuedo-codes?

Again,
to difficulties : Im not asking you to write for me the game, Im asking you to support me with any ideas you’ve.
*Note : If it’ll help you to not say that I want you to "write’ my game then I can show you my failures so you won’t tell me that I want you to “write” my game?

erm… Quietus I really didn’t like you answer, take ur post and push to your ass.
I hate people that post negative posts in that childish level.

Any positive posts that refer to my request will be appreciated, thanks.

bump

Past experience.

Seems that banning isn’t what it used to be. Changing nick somehow negates previous illegal activity?

The account was banned to prevent the activity which was happening, I don’t think it was intended to prevent someone from ever asking for help on a project again. The purpose of the account ban is in effect, the user knows what not to do, and the issue has been removed from the forum.

In regards to the project at hand, AnaRhisT12, I think you should consider doing a series of smaller, much simpler projects (not necessarily full games) which help develop your knowledge of Unity and your expertise in programming. You will be able to solve the problem you have with this Checkers game when you come back to it after some other projects.

Set a global boolean that is something like

bool CurrentlyMoving;

In your start, set this to false, now, when it is the players turn, set this value to true, you might ask me, why bother, well you want to have a method setup as part of your move routine that says if CurrentlyMoving and logic for checker states check not met, stay moving.

So if it is playerTurn 0 (red), and CurrentlyMoving = True, if checker placed position != last position of checker, check the adjacent squares, if any of those adjacent squares contains player 1 (white) then check only squares who’s angle is valid, so since in checkers youre limited to moving diagonally, and UP (red) or DOWN (white) while not KING, then you only have to check 2 slots, you need your grid to be in an array or hashtable, so you can easily check the points, once the check is complete and no valid move is availble, set CurrentlyMoving to false and switch players. (Or call it what ever you want, but you need some balance)

If the board is as follows:
X01234567
0EWEWEWEW
1WEWEWEWE
2EWEWEWEW
3EEEEEEEE
4EEEEEEEE
5RERERERE
6ERERERER
7RERERERE

This is the start position of all points, E = Empty, W = White, R = Red, now with any grid based game, you need to keep a map of coordinates. X in this grid doesn’t mean anything, just a place holder for text on this screen, 0,0 being the Empty square, 7,7 being an empty square, you get the point on the rest.

So, now take this into the depth of movement, Red turn, moves to (X,Y) of chip 0,5 to space 1,4 well you have this code kinda (I just glanced over it, didn’t soak it in) you have made a move, you are done, but lets assume for a second you had JUMPED into that position where you are now stuck in your code, you say, was the last piece moved a RK? (Red King), well, no it isn’t, so maybe you need another boolean or string that determines your piece moved, but anyway, moving on, you are now in 1,4 what is the legal moves for that piece? (meaning next move in sequence), well that is of course 0,3 and 2,3 ONLY, now you ask in your code, is there a W or WK in either 0,3 or 2,3? Let us assume for a second that the answer is YES, now we need to know one more rule, lets assume that you have a piece in both 0,3 and 2,3 that makes the rule a yes, now you need to know if the player can still continue, so we have a normal Red piece, can only move UP so what are the next legal steps in this one case, well 0,3 is on the LEFT edge of the board, so no more legal moves for a jump, so all though 0,3 has a piece, no legal jumps can happen UP, so now lets look at 2,3 the next legal landing spot is 3,2, now all you have to know, is that spot empty or not, that is as far as the logic needs to go, if the spot of 3,2 is empty being true, then it is still Red’s turn, done.

If 3,2 is not empty, turn is over.
Now you just have to transpose that article into code.

First of all, thanks for the reply.
now, about your reply, after this sentence:
"If the board is as follows: "
all what u wrote below that sentence is already done.
because i`m storing the checkers in 2d array, and then applying the new position as an old position.

now, about the thing that i need to check if there’re valid moves after it moved AND destroied once, i want to check diagonally up left, up right, AND up downLeft,downRight because when it destoried it can check wether there’re OPPONENT checkers in ONE of the 4 diagonal ways.
that’s the only thing i want to do, after it, i want to check it with a king, and i`m done :slight_smile:

Ok, well, I guess I am confused then, you have 1 array for the board positions and who is in what position. You need 3 rules, one for white player, one for red player and one for all kings. You need 3 different loops to keep your itterations to a minimum,

if(player==0) // red
Only deal with a loop that checks moving “UP” direction.
if(player==1) // white
Only deal witha a loop that checks moving “DOWN” direction
if(isKing) // red or white, but king
in the isKing rule, use a switch/case statement for destroy gameobject

logic check would be piece location x,y of ±2,±2 for empty spot in the array. You just want one of the 4 to return true to keep the CurrentlyMoving to be true and you can’t be <0 || >7 on the x or y else you are going off the board.

That is pretty much your logic without code.
You could combine all that into a single code block but would mean more itterations during the checks, not that it matters in a checkers game logic speed.

again, if you’ll look at the code, all of that is DONE.
i just want to do the final step.