• 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, 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
      520
    2. 2
      PsYcHoKiLLa
      197
    3. 3
      +Edouard
      157
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      75
  • Tell a friend

    Love Neowin? Tell a friend!