Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Decision Tree Based Project

Author
Message
MetalGuitar08
14
Years of Service
User Offline
Joined: 22nd Oct 2009
Location:
Posted: 3rd Dec 2009 17:16
Hi everyone.

I need to create a Dark GDK project, which graphically displays an array of 8 coins, and utilizes a decision tree to create a game.

The game is simple, Player 1 plays against a computer AI (utilizing the decision tree). Each coin is assigned different values at random at the start of the game (1, 5, 10, 25- like coins). Each player gets a turn to pick one coin (by mouse click). One can only click on the first coin in the array or the last coin, and after each selection, that coin is eliminated from the array. The player with more points after all the coins are gone wins.


Honestly, I'm stuck, I have some coding done, but I'm in desperate need of help.

Here's my code:



#include "DarkGDK.h"
#include <string>
#include <cstdlib>
using namespace std;

struct treeNode
{
const int SIZE = 8;
array coins[SIZE];
int player1score = 0;
int player2score = 0;
treeNode * left;
treeNode * right;
};

typedef treeNode* treeNodePtr;


void DarkGDK(void)
{
string player1 = "";
string userString = "Please click one of the two selectable coins, ";

string compString = "Player 2 is now selecting a coin.";
int random;
char temp[128];

random = rand() % 2;

dbSetWindowSize(800,600);
dbSetDisplayMode(800, 600, 32);
dbLoadImage("penny.bmp", 1);
dbLoadImage("nickel.bmp", 2);
dbLoadImage("dime.bmp", 3);
dbLoadImage("quarter.bmp", 4);

dbPrint("Please enter your name: ");
player1 = atoi(dbInput());
userString = userString + player1;

dbPasteImage(1, 5, 50);
dbPasteImage(2, 105, 50);
dbPasteImage(3, 205, 50);
dbPasteImage(4, 305, 50);
dbPasteImage(4, 405, 50);
dbPasteImage(3, 505, 50);
dbPasteImage(2, 605, 50);
dbPasteImage(1, 705, 50);

dbSyncOn();
dbSyncRate(60);

while(LoopGDK())
{
//write code to implement a tree and mouse clicks
dbPrint("Player 1, please click one of the two coins.");
if(dbMouseClick() == 1)
{
dbPrint("Test.");
}


dbSync();
}

if(player1score > player2score)
dbPrint("Congratulations! Player 1 wins!");
else if(player2score > player1score)
dbPrint("Player 2 wins!");

return;
}

I'm not sure how to even construct the tree, and have very little Dark GDK knowledge, so I would appreciate it if someone would guide me through this project. First, I would like to build the tree (I only created nodes, I have no idea how to build this tree.)
If someone could help me with that initially, I'd be very thankful.

Thank you

Login to post a reply

Server time is: 2024-10-01 18:33:31
Your offset time is: 2024-10-01 18:33:31