Programming

R.B.

King of the Meeps
Joined
Sep 25, 2006
Messages
316
Location
Meeps
How does a person go around creating programs like tic-tac-toe or a text game?
 
Visual Basic is quite easy to use, but you could use BASIC (language) to make such things I believe. A coding technician can probably answer a lot more detailed.
 
I don't know whether to :rolleyes:, or :shake:, or:spank: .

Writing a game program is a non-trivial task. There are tools that help make things easier, especially the graphical interfaces, but the tough part is still figuring out exactly what you want to do. And I mean EXACTLY. Every single step. Everything that might happen in the game, to the smallest detail. And if you need an AI (so you can "play against the computer") that complicates things to a horrifying degree.

There's a reason why good software engineers can make significant $$$. ;)
 
First you'll need to learn a programming language, at least to the point of loops, input/output, and graphical user interface (i.e. buttons, etc.). You probably could teach yourself this with a good book for newcomers, but I'd recommend taking a class if it's possible, either at your local school or computer store. Programming languages are far too difficult to jump right in for the first time and make a cool program.

As to which language, I've programmed in Visual Basic and Java, and I'd recommend Visual Basic (6.0 or less) if you're looking to do things with buttons. In both graphics and general syntax, I've found VB to make more sense (others may differ). Unfortunately, Microsoft has been suppressing VB in favor of their new, more Java-esque VB.NET, so it may be difficult to find a copy.

I'm an amateur at programming, not an expert, but Tic-Tac-Toe is one of the programs I've made. My most complete version is in Visual Basic. It has artificial intelligence for both the X's and the O's, with only one minor error where the AI doesn't make the smartest move (I plan to fix that eventually). That was the first AI programming I ever did and it took forever. The first major difficulty is the logic of figuring out the best move in every possible situation (making a Tic-Tac-Toe program will make you a better Tic-Tac-Toe player), and then programming it in efficiently. Then I had to fix all the situations where the AI would put an "O" where there was already an "X" or the AI would play an "X" when it was playing "O" or something like that. Error-catching is a huge part of making a program - if it weren't we would have a CivIV Bug Reports subforum here.

Recently I've been rewriting the program in Java. I've taken a slightly different method in telling the AI what to move this time, and I think the AI will play even better this time. I'm also planning to implement difficulty levels this time. Even with VB code to start from, it's still very difficult to get everything working correctly, and just one typo will result in the computer, for example, filling in the second box down on the right rather than the first down on the right. If I remember correctly, I've completed all but one major method for the AI playing "O", and none yet for "X". Another problem with my Java version is I'm not sure how to make sub-classes modify the buttons of super-classes, so my Java program is far less object-oriented than my VB version.

Both of these programs took several weeks to complete (not working on them full time, of course, but 45 minutes or so a day...8+ hours).

Other possible trip-ups in Tic-Tac-Toe included the AI not making a move because I missed a possible situation, and the AI hitting an infinite loop trying to find best-fit square. So I guess I just gave a bunch of examples of how Padma's second paragraph applies to Tic-Tac-Toe :).

My other finest completed programs include a ratings calculator (featuring 3-D arrays), a Wheel of Fortune game without a wheel (graphical difficulties), a Minesweeper variant (special thanks to Wingdings font), and a one player v. computer game of Chemin de Fer (the version of baccarat James Bond plays in the book Casino Royale). The Wheel game needs significant improvements to match the TV show (not including graphics), and I hope to add more players to Chemin de Fer, but they all are error-free for now. Emphasis on "for now" because I remember when I showed a friend the Wheel program and he uncovered an error within about 30 seconds. That error has since been fixed.
 
I don't know whether to :rolleyes:, or :shake:, or:spank: .

:lol:

Actually, tic tac toe should be pretty easy to implement with ASCII 'graphics'. Even a basic AI shouldn't be to much trouble given how simple the game is. Of course it would kinda help to know at least, erm, a *bit* about some language before starting. ;)
 
I'd suggest Java as an introductory language. It's relatively uncomplex, elegant and forgiving. Garbage collection ftw! For GUIs, Swing (part of Java) is pretty easy to use with a little practise. Sadly it uses a Virtual Machine, so it's slow for games etc, but for learning it's fine.

Also, it's quite similar to C++ which is what you *would* use to make a commercial game.
 
I'd suggest Java as an introductory language. It's relatively uncomplex, elegant and forgiving.

Not exactly how I'd describe Java :p If you're looking for the above characteristics you should definetely try Python. And about games programming, I haven't done games myself but I have a hunch that http://www.gamedev.net/ is quite reasonable place to look more information about it.
 
Well if you really want to get into programming, and I mean to really learn all the ins and outs and be relatively confident in picking up any other language, I would reccomend something like c++. Yeah sure VB and java are simple and give you results, but if you learn them first, then try and move onto something more pedantic like c++, you will be in for a shock. I suppose it is sort of like learning to drive an auto, then moving onto the manual - its generally better just to learn the manual straight away.

Although I personally first learn Pascal, bits of pieces of VB, bits of pieces of python, then I learnt c++.
 
First I must admit that I'm just a dabbler in programming so grain of salt might be handy when reading my opinions. Anyways, personally I do disagree with chinesefireball.

A high level language with readable syntax, like Python, lets you to focus more on the programming itself than on the details of any specific language. Trying to learn too much language specific details (which C++ probably has more than any other language) in the beginning can easily haze the generic how's and why's. Also the biggest benefit C/C++ has is its excecution speed which is not needed in most of the programming. Most of the programmers I know either don't use C++ in their work at all or use it only rarely (most of them use primarily Java).
 
I made a tetris program with Visual Basic. It works, and gives me immense pride (and misery).

tetrisxa9.jpg
 
C# is a good choice to. I'm using that for SSS.
Clean and efficient, not to complicated, loads of existing library, easy to do GUI
... expensive and chained to microsoft politics.

I would prefer Java for the small programs mentioned above. It's free, comes with extensive libraries (official and third party), many IDE, and is easilly distributed. On the downside, there remains some Sun Microsystem politics.
 
I'd second the recommendation for GameDev, specifically their forums, which have lots of people at various stages of learning how to program. You can get started at the Beginner's Forum FAQ.

The first step is to learn a programming language. There are a variety out there, but really, anything that you find interesting will work, including Python, Java, Visual Basic, and C#. Some people recommend C++, but it can be difficult and overwhelming for beginners. I'm almost certain all have game development communities and samples/tutorials to help you get started. Also, don't get caught up in choosing the "correct" language--there isn't one, and you can always learn more languages later.

stormbind: All Visual Studio 2005 Express products, including C# Express, are free. If you want a free, OSS C# IDE, there's SharpDevelop. If you don't want any IDE, then the free .NET redistributable is sufficient, since it comes with command-line compilers. And finally, if you want an OSS, cross-platform .NET, there's Mono.

Gangor: Take a look at a Java port of Quake 2 with some impressive performance. Personally, I don't care about language/framework performance in most cases, and it should especially not matter for beginners.
 
The express edition of Visual C# is free so it's not expensive at all. You can also get fre versions of VB, Visual C++ as well.

I'd recommend gamedev.net too, I'm a member of that site as well my user name is Paradigm Shifter (with a space - it was too many letters to fit on this forum).

If you are doing a tic-tac-toe game you will probably want to take a look at the minimax algorithm although that will give you an unbeatable ai so you will want it to play sub-optimal plays at times.

I'd second python as a good beginners language too. C++ is too complicated for beginners, although that's what I use in my day job.

EDIT: Text programs are probably easiest with a language like python which has excellent support for lists, dcitionaries and the like.
 
I recommend a program for creaing games without writing code. (Even though you can write scripts if you want)

http://www.gamemaker.nl/

There's also tutorials you can download

Have fun ;)
 
I don't know whether to :rolleyes:, or :shake:, or:spank: .

Writing a game program is a non-trivial task. There are tools that help make things easier, especially the graphical interfaces, but the tough part is still figuring out exactly what you want to do. And I mean EXACTLY. Every single step. Everything that might happen in the game, to the smallest detail. And if you need an AI (so you can "play against the computer") that complicates things to a horrifying degree.

There's a reason why good software engineers can make significant $$$. ;)


that's not true....the hardest part is the graphics
 
that's not true....the hardest part is the graphics

I'd wager that depends on the game. For something with tons of modern, often 3D graphics, graphics may be the hardest part. But if you're making a simply, amateur-level game (which I think is what the opening poster is hoping to do), then the logistics are likely far more complicated than the graphics - and unless you have commercial hopes, you don't need stellar graphics, either.
 
that's not true....the hardest part is the graphics

That must the reason why strategy gamers all over the world are contended with level of AI in the games and why game graphics in general have improved so little in the last few years :mischief:
 
Back
Top Bottom