c# - Hint algorithm problems in a Bejeweled clone -
i've got slight issue hint algorithm bejeweled clone. right now, following code produces 'hint' @ top left of board every time hit h key (the key showing hint).
public bool aretheremoves(gem[,] gem2) { hintgems.clear(); return (aretheremovesdown(gem2) && aretheremovesright(gem2)); } public bool aretheremovesright(gem[,] gem2) { hintgems.clear(); (int x = 0; x < gem2.getlength(0) - 1; x++) { (int y = 0; y < gem2.getlength(1); y++) { gem[,] gems3 = new gem[gem2.getlength(0), gem2.getlength(1)]; array.copy(gem2, gems3, gem2.length); swapgemscheck(x, y, x + 1, y, ref gems3); if (checkmatches(gems3, 2) || aretherespecialgems(gems3)) { hintgems.add(gems3[x, y]); return true; } } } return false; } public bool aretheremovesdown(gem[,] gem2) { hintgems.clear(); (int y = 0; y < gem2.getlength(1) - 1; y++) { (int x = 0; x < gem2.getlength(0); x++) { gem[,] gems3 = new gem[gem2.getlength(0), gem2.getlength(1)]; array.copy(gem2, gems3, gem2.length); swapgemscheck(x, y, x, y + 1, ref gems3); if (checkmatches(gems3, 2) || aretherespecialgems(gems3)) { hintgems.add(gems3[x, y]); return true; } } } return false; }
right now, code bit kinky special gems hints. in, won't show hint on hypercube.
when tried using plain aretheremoves()
method in check end of game, didn't function @ all. have testing both down , right methods in end of game check.
my question is: how go changing puts hint on actual move?
if there other information needed, please don't hesitate so.
edit:
here's hint popup code:
public void showrandomhint() { if (hintgems.count == 0) return; gem g = hintgems[main.rand.next(hintgems.count)]; g.sparkle(main.rand); addtext(new vector2((getgemposition(g)[1] - 1) * gemsize + (gemsize), (getgemposition(g)[0] - 1) * gemsize + (gemsize)) * new vector2(1.08f, 1.08f), "hint!", 2f, color.aqua, outlinecolor: new color?[1] { color.gold }, amt: .01f); }
and code calls it(in board.update):
if (checkmoving()) hinttimer++; else hinttimer = 0; if (hinttimer >= hintdelay) { showrandomhint(); hinttimer = 0; }
Comments
Post a Comment