• 0

How to be a game programmer and developer?


Question

Hello :) .I am new in this forum and i am really interested in programming.I really want to learn to program with Cuda, C++ you know. I want to make my own game engines and 3D games with stunning grafiks. I saw really interesting things in the Nvidia developer zone like Nvidia PhysX SDK, OpenGL, OpenCL, DirectX and many other stuff. I want to learn how to program with them and for what and how can i use it? What i must learn first? From what i must start? What book's i must read of i am new to software and game programming? I am really confused. Thank's :D .

Recommended Posts

  • 0

Oh you are right. I remember. Then why board[8]=value works?

I could repeat what I said in my last two posts, but what didn't you understand about these? board[8]=value worked by chance, on your machine, at the time you tested; it might stop working or do anything at any time. It's undefined behavior.
  • 0

I could repeat what I said in my last two posts, but what didn't you understand about these? board[8]=value worked by chance, on your machine, at the time you tested; it might stop working or do anything at any time. It's undefined behavior.

Ok. Then can you advice me how to make the AI? And are you are professional programmer?

  • 0

Oh you are right. I remember. Then why board[8]=value works?

I don't know how to code the AI for this Tic-Tac-Toe. Some advice?

For now, you should just make this a two-player game. AI can be added later after you have made a working board, working input, working move validation, and working victory detection. After you have all that you can add an AI player much more easily.

  • 0

What programmer are you? Do you program game engines or anything with games or you make GUI applications? And what are you developing if it isn't a secret? And the problem programming the AI is the code itself. How to do it? Can it be like the code for checking when and who will win?

  • 0

I used to write inventory control and sales software for manufacturers. Now I'm busy writing a touchscreen music player using the Windows Presentation Foundation/C#...

I think Dr_Asik writes the code that falsely tells you that your bank account is overdrawn. *evil grin*

  • 0

What programmer are you? Do you program game engines or anything with games or you make GUI applications? And what are you developing if it isn't a secret?

I worked in telecom, game programming and now I'm developing UI for flight simulators. In C#. :heart:
And the problem programming the AI is the code itself. How to do it? Can it be like the code for checking when and who will win?
Not sure what you mean. You should have a function that says if a particular move is valid, so you can validate the AI moves:

bool IsAValidMove(int x, int y) // where x, y are the coordinates of the move

Then your AI could be as dumb as trying random moves until it stumbles unto a valid one. See rand for generating random numbers. I'm sure you can figure out better strategies, that's the fun of it.

I think Dr_Asik writes the code that falsely tells you that your bank account is overdrawn. *evil grin*
Indeed, plus I added a backdoor so the penalties don't actually apply when it's me.
Ou you are colleagues.
Afaik, no. :shiftyninja:
  • 0

A question. You saw the AI of the old Tic-Tac-Toe that was 1000 lines of code just the AI? How to make it different? I mean the code was:

if (board[0]=='X'&&board[1]=='X'&&board[2]==' ')

board[2]='O'//To block the enemy attack to stop the winning of the enemy

And this code was repeated many times. How can i fix this?

  • 0

Ou you are colleagues. Cool :) . Can you answer how to make the AI code itself? I mean will it be like the code for checking when and who wins? And what do you thing for my new Tic-Tac-Toe code?

No, I believe we've only met here on Neowin... I was just being mean about the bank account code. :)

  • 0

I'll assume you're using a two-dimensional array, because it's much easier to code the AI with that.

So you have this:

char board[3][3] = 
	{
		{ ' ', ' ', ' ' },
		{ ' ', ' ', ' ' },
		{ ' ', ' ', ' ' }
	};

Then the player and the computer each use a certain character:

char playerChar = 'X';
char aiChar = 'O';

So now, all we have to do is count the Xs and Os on each row. If we find a row with two Xs and no O, then we should find the empty square on that row and play there.

void PlayAiMove()
{
	for (int y = 0; y < 3; ++y) // for each row
	{
		int numPlayerMoves = 0;
		int numAiMoves = 0;
		for (int x = 0; x < 3; ++x) // for each square in that row
		{
			if (board[y][x] == playerChar)
			{
				++numPlayerMoves; // count the number of times the player played in that row
			}
			else if (board[y][x] == aiChar)
			{
				++numAiMoves; // count the number of times the AI played in that row
			}
		}
		// If the player played twice and the AI didn't
		if (numPlayerMoves == 2 && numAiMoves == 0)
		{
			// then find the empty square on that row and play there
			for (int x = 0; x < 3; ++x)
			{
				if (board[y][x] == ' ')
				{
					board[y][x] = aiChar;
					return;
				}
			}
		}
	}
}

Then you'd have similar code to check for columns as well. A tricky question would be how to avoid repeating much of this code to check for columns, but I'll let you think about it a bit first.

  • 0

An empty IF just to get to the opposite result is a bad bad bad practise!

Yes i know. The problem is that it don't works in the normal way. What i mean is when i remove the else and making the == to != don't works. I don't know why. It return every time true. Something is wrong, but why?

  • 0

I'll assume you're using a two-dimensional array, because it's much easier to code the AI with that.

So you have this:

char board[3][3] = 
	{
		{ ' ', ' ', ' ' },
		{ ' ', ' ', ' ' },
		{ ' ', ' ', ' ' }
	};

Then the player and the computer each use a certain character:

char playerChar = 'X';
char aiChar = 'O';

So now, all we have to do is count the Xs and Os on each row. If we find a row with two Xs and no O, then we should find the empty square on that row and play there.

void PlayAiMove()
{
	for (int y = 0; y < 3; ++y) // for each row
	{
		int numPlayerMoves = 0;
		int numAiMoves = 0;
		for (int x = 0; x < 3; ++x) // for each square in that row
		{
			if (board[y][x] == playerChar)
			{
				++numPlayerMoves; // count the number of times the player played in that row
			}
			else if (board[y][x] == aiChar)
			{
				++numAiMoves; // count the number of times the AI played in that row
			}
		}
		// If the player played twice and the AI didn't
		if (numPlayerMoves == 2 && numAiMoves == 0)
		{
			// then find the empty square on that row and play there
			for (int x = 0; x < 3; ++x)
			{
				if (board[y][x] == ' ')
				{
					board[y][x] = aiChar;
					return;
				}
			}
		}
	}
}

Then you'd have similar code to check for columns as well. A tricky question would be how to avoid repeating much of this code to check for columns, but I'll let you think about it a bit first.

Ou this is really complicated. I think i understand the code, but it's really complicated. but really good written. Then i will make my program with a 2D array, but not now. I must go to sleep. When i am ready with it i will post the code.

PS: Can the AI be created with a 1D array? I don't thing it will be created in this way, but this is the best way with the 2D array AI i thing.

  • 0
PS: Can the AI be created with a 1D array? I don't thing it will be created in this way, but this is the best way with the 2D array AI i thing.
You can do it with a 1D array, but when you try to go row-by-row and column-by-column to check for wins, it's not as intuitive. A 2D array gives you rows and columns already, whereas you have to calculate them with the 1D array, e.g.

board[3 * rowIndex + columnIndex ] = value;

instead of

board[rowIndex][columnIndex ] = value;

  • 0

Yes i know. The problem is that it don't works in the normal way. What i mean is when i remove the else and making the == to != don't works. I don't know why. It return every time true. Something is wrong, but why?

It could be you're comparing equality between a char and a number. '1' is never equal to 1. One is a character and one is an integer.

You could use

isdigit(input)

to test and make sure the entry is a number, then cast it to a character.

  • 0

No the problem is that the condition doesn't make sense.

Let's make this more simple:

if (myChar != '1' || myChar != '2')
{
    // code
}
else
{
    // unreachable code
}

The condition says: myChar is not '1' OR it's not '2'. So let's see the different possibilities:

myChar is 0. It is not '1', therefore the condition is true.

myChar is 1. It is '1', but it is not '2', therefore the condition is true.

myChar is 2. It is not '1', therefore the condition is true.

myChar is 3. It is not '1', therefore the condition is true.

etc.

Therefore the condition is always true, and the "else" is unreachable.

In boolean algebra, this is equivalent to:

if (!(myChar == '1' && myChar == '2'))
{
}

where the error is much more obvious. myChar cannot be both 1 and 2 simultaneously.

  • 0

No the problem is that the condition doesn't make sense.

Let's make this more simple:

if (myChar != '1' || myChar != '2')
{
    // code
}
else
{
    // unreachable code
}

The condition says: myChar is not '1' OR it's not '2'. So let's see the different possibilities:

myChar is 0. It is not '1', therefore the condition is true.

myChar is 1. It is '1', but it is not '2', therefore the condition is true.

myChar is 2. It is not '1', therefore the condition is true.

myChar is 3. It is not '1', therefore the condition is true.

etc.

Therefore the condition is always true, and the "else" is unreachable.

In boolean algebra, this is equivalent to:

if (!(myChar == '1' && myChar == '2'))
{
}

where the error is much more obvious. myChar cannot be both 1 and 2 simultaneously.

I think you are not right, but when i am looking in your answer i see some mistaces. I am not sure if they are, but i think the second and thirth case must return false, because it must be not 1 or 2. In the second case it is 1 and because i must be not one it will return false. In the thirth case it is 2 and it will return false, because it must be not 1 or 2.

  • 0

I think you are not right, but when i am looking in your answer i see some mistaces. I am not sure if they are, but i think the second and thirth case must return false, because it must be not 1 or 2. In the second case it is 1 and because i must be not one it will return false. In the thirth case it is 2 and it will return false, because it must be not 1 or 2.

Nope, he's right, the if clause will always equal true because its an OR.

if (myChar != '1' || myChar != '2')

{

// code

}

else

{

// unreachable code

}

myChar is 1:

(myChar != '1') => false

(myChar != '2') => true

false OR true => true

myChar is 2:

(myChar != '1') => true

(myChar != '2') => false

true OR false => true

myChar is 3:

(myChar != '1') => true

(myChar != '2') => true

true OR true => true

For that if clause to produce a false output, you need a variable that's equal to 1 and 2 at that same time, which is not possible.

And that's why most people in this thread were focusing on improving core skills, not just programming but also elementary things like logical equations.

  • 0

I think you are not right, but when i am looking in your answer i see some mistaces. I am not sure if they are, but i think the second and thirth case must return false, because it must be not 1 or 2. In the second case it is 1 and because i must be not one it will return false. In the thirth case it is 2 and it will return false, because it must be not 1 or 2.

He's right. Your if statement will always be true because it's impossible for a number to be two different numbers at the same time. The only way your if statement would be false is if the laws of physics suddenly changed or a number was given that was out of range (a number other than 1 through 8).

Your if is checking to see if myChar is a 1 or a 2 or a 3 or a 4 or a 5 or a 6 or a 7 or an 8. Any one of those will make the if statement true.

  • 0

For now, you should just make this a two-player game. AI can be added later after you have made a working board, working input, working move validation, and working victory detection. After you have all that you can add an AI player much more easily.

The Tic-Tac-Toe is already ready.

He's right. Your if statement will always be true because it's impossible for a number to be two different numbers at the same time. The only way your if statement would be false is if the laws of physics suddenly changed or a number was given that was out of range (a number other than 1 through 8).

Your if is checking to see if myChar is a 1 or a 2 or a 3 or a 4 or a 5 or a 6 or a 7 or an 8. Any one of those will make the if statement true.

No, it must check if it's not 1, 2................ And for that it must return false every time of it is a 1, 2.................., but it don't works with the !=. I don't now why.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Wow, imagine you dump hundreds of hours into completing things and unlocking stuff and you lose it all. Back in the day when cheats were built into games, you could at least unlock things again that way without spending hundreds of hours again. But those days are long gone for some reason as no one builds cheats into games anymore. So it's even more painful that studio that's on its 6th installment **** it up so badly.
    • Spotify finally removes the disco ball app icon in the latest update by Ivan Jenic Image: Spotify Spotify has just released an update that removes its now infamous disco ball icon. The update reverts the app icon to the familiar flat green logo after weeks of mixed reactions online. The icon arrived on May 13 as part of the company's 20th anniversary celebration and was always intended to be temporary, though Spotify only confirmed that after the backlash started. The disco ball took the internet by storm, as the reception was split. A vocal group of users called it ugly and disorienting, with some iOS users noting that the 3D glowing effect made the app look like it was stuck mid-update. On the other end, the icon picked up a following of its own. Its retro, three-dimensional look immediately stood out against the flat, minimalist aesthetic that has dominated app design for years. It even started a small movement, spawning what people started calling "discomorphism," a mashup of disco and skeuomorphism. Other brands started posting disco ball versions of their own logos, probably in an effort to ride the wave of memes that flooded the internet during late May. Spotify has had a turbulent relationship with its user base lately. Besides the disco ball icon, which certainly wasn't appreciated by everyone, the company has also received backlash for its willingness to include AI-generated music on its platform. On May 17, Spotify promised the old icon would return “in a few weeks.” And now it looks like that time has finally arrived. So, whether you liked the disco ball or it made you uncomfortable, it’s now gone for good. The next time you update the Spotify app on your phone, the old, flat-design icon will return.
    • Playground Games confirms Forza Horizon 6 save wipe bug by Taras Buria Forza Horizon 6 was launched last month to critical acclaim (check out our review here), and it became a smash hit in an instant. Now, weeks into the launch, with die-hard fans clocking hundreds of hours, Forza Horizon 6 is facing a serious issue: save wipes. After multiple complaints on Reddit and social media, the studio issued a statement. The problem with missing saves came shortly after Playground Games promised the initial batch of gameplay tweaks and improvements. Unfortunately, there seems to be no temporary fixes for those affected by unexpected save wipes. However, the studio published a new support document with a few important steps users should try. First, affected gamers should open a support ticket immediately (go here to file one) so that the support team can try recovering the lost progress by reverting to an earlier save. Playground Games says this should be done the same day the issue occurs. Meanwhile, gamers are urged not to start new play sessions or create new saves. The studio also published a few things gamers should try to avoid to prevent potential progress loss: Ensure your Gaming Services app on PC or XBOX Series X|S console is fully up to date. On XBOX Series X|S consoles, disable Quick Resume for Forza Horizon 6: To disable Forza Horizon 6 from using Quick Resume, highlight the game box art anywhere in the console experience (Home, My Games & Apps, Pins, etc) and then press the Menu button, then go to Manage game and add-ons > Quick Resume settings > Disable Quick Resume. Ensure you are online when ‘quitting’ the game. Give your saved time to sync to the cloud before powering off or switching devices. Do not force quit the game during save screens. Do not power off the device during gameplay. Always "Quit" (console) or "Exit to desktop" (PC) once you've finished your play session, ensuring the save icon is not visible when you’re closing the game. Before turning off your console, shutting down your PC, or force-closing the Steam app, give your devices or clients at least a few minutes to ensure your latest progress has been synchronized with the cloud. This will reduce the risk of progress reversions as you switch between different platforms. XBOX Series X|S consoles, Steam, and the XBOX app on PC all include game save indicators that confirm your progress has been synced. You can read more about the bug in the official support document here. Forza Horizon 6 is currently available on PC (Steam and the Microsoft Store), Xbox Series X|S, and Game Pass. The game is also coming to PlayStation 5 later this year.
  • Recent Achievements

    • One Year In
      slackerzz earned a badge
      One Year In
    • One Year In
      highriskpaym earned a badge
      One Year In
    • One Month Later
      highriskpaym earned a badge
      One Month Later
    • Week One Done
      highriskpaym earned a badge
      Week One Done
    • Week One Done
      FBSPL earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      519
    2. 2
      PsYcHoKiLLa
      198
    3. 3
      +Edouard
      158
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      75
  • Tell a friend

    Love Neowin? Tell a friend!