C++ :: Creating Computer AI For Tic Tac Toe Game

Dec 24, 2014

How I can go about creating a computer AI given the way that I structured my code.

main.cpp

Code:
#include <iostream>
#include "Board.h"
#include <limits>
#include <cctype>
using namespace std;
int main() {
// Welcoming message.

[Code] ...

View 14 Replies


ADVERTISEMENT

C++ :: Guessing Game Program - Ask User To Guess Computer Generator Number

Feb 11, 2013

I'm currently creating a guessing game program where the user will be asked to guess the computer generated number. Once the program is finished, at the end the user will be asked if they want to play again. If the user types "Y or Y" the program will loop and when the user types "n or N" it will not loop. Check out my code below.

#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#define g gotoxy
void main(){
int a,l,b,guess,row,col,answer,num,clue=5;

[Code] ....

I can't loop this program.

View 3 Replies View Related

C++ :: Creating Game Using SFML

Apr 26, 2014

I'm currently working on a 2D space shooter game in C++ using SFML library. What I need to know is how make an object (ex:laser) fire up from object (ex:player) when a user press button??

View 1 Replies View Related

C :: Creating A Kind Of Connect 4 Game

Nov 14, 2014

I'm creating a kind of connect 4 game that will be due on November 30. I'm starting now so that I don't have to worry about it as much later. Anyways, I just started, and I already have some questions/problems. I want to be able to change that numPlayers outside of the function, so I used pointers like my instructor said to, but it is giving me an error that numPlayers(the argument) is not an int*. How do I fix this?

Code:

int numPlayers=0;
void promptNumPlayers(int *numPlayers)
{
printf("Enter the number of players: ");
*numPlayers=readInt(stdin);
if (*numPlayers != 1 && *numPlayers != 2)
}

[code]...

View 3 Replies View Related

C/C++ :: Creating Moving Objects For 2D Game

Oct 21, 2014

I'm working on designing a game in C++ that is similar to the "find the ball under the cup" game. I have a Sonic the Hedgehog icon (weird I know, but it was the first thing that came to mind) that will be hidden underneath one of three rectangular blocks.

Here is how I envision this working:

On the main menu I have 3 buttons which represent 3 different difficulty levels
Easy- blocks move 3 times at a slow speed
Medium- blocks move 5 times at a slightly faster speed
Hard- blocks move 10 times at a fast speed

When the user clicks one of these buttons they will be taken to the game screen.

Sonic will be displayed for 3 seconds and the user will then see him be covered with one of the three blocks.

The three blocks will then move in a random pattern along the middle of the screen at the speed and number of times associated with the button that was pressed.

Once the blocks stop moving, the user is to click on the one they think Sonic is underneath.

If they choose correctly, they'll be taken to a "Winning Screen" that displays a congratulatory message and 2 buttons. Play Again- returns the user to the main menu and the game starts over with a new random pattern. Quit- the window closes.

If they choose incorrectly, they'll be taken to a "Losing Screen" that displays a "Try Again" message and 2 buttons that have the same function as the buttons on the winning screen.

I have never worked with any kind of graphics before other than in HTML and Javascript. I have managed to create the main menu, but how to do the actual game portion of the project. I've been trying to take it a step at a time, (for example, I first figured out how to set the background color for the console window, after I got that right I figured out how to add buttons) but the rest of this seems to depend on each other.

Here is what I have so far:

Main menu:

#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
class MainMenu

[Code]....

So I've got the screens pretty much designed now (with the exception of the game screen itself) but how to tie everything together.

In case my description wasn't too clear, here is a game that I found on Google that is pretty much exactly what I'm looking for. [URL]

View 2 Replies View Related

C/C++ :: Tic Tac Toe Game - Creating A Menu/choice

Nov 11, 2014

Im trying to create something like a menu in a tic tac toe game. I want the computer to ask the user "who starts first" is it the X or the O who starts first? Then the user should type in either X or O but if he types something else i want to ask again .

this is what ive done :

int main () {
printf("
");printf("
");
printf(" %c | %c | %c
", board[1], board[2], board[3]);

[Code] .....

View 10 Replies View Related

C++ :: Creating 2 Dimensional Console Base Game

Jun 13, 2013

what i got so for my code.

#include <iostream>
#include <windows.h>
using namespace System;
using namespace std;
int refreshDisplay(int , int);
const char wHole = '@';

[code]....

count <<" The oblective of the game is for the player to move around a 2 dimensional playing field and capture the star withought falling into a black hole or walking off the edge of the playing field. The controls are W = up S= down A=Left D=Right" <<endl; how implement 3 black hole X characters and 2 wormhole characters on field @ and a star *. all these char has to be randomly generated.

View 1 Replies View Related

C++ :: Creating A Game - Use Classes For Rendering Objects?

Mar 16, 2014

I am creating a game and I using classes for other things in my game, I was wondering if i should use classes for rendering objects?

View 2 Replies View Related

C/C++ :: Creating Two Dimensional Terminal Based Game?

Apr 4, 2014

i am working on class project in which i have to save the tank from canon....imy tank is moving only when i press the moving key.. and after that i see blank screen what should i do to run my process when i am not pressing moving keys....

View 8 Replies View Related

C# :: Creating A Class And Methods For Dice Game?

Mar 21, 2015

The only difficulty im having is creating a class and methods & being able to access them from my win form app. Can i get a few tips on the do's and donts of creating classes / methods and accessing them from form app.

This is what i have put together so far.

public partial class Form1 : Form {
private Image[] dicePics;
private int[] diceNum;
private Random randomize;
public Form1() {
InitializeComponent();

[code]....

View 3 Replies View Related

C :: Creating Match-3 (Candy Crush) Game Using Arrays

Mar 6, 2015

I'm supposed to create a "game" that is similar to Candy Crush or Bejeweled. The assignment takes in a .txt file that contains a matrix of values from 1-5 and then assigns each value to a spot in a [10][10] array. Then an Escape Code function prints out colored pixels in place of the number values for each spot, creating a "game board" looking output. Finally, the program is supposed to look for any matches of 3 same-colored pixels and replace them with a white pixel and "XX". Then the program prints the corrected game board with the matches X'd out.

I have it mostly coded, but I've encountered a couple of issues.

1.) I am supposed to label the columns and rows 0-9, and while I have no problem coding the labels for the columns using printf( ), when I try to print the row labels I get a random string of numbers.

2.) I replaced the matches with white pixels by reassigning the value in the array to 7, for which the ANSI Escape Code is white. However, I'm unsure about how to print the "XX" in the same spot.

Here is the input(.txt) file and the output of the program so far:

And here is what I have coded at this point:

Code:
#include <stdio.h>
void printEscapeCode(int c);
int main(void)
{
/* Declare an image array to be gameboard */
int gameboard[10][10];
/* Declare variables and load in how many rows and columns */
int Nrows;
Nrows = 0;

[code]....

View 2 Replies View Related

C++ :: Creating Frog Leap Game That Starts At 1 And Finishes At 12

Feb 13, 2015

I have been given the task of creating a frog leap game that starts at 1 and finishes at 12. The layout is as follows. The '@' symbols are just included to show blank white space.

1-----2 @@ 3---4
|@@ |@@@ |
|@@ |@@@ |
5@@ 6------7-----8
|@@ @@@ |@@ |
|@@ @@@ |@@ |
9----10 @ 11 @12

Each number within the game will represent an object, the user will have to reach the 12th leaf start from leaf 1. the frog can only move in the directions of forwards backwards, left and right. Any starting points? E.g. using and array or list? i have a feeling this is going to be a big task. is inheritance possible?

View 1 Replies View Related

C++ :: Creating Game That Will Test The Attention And Mind Flexibility Of User

Mar 6, 2015

I want to create a game that will test the attention and mind flexibility of the user. So the challenge is The user will be given 50 rounds, and each round should generate a random combination of text and words.Then the user must Press 'Y' if the UPPER CASE text spells out a color that match the BACKGROUND. But if the text are in LOWERCASE the user must press 'N'.(Note: you can change the keys to any key from the keyboard if you wish to)

Then I also want my program to record the high score each time the program prompts the user if he/she wishes to play again.

I also want to control the combinations by NOT allowing the text color and background color to be the same.

I also want the combination to generate an AVERAGE of 50% correct combination and 50% wrong combinations. The I want to use is only Red, Blue and Green

HIGH SCORE Determinants:

1. Accuracy ( (Number of corrects / 50 ) * 100% ) - The higher the better.
2. Time in seconds (Time Ended - Time Started) - the lower the better.

Computation for high score: 10 000 * ( (Accuracy) - (2 x total Attempts - Time) )

View 6 Replies View Related

C++ :: Spaceship Game - Creating Gravity For Each Object Depending On Mass

Mar 27, 2012

I've been having trouble working on this physics engine of mine. Right now I'm having trouble adding gravity.

The game is a spaceship--which you control--flying around in space with asteroids and eventually the ability to shoot bullets. There should be a wrap on the edges of the screen and gravity for each object depending on their mass.

I'm creating a forceX and forceY for each force put onto each object, and then computing that force into a velX and velY which will determine the direction of each object and at which speed.

Where my problem arises:

Code:
//add gravity pulls to forces
for(int i = 0; i <= pushCount; i++) //add gravity pulls for each object {
for(int u = 0 ; u <= pushCount; u++) //each object should add a force for every other object {
if(i != u) {
switch(id[i])

[Code] ....

View 7 Replies View Related

Visual C++ :: Dice Game - Creating Pass By Value Function Reference

Nov 27, 2014

i have a project where i create a dice game, the user rolls 2 dice and the computer roles 2 dice. the player that wins 3 out of 5 rolls wins the game. I have completed the requirements, but i wanted to create a pass by value function for "void Dice()", I'm not too sure how that works?

Code:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
//creating my variables and their values
int compinput;

[Code] .....

View 5 Replies View Related

C++ :: Creating A Game - Read Prices Of Object Inputted By User From A File

Feb 19, 2013

How do i read a specific part of a file? I am trying to create a game that reads the prices of an object inputted by the user from a file. This is the code i have so far

#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream infile;
infile.open ("Objects.txt", ifstream::in);

[Code] ....

The file contains this :

Example objects
( ) store items
(item) (purchase value)/(sell value)

Grocery Store Items
Fish 5 7
Vegetables 10 15
Drinks 20 30

Weapon Store Items
Pistol 300 375
Rifle 400 500
Ammunition 20 30

View 4 Replies View Related

C++ :: Game Design Practice For Accessing Container Of Game Objects

Dec 21, 2014

I'm working on my first video game. So far I have a few classes in the game starting with the Game class which includes a list of GameObjects (another class). There are several classes that inherit from GameObjects used to implement things like bullets, explosions, various enemy types, etc.

The game essentially iterates through the list of GameObjects to update/render them. I would like to provide access to the Game's list of GameObjects inside another class (like the Bullet class) so I can put new objects on the list. For example, when a bullet hits, I want to add an explosion to the Game's GameObject list it can be updated/rendered.

How this should be setup? I was considering adding a pointer to the Game or GameObject list to the GameObject class (and methods to access it), but I was wondering if there is a better way to set this up?

View 4 Replies View Related

C++ :: Program For Calculating Total Price Of Game Station And Game

Sep 13, 2014

I would like to make a program for calculating the total price of a game station, and a game. I made a program like this for just the price of a game in class, but I want to make one that does the game system as well.

View 7 Replies View Related

C :: How To Get Remote / External IP Of Computer

Oct 20, 2013

I am starting to learn C, its quite an easy language to learn from the basics, I hope to learn others as time goes, I wonna know how do I get the external / remote IP of a computer?

View 6 Replies View Related

C++ :: Transfer TXT File From Computer A To B?

Aug 4, 2014

how could I transfer a .txt file from Computer A to Computer B using c++. (over LAN)

View 3 Replies View Related

C# :: Run Console App On Remote Computer?

Dec 22, 2014

I'm looking for a way to run my console app in C# on one computer, but the actual program is ran on another computer. IE I open the file or hit "Run" in Visual Studio on computer1, the computer2 runs the program. I was looking online and found some stuff that may be applicable, but I didn't see a very clear answer.

View 6 Replies View Related

Visual C++ :: Input X And Y To Computer Sin / Cos

Dec 11, 2012

input X and Y then write the program to compute

Sin(X++) Cos(Y--);Sin(X+X),Cos(Y--)

and write your conclusion for

X=46 & Y=90

View 5 Replies View Related

C++ :: Function To Search For A File In Computer

Apr 4, 2013

#include <iostream>
#include <cwchar>
#include <string>
#include <Windows.h>
using namespace std;
#include <shellapi.h>
#pragma comment(lib,"shell32.lib")
static HWND hBut;
#define ShellExecute;

[Code] ....

My function is the issue. I'm not sure how to write a correct function to search your computer for file 'a'.

View 3 Replies View Related

C++ ::  Reading Files Saved On Computer

Jul 20, 2014

I can't seem to get my program to read a file that's saved on my computer. Here's my code:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream inputfile;
string name;

[Code] ....

View 6 Replies View Related

C++ :: Access Registry Of A Computer Within Domain

Aug 6, 2013

I have to implement code in such a way that form one system in a domain we have to change registry of other system within the domain.

View 4 Replies View Related

C/C++ :: Saving Sequential Files To Computer?

Feb 2, 2015

[size="5"][size="4"]

I am programming in C and am having some trouble finding the .txt file I saved after having run my program. It is likely a stupid error on my behalf. However, it is causing me quite a bit of grief at the moment. I attached my source code below  
abgcchp27ex1.txt (2.01K)

I coded my structure within my header file(bookInfo.h) correct along with everything else. My dilemma is a matter of my file location and whether it actually saved.

/* This program takes the book info program from chapter 27 and writes the info to a file named bookinfo.txt. */

// First include the file with the structure definition

#include "bookInfo.h"
#include
#include
FILE * fptr;

[Code]....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved