A checkers or other similar "board" game
Posted:
Thu Jul 22, 2010 4:35 am
by Toasterman
I have been wanting to make a basic board game that operates on a grid -like chess or checkers- for a while now, but am unsure as to how to set up the grid.
More specifically, how the actors would check if a potential space is occupied. I'm not worried about the AI just yet -I can make that later- but rather the basic foundations that would allow a peice to move around the board while not moving onto other peices.
I have a basic knowlage of other object-oriented languages (like adobe flash's actionscript) but I'm reletively new to Game Editor
Any help would be greatly appreciated as well as links to other tuturials etc.
(my crummy dial up may prevent any prompt updates on my part)
Re: A checkers or other similar "board" game
Posted:
Thu Jul 22, 2010 4:45 am
by jimmynewguy
Hello, and welcome!
Here is a checkers demo made by Makslane:
viewtopic.php?f=6&t=5188&p=34711&hilit=checkers#p34711This should get the basic and advance concepts out of the way, as long as you understand
If you need any help, just ask around. There's plenty of smart coders around these parts!
Re: A checkers or other similar "board" game
Posted:
Thu Jul 22, 2010 4:53 am
by DST
Create an integer array, you can use the variables tab or create one in global script; make it 64 in length.
int board[64];
At any time, you can use a timer or Actor*loop to enter each actor's coordinates into the array. You should make the game so the 0 coordinate (Game Center) is the upper left corner of the board, to make things easier. If your squares are, say , 50x50 pixels each:
int s1=round(x/50); //how many squares from 0
int s2=round(y/50);
int mycell=s1+(s2*8); //xsquare (horizontal) + 8 for every vertical row. This is the core of 1d arrays to make 2d boards.
board[mycell]=1; //show that square is occupied.
A pawn can then easily search the array for (mycell+8) to see if it can move forward, and (mycell+9) & (mycell+7) to see if it can capture.
Eventually you will want to make it a 2d array, (int squares[64][5]) as the 2nd slots would be used to store all the information about a square when you do construct the AI:
0: is this square occupied (can i move here)
1: what color is on it (can i capture here)
2: What can i put in danger by moving here (is this an advantageous square)
3: how many other opposite pieces can capture this (is this a dangerous square)
4: if opposite side piece, is it already in danger (do i need to capture here)
5: will i protect more of my pieces now or if i move to this square (is this an advantageous square)
From this point of view, AI is relatively simple, as you search the array for each piece, ask those 6 questions about every possible move that piece has, and find the piece/square combo with the highest number of positive answers.
Re: A checkers or other similar "board" game
Posted:
Thu Jul 22, 2010 3:40 pm
by Toasterman
Thanks for the help!
Finally the answer to a nagging problem that has bothered me for some time!