• 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

I probably don't. I got quite lost as that course went on. I understood the theory but was terrible at implementing it. And yes, AI in games often means things that aren't true AI.

That's what i mean :) . Ok so i want to comment something that you sad. You sad that i am ignoring the 3rd one. That's not true. I am searching every day for more information for what i don't know. I think you know perfectly what i don't know that i don't know :) . Then i will be happy if you tell your secret :) .

  • 0

Well... yes, depending on how simple that AI is. As I just illustrated, you can make a very potent Tic-Tac-Toe AI with a few if statements. It doesn't answer unmodified Jeopardy questions in real-time but you still have to try pretty hard to beat it. :p

I usually have nothing but respect for your posts Dr_Asik, but in this case you're wrong, you made a static decision engine. AI is a whole different ballpark mate.

  • 0

I've never read from an authoritative source that learning was an essential component of any AI. According to Wikipedia, as I've previously quoted:

AI textbooks define the field as "the study and design of intelligent agents"[2] where an intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success.[3] http://en.wikipedia.org/wiki/AI

I think my little function with 3 if statements can be defined as

  • "a system that perceives its environment" (it has access to the tic-tac-toe board data)
  • "and takes actions" (it produces moves)
  • "that maximize its chances of success" (it uses rules to play the best possible move).

It is therefore an intelligent agent which the object of AI.

I'm open to different point of views of course but not without argumentation.

  • 0

This is difficult to answer. Many will think that it is AI and many will thing that it isn't AI. And i am not really sure if it is, but the thing that makes it a little intelligent is the random moves.

In the context of a game, any code that defines the behavior of a computer-controlled opponent is considered "AI". Outside of games it requires the ability to learn. Like many words, it has different meanings depending upon context.

  • 0

I've never read from an authoritative source that learning was an essential component of any AI. According to Wikipedia, as I've previously quoted:

AI textbooks define the field as "the study and design of intelligent agents"[2] where an intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success.[3] http://en.wikipedia.org/wiki/AI

I think my little function with 3 if statements can be defined as

  • "a system that perceives its environment" (it has access to the tic-tac-toe board data)
  • "and takes actions" (it produces moves)
  • "that maximize its chances of success" (it uses rules to play the best possible move).

It is therefore an intelligent agent which the object of AI.

I'm open to different point of views of course but not without argumentation.

You are correct. You would call such a form of AI a Reactionary Agent, as opposed to a State Based Agent.

  • 0

That's what i mean. Everyone in this forum things differently for the AI. I think the random moves make it more inteligent. Another part thing that the if statements make is more inteligent. For the source code: For now i will not post it. It's in developing. For that. And it isn't complete. I want to ask something. Is it normal the code of the AI to be aproximately 1500 lines of code? The Tic-tac-Toe without AI is just aproximately 290 lines of code. So it will be aproximately 1790 lines of code when it is complete i think.

  • 0
Is it normal the code of the AI to be aproximately 1500 lines of code? The Tic-tac-Toe without AI is just aproximately 290 lines of code. So it will be aproximately 1790 lines of code when it is complete i think.
That's probably a lot. You probably have a lot of repetition in there, which can be fixed by better design. But without seeing the code, it's impossible to tell what can be improved.
  • 0

After reading the post that he used 1600 lines to write tic-tac-toe with AI I thought I'd see how small mine would come out to in C.

I ended up with about 100 lines of spaghetti code.

And no, I don't use goto in actual programs.

#include <iostream>
using namespace std;

int AskForNumber(char* prompt) {
	cout << prompt;
	int r = 0;
	cin >> r;
	return r;
}

int CheckForEnd(int (*board)[3][3], int cindex, int lmx, int lmy, bool player) {
	for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
			if ((*board)[x][y] == 2)
				goto notadraw;
	}
	cout << "\nDraw!\n";
	return 3;
notadraw:
	for (int i = 0; i < 3; i++) {
		if ( ( (*board)[i][0] == (*board)[i][1] ) && ((*board)[i][1] == (*board)[i][2]) ) {
			if ( (*board)[i][0] != 2 )
				goto win;
		}
	}
	for (int i = 0; i < 3; i++) {
		if ( ( (*board)[0][i] == (*board)[1][i] ) && ((*board)[1][i] == (*board)[2][i]) ) {
			if ( (*board)[0][i] != 2 )
				goto win;
		}
	}
	if ( ( (*board)[0][0] == (*board)[1][1] ) && ((*board)[1][1] == (*board)[2][2]) && ((*board)[0][0] != 2)) {
			goto win;
	}
	if ( ( (*board)[1][1] == (*board)[0][2] ) && ((*board)[1][1] == (*board)[2][0]) && ((*board)[1][1] != 2)) {
			goto win;
	}
	return 0;
win:
	cout << (player ? "\nPlayer Won!\n" : "\nComputer Won!\n");
	return (player) ? 1 : 2;
}

int main(int argc, char** argv) {
begin:
	char* boardStrings[] = { "O", "X", "#" };
	int playerIndex = AskForNumber("Choose piece:\n0. O\n1. X\n"), computerIndex = ((playerIndex) ? 0 : 1); //should really check for > 1 here
	int board[3][3] = { 2,2,2,2,2,2,2,2,2 };
	while (!CheckForEnd(&board, computerIndex, 0, 0, false)) {
		for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
			cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
		}
	penter:
		int x = AskForNumber("\nEnter 0-based destination x coord: "), y = AskForNumber("\nEnter 0-based destination y coord: ");
		if (x > 2 || y > 2 || board[x][y] != 2) {
			cout << "\nInvalid coordinate!\n";
			goto penter;
		}
		board[x][y] = playerIndex;
		if (CheckForEnd(&board, playerIndex, x, y, true))
			break;
		int p = -1, b = -1;
		for (int cplayer = 1; cplayer != -1; cplayer--) {
			int mx = -1, my = -1;
			for (int nx = 0; nx < 3; nx++) {
				int cplayer_pieces = 0;
				for (int ny = 0; ny < 3; ny++) {
					if (board[nx][ny] == cplayer)
						cplayer_pieces++;
					else if (board[nx][ny] != 2) {
						cplayer_pieces = 0;
						break;
					}
					else {
						mx = nx;
						my = ny;
					}
				}
				if (cplayer_pieces == 2 && mx != -1 && my != -1) {
					board[mx][my] = computerIndex;
					x = mx;
					y = my;
				}
			}
		}
		if (board[1][1] == 2) {
			board[1][1] = computerIndex;
			x = 1;
			y = 1;
			goto computerdone;
		}
		for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
			if (board[x][y] == 2) {
				board[x][y] = computerIndex;
				p = x;
				b = y;
				goto computerdone;
			}
		}
computerdone:
		if (p != -1) {
			x = p;
			y = b;
		}
		if (CheckForEnd(&board, computerIndex, x, y, false))
			break;
	}
	goto begin;
}

  • 0

After reading the post that he used 1600 lines to write tic-tac-toe with AI I thought I'd see how small mine would come out to in C.

I ended up with about 100 lines of spaghetti code.

Your AI is so good, it can actually play twice in one turn :rofl: :

post-138285-0-41486700-1311813002.png

  • 0

Your AI is so good, it can actually play twice in one turn :rofl: :

post-138285-0-41486700-1311813002.png

Heh, never seen that happen before.

Anyway it wouldn't take 1500 lines to fix that bug so my point still stands.

I just forgot a goto inside

if (cplayer_pieces == 2 && mx != -1 && my != -1) {

  • 0

Ok i will post the code. It isn't well programmet at all. What i mean is the code. For the program it works really well, but it isn't complete. This is the code with AI. The code without AI is aproximately 290 lines of code and i like ot, but it can be really better written. The waste of lines of code is because of the anticheating system and the AI.Without them it will be aproximately 100 lines of code.

PS: And sorry for not using an array for the board. When i was writing the core code of the program i don't knowed what's an array.And sorry for the text format. It say's that i can't upload files in this format. The this format is .cpp. So i made it .txt so that i can upload it.

main.txt

  • 0

Ok i will post the code. It isn't well programmet at all. What i mean is the code. For the program it works really well, but it isn't complete. This is the code with AI. The code without AI is aproximately 290 lines of code and i like ot, but it can be really better written. The waste of lines of code is because of the anticheating system and the AI.Without them it will be aproximately 100 lines of code.

PS: And sorry for not using an array for the board. When i was writing the core code of the program i don't knowed what's an array.And sorry for the text format. It say's that i can't upload files in this format. The this format is .cpp. So i made it .txt so that i can upload it.

OH DEAR GOD! MY EYES, THEY BURN!!!

I know you are quite young, and it's a really good effort. But please before jumping ahead too much and corrupting your fresh brain, try advancing in the core development concepts.

Looking at the code you posted, it's very obvious that you just started coding, and you are doing a lot of things wrong (well pretty much everything).

  • 0

Making games takes a lot of work, learn through either making a cirrulum for yourself or taking computer science courses, you will need to learn data structures, databases, algorithms, software development, and software design and architecture. Learn to walk before you run, set smaller goals for yourself, you will need to do well with mathematics and science. You have to make it a process where you can teach yourself these things, and practice practice practice.

  • 0

Can you please stop with these computer courses. I don't have money for that. And i can't go to college or universuty, because i am in Highschool.

PS: And i know the code is horrible. Some advice? I mean what i must do to fix this? Not the code for the Tic-Tac-Toe. I mean my programming style at all?

  • 0

I know you are doing C++, but these should give you some ideas on how to structure a game well.

http://www.phstudios.com/tutorials/xna/Paddles/PaddlesXNATutorial.pdf (very old but basic tutorial)

http://phstudios.com/?q=node/49

Edit: For a console based Tic-Tac-Toe game, I recommend using the MVC approach (model, view, and controller). Here is an example I did on the iPhone (Objective C). I do not expect you to fully understand the coding, but you should be able to see I created several methods to clean the code, and I also cleaned up the checking code (so there is not 1,000 if statements).

(model): https://phstudios.svn.beanstalkapp.com/iphonedevelopment/trunk/C490/Homework%203/TicTacToeModel.m

(view): https://phstudios.svn.beanstalkapp.com/iphonedevelopment/trunk/C490/Homework%203/TicTacToeView.m

(controller): https://phstudios.svn.beanstalkapp.com/iphonedevelopment/trunk/C490/Homework%203/TicTacToeController.m

Again, I do not expect you to fully understand the Objective C code. If you just take a look at the Model - Win function, this technique should clean up your code by a large amount:

	//Check Rows
	for(int i = 0; i < 3; i++)
	{
		s1 = (NSString *)[board objectAtIndex:i * 3];
		s2 = (NSString *)[board objectAtIndex:(i * 3) + 1];
		s3 = (NSString *)[board objectAtIndex:(i * 3 ) + 2];

		if (s1 == s2 && s2 == s3) {
			return YES;
		}
	}

	//Check columns
	for(int i = 0; i < 3; i++)
	{
		s1 = (NSString *)[board objectAtIndex:i];
		s2 = (NSString *)[board objectAtIndex:i+3];
		s3 = (NSString *)[board objectAtIndex:i+6];

		if (s1 == s2 && s2 == s3) {
			return YES;
		}
	}

	//Check Diagonals
	for(int i = 0; i < 3; i = i+2)
	{
		int j = 1;
		if(i == 2)
			j = -2;
		s1 = (NSString *)[board objectAtIndex:(i * 3)];
		s2 = (NSString *)[board objectAtIndex:(i * 3) + (4 / j)];
		s3 = (NSString *)[board objectAtIndex:(i * 3) + (8 / j)];

		if (s1 == s2 && s2 == s3) {
			return YES;
		}

	}

Where board is a string (NSString) array. You can just use a char array in C++:

char board[] = "123x456o789";
   char s1 = board[3];

S1 will be X.

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

    • No registered users viewing this page.
  • Posts

    • Wow, spoken like a true blind hater, you don't even provide arguments. Please, go check my comment above to @seacaptain and you'll find out why what you say doesn't make sense in this context...
    • Get used to this, with AI tooling now uncovering new vulns and getting them exploitable far faster than has ever been possible before software is going to need to be updated far more frequently. Back in the day it may take reseachers weeks or months to do what AI can now do in hours. Once its a threat is discovered it's weaponsized far more quickly, meaning you simply can't be waiting 2, 3, 4 weeks to deploy a patch, it needs to be patched immediately. Going to be interesting handling this in the enterprise space where traditionally patching has been steady, but very staged (and rightly so up until now), that is going to have to change.
    • You don't need to "close all browser sessions constantly" or wait for updates to install. The updates download in the background while you use the browser, without interrupting you, they install automatically the next time you launch the app. And they install very fast (depending on your storage speeds, of course), you have to wait at most 2-3 extra seconds, if any. Seems like you haven't used Edge in a loooooooong time...
    • Segra 1.6.0 by Razvan Serea Segra is a free, open-source OBS-powered game recorder offering fast gameplay capture, instant clips, AI highlights, deep game integration, and seamless uploads—perfect for gamers, streamers, and content creators. Lightweight, fast, zero bloat. Segra key features: Automatic Game Recording: Begin capturing gameplay the moment your game launches, with zero manual setup. Instant Clipping: Save important moments instantly using a customizable hotkey—perfect for highlights, montages, or quick shares. Segra AI Highlights: Let Segra automatically detect kills, assists, deaths, and key events to generate polished highlight reels without manual editing. Gameplay Uploads: Upload recordings and clips directly to Segra.tv for fast sharing and cloud access. Deep Game Integration: Enjoy advanced game-data tracking across hundreds of supported titles, enabling smart highlight generation and stat-informed clipping. High-Performance Capture: Record up to 4K at 144 FPS using OBS-powered technology with minimal performance impact, supporting NVENC, AMD VCE, and custom quality controls. Segra Editor: Edit recordings easily with timeline controls, segment management, and event-based navigation to build the perfect clip. Customization Options: Adjust hotkeys, output formats, storage paths, codecs, capture quality, and performance settings for a tailored recording experience. Segra 1.6.0 changelog: Recording: Added HDR support. Grand Theft Auto: Added game integration for deaths (FiveM and RAGE MP supported). Highlights: Added customizable padding for highlights. Replay Buffer: Added a shockwave visual effect when a replay buffer clip is saved. Audio: Increased the maximum sound effects volume from 100% to 200%. Hotkeys: Fixed hotkeys not triggering while unrelated keys were held. Installer: Added code signing to verify publisher identity, branded the installer, and reduced OS security warnings. OBS: Updated the supported OBS version to 32.1.2. Download: Segra 1.6.0 | 74.4 MB (Open Source) View: Segra Homepage | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Week One Done
      Timaximus earned a badge
      Week One Done
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      PsYcHoKiLLa
      175
    3. 3
      +Edouard
      163
    4. 4
      Steven P.
      86
    5. 5
      ATLien_0
      79
  • Tell a friend

    Love Neowin? Tell a friend!