The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 Viewsi think AI might be a little out of my league but i guess i could program a more simple ai than checkers. maybe a computer that based on its health it decides whether or not to heal, attack or defend. (a lame text based fighting game)
i should probably get a bit better at loops and such before i attempt this
A.I. isn't that complicated for tic tak toe. Its just A LOT of coding and its sort-of repetitive. its basiclly:
if
x--
x--
----
then
---
----
0---
and just doing it for all the combinations
At 2/23/05 03:16 PM, Love_Daddy wrote: A.I. isn't that complicated for tic tak toe. Its just A LOT of coding and its sort-of repetitive. its basiclly:
if
x--
x--
----
then
---
----
0---
and just doing it for all the combinations
Err.. not really. That would be extremely inneficient.
Usually you just brute force it (Google: Minimax), by calculating all of the possible moves that you and the computer can make and determining which would be most benificial to the computer. (I used a dif algo, but I don't feel like explaining it...).
well for something like tic tak toe that would work. were else would you want the comp to go if that move was made(see above)? but for something like chess, then you might want to get the best move and do the A.I. that way.
Err... actually, most chess AIs operate on similar principles. The brute force method. I've never written one -- but I can vouch that that is how they work.
meh whatever i had fun writing my VB tic-tak-toe A.I. I'll transfer all my VB programs into C++ soon, but i have to learn a lot more of it first:). Im takeing computer ennnginering technolegy next year(gr.10) and its supposed to have "fundimental programming concepts" in it so im just gonna breeze through that course.
OK, OK.... I know this isn't C or C++, however, this is the programming language for the ,( ),mega RPG engine. It's kinda sorta Java-based but it looks a lot like C++ so here it goes!!!
WRLD gw = newWorld("Arcania", 1000);
GCAR mainchar = newCharacter(
gw,
"Auron",
"Warrior",
high,
med,
medhigh,
low,
low
);
TERR tg = newTerrain(
"Grass",
10,
0,
NULL
);
TERR tf = newTerrain(
"Forest",
15,
1,
NULL
);
TERR tv = newTerrain(
"Village",
0,
2,
"Safe"
);
CMPS onlycomp = newCompass(
"compbg.bmp",
"compln.bmp",
"compbn.bmp",
gw
);
AREA tut = newArea(
FALSE,
FALSE,
TRUE
);
GRID zz = newGrid(0, 0, 2, "room1.bmp", tut);
GRID zo = newGrid(0, 1, 2, "room2.bmp", tut);
GRID zt = newGrid(0, 2, 2, "room4.bmp", tut);
GRID ot = newGrid(1, 2, 2, "room6.bmp", tut;
GRID or = newGrid(1, 3, 2, "room3.bmp", tut);
GRID of = newGrid(1, 4, 2, "room6.bmp", tut);
GRID tf = newGrid(2, 4, 2, "room5.bmp", tut);
GRID rf = newGrid(3, 4, 2, "room3.bmp", tut);
GRID ff = newGrid(4, 4, 2, "room1.bmp", tut);
CHAR goca[*] = new Array();
CHAR goca[0] = "Hello, and welcome \n! This is Arcania. Me and the other guides, Steve and Tom, are here to guide you through this exciting world. First, push the \qright\q arrow or \qD\q on your keyboard to move east.";
CHAR goca[1] = _END;
CONV goc = newConversation (goca);
NPC go = newNPC(
"Alex",
goc,
zz,
FALSE,
FALSE,
"aleximg.bmp"
);
CHAR gtca[*] = new Array();
CHAR gtca[0] = "Hi, I'm Steve. So, you know how to walk, eh? Well, that's good, because there are tons of other commands you will have to know. Type \qS\q to search the area closely. You will find a key. Then type \qO\q, then the name of the container, in this case \qChest\q, and then give the object you find to me and I'll let you into the other room.";
CHAR gtca[1] = _END;
CONV gtc = newConversation(gtca);
NPC go = newNPC(
"Steve",
gtc,
zo,
FALSE,
FALSE,
"stevimg.bmp"
);
GITM Sgem = newGameItem(
"Special Gem",
"A gem I must give to the Guide.",
NULL
);
CITM chitm[*] = new Array();
CITM chitm[0] = Sgem;
CITM chitm[1] = gold(_ADD, 100);
CNTN chst = newContainer(
"Chest",
chitm
);
SPEV Egem = newSpecialEvent(
evGive(Sgem, go),
evDoor(zz, zo, _OPEN)
);
SPEV Ngem = newSpecialEvent(
evOwn(go, Sgem, FALSE),
evDoor(zz, zo, _CLOSE)
);
Ya... the game code is several hundred lines long and I havn't even compiled it yet. If anyone knows an easy way to make conversations could they tell me? I dont know how to get the choices to work. Also - what is the newQuest() syntax?!?!?!?
well its been some time since i posted any code here so:
#include <iostream>
using namespace std;
int main(){
int endless = 1;
while(endless = 1){
cout<<"ownage"<<endl;
}
}
you know what i realized mabey its my compiler but my MSVC++ compiler doesn't require using namespace std; and you have to add the .h in the include files. I've been told not to use those but i have to. If i right using namespace std; i get an error and if i leave out .h i get an error. Do you other MSVC++ guys have the same thing going on?
i use msvc++ and i have no idea what you are talking about. its only on the iostream that i don't use the .h becasue the rest of em' are actually .h files. using namespace std; has never given me an error as far as i know.
here is some code for all the beginner c++ers out there (this is a variable script)
#include <iostream>
using namespace std;
int main()
{
// declaring the variables
double x,y; //makes 2 variables called x and y!
cout<<"enter a value in degrees celcius!"<<endl;
cin >> x; //inputs the value for x.
y = (x*1.8)+32; // the computer now knows what to print as "y" for a farenheit temp.
cout<<"the farenheit equivelent is "<<y<<" degrees farenheit"<<endl;
return 0;
}
You guys need to discover the wonderful world of Command-Line arguements.
omg.
Playstation Network tag: muffin-noodle
the empty set
At 2/26/05 10:01 PM, RegExp wrote: You guys need to discover the wonderful world of Command-Line arguements.
would you like to elaborate?
At 2/26/05 10:01 PM, RegExp wrote: You guys need to discover the wonderful world of Command-Line arguements.
baby steps, RegExp, baby steps
i'll get to that once i learn whatever it is im learning now.
You've all seen those uber programs like Rainbow Crack or John the Ripper, and how they use Command-Line arguements so the program doesn't have to ask the user eighty-billion questions right? (You must have come across at least one.)
That's basically what they do. Those programs where you enter flags like:
"program -help" and the program will get you help, those are CMD-Arguements.
I'm not really a C++ programmer at all, but in C, this is how you do CMD-Arguements:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
/*Simple addition program*/
int main(int argc, char *argv[]) {
if(argc < 3) {
printf("Usage: <firstnum> <secnum>");
getchar();
return 0;
}
int a = atoi(argv[1]), b = atoi(argv[2]);
int z = a+b;
printf("%d",z);
getchar();
return 0;
}
That program simply adds ARGV[1] + ARGV[2] and gives you back the result of the addition.
Command-Line arguements are how you make your programs more flexible to the users, that's how many half-way complex programs (like my MD5 cracker) know what to do: CMD-Arguements tell the program what operations it should preform using the given arguements.
Get it?
omg.
Playstation Network tag: muffin-noodle
the empty set
Whoops! I forgot to mention a few things:
A. The headers STDlib.h and MAlloc.h are not needed, it's just a habit I include them (been working with Dynamic Memory allocation.)
B. The reason I add ARGV[1] + ARGV[2] when arrays index at 0, is because in C and C++, the first CMD-Arguement is always the program name
So if you went printf("%s",argv[0]); that would print the programs name.
ARGV[0] is never really needed, so don't worry about it, just always know to start at 1 as an index when dealing with CMD-Arguements.
omg.
Playstation Network tag: muffin-noodle
the empty set
well since this is C++ help : wat does this do i've ran into it in Win32 but im not sure wat it does. I belive it declares an agument or someting bbut i really have no idea.
int main(int argc, char *argv[]) {
Lolify, one more thing:
Learn to manipulate Dynamic Memory Allocation, it's a very touchy subject in terms of debugging (because you'll always have errors with DMA, even seasoned programmers do.) but it's great to learn.
DMA basically creates variables on runtime.
Dynamic Memory Allocation (DMA) example in C:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int main(int argc, char *argv[]) {
char stuff[] = "Hello World!";
char *dma;
dma = (char *)malloc(strlen(stuff) + 1); /*Allocate memory with Typecast
The +1 is for the \0 because all strings are null terminated.
Also note, I'm not doing (char *)malloc((strlen(stuff) + 1) * sizeof(char));
Because characters are one byte, while if I was allocating memory for an integer,
I would do (int *)malloc(integer * sizeof(int));
Because ints are four bytes, I think.*/
strcpy(dma,stuff); /*This won't cause error, because *dma has allocated enough memory to hold the contents of stuff[].*/
int i, a = strlen(stuff);
for(i=1;i<=a;i++) {
printf("%d ",i);
}
printf("\b. That many bytes have been allocated.");
getchar();
free(dma); //You should always free() allocated space.
return 0;
}
omg.
Playstation Network tag: muffin-noodle
the empty set
At 2/27/05 12:05 AM, Love_Daddy wrote: int main(int argc, char *argv[]) {
It's for Command-Line arguements.
I think you're jumping ahead of yourself, Daddy, you shouldn't be getting into Win32 just yet.
omg.
Playstation Network tag: muffin-noodle
the empty set
At 2/27/05 12:04 AM, RegExp wrote: ARGV[0] is never really needed, so don't worry about it, just always know to start at 1 as an index when dealing with CMD-Arguements.
Unless you want to create a program that deletes or modifies itself after running.
At 2/27/05 12:20 AM, RegExp wrote:
It's for Command-Line arguements.
I think you're jumping ahead of yourself, Daddy, you shouldn't be getting into Win32 just yet.
ok i'll sick to learning the baisivs i suppose im just getting tired of plain black and white screen. i knwo one can create someting awsome in that but it just looks that much better with GUI. Thats one of the reasons i like VB so much it goes straight into GUI and lets you make a nice looking useful form really quickly.
Then stick to VB for GUIs, because it takes a while to get used to Win32 coding in C and C++.
omg.
Playstation Network tag: muffin-noodle
the empty set
At 2/23/05 08:19 PM, Love_Daddy wrote: meh whatever i had fun writing my VB tic-tak-toe A.I. I'll transfer all my VB programs into C++ soon, but i have to learn a lot more of it first:). Im takeing computer ennnginering technolegy next year(gr.10) and its supposed to have "fundimental programming concepts" in it so im just gonna breeze through that course.
You're taking a computer engineering class, and you only have fundamental programming concepts? I am in my first year of computer science, and I have alot more than just "fundamental programming concepts"
Well, I've only had C and Java to this point, but it's still alot more than just fundamental.
"no sound in ass"
the course is a gr 10 engineering one and i think it mostly hardware stuff not software. I think we'll do just a little prgramming. The acual computer science courses start at gr.11. and i don't thik there are courses where you can just learn a programming language.
damnit, this threadis dieing and i feel like such a n00b to c++ now. everybody who was very n00bish at the begining of this thread has now passed me. does anybody know a good way to learn c++? i have a good book on it but i think i should take a course. any suggestions?
At 3/5/05 08:06 PM, eh-productions wrote: damnit, this threadis dieing and i feel like such a n00b to c++ now. everybody who was very n00bish at the begining of this thread has now passed me. does anybody know a good way to learn c++? i have a good book on it but i think i should take a course. any suggestions?
does that include me....lol. Well C++ for dummies was deceant i suppose
Go to your local bookshop there will be about 20 books,
Sorry I havent been helping out guys, I have been working on a FBF movie
hehe.........
#include <iostream.h>
using namespace std;
int main(){
char ans;
cout<<"OMG is this Love_Daddy's 666th post(y, n)"<<endl;
cin>>ans;
if ((ans == "y")||(ans == "Y")){
cout<<"THATS RIGHT FOOL. I R TEH DEVIL!"<<endl;
}
else{
cout<<"NO U DUMASS I R TEH DEVIL. GO 666!"<<endl;
}
cin.get();
return 0;
}
lol @ that ^^^
That above code has errors.
You use single quotes for characters, but you use double quotes for strings.
Like:
if(stuff == 'e'); //CORRECT
if(stuff =="e"); //INCORRECT
Your compiler probably won't notice but it's always good to note that.
omg.
Playstation Network tag: muffin-noodle
the empty set
At 3/7/05 07:55 PM, RegExp wrote: That above code has errors.
You use single quotes for characters, but you use double quotes for strings.
Like:
if(stuff == 'e'); //CORRECT
if(stuff =="e"); //INCORRECT
Your compiler probably won't notice but it's always good to note that.
ya thanks.
one more thing thougth. if i say something like char ans; and then the user would type something like "cat" i would only get "c". If i got char ans[]; the i would get "cat". I think that thats fucked up but how do i declare a string variable properly?
#include <windows.h>
const char class1Name[] = "Stuff";
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,
WPARAM wParam,LPARAM lParam) {
switch(message) {
case WM_LBUTTONDOWN:
{
char FilePath[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL),FilePath,MAX_PATH);
MessageBox(NULL,FilePath,"Hi! This program is:",MB_OK | MB_ICONEXCLAMATION);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int CmdShow) {
HWND wind1,wind2; WNDCLASSEX wndx; MSG msg;
wndx.cbSize = sizeof(WNDCLASSEX);
wndx.style = 0;
wndx.lpfnWndProc = WndProc;
wndx.cbClsExtra = 0;
wndx.cbWndExtra = 0;
wndx.hInstance = hInstance;
wndx.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndx.hCursor = LoadCursor(NULL, IDC_ARROW);
wndx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndx.lpszMenuName = NULL;
wndx.lpszClassName = class1Name;
wndx.hIconSm = LoadCursor(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wndx)) {
MessageBox(NULL,"WND Registration failed!","Err0r:",MB_OK);
return 0;
}
wind1 = CreateWindowEx(
WS_EX_CLIENTEDGE,
class1Name,
"Window 1! WND Class !",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,240,120,
NULL,NULL,hInstance,NULL);
wind2 = CreateWindowEx(
WS_EX_CLIENTEDGE,
class1Name,
"Window 1! WND Class 2!",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,120,240,
NULL,NULL,hInstance,NULL);
if(wind1 == NULL || wind2 == NULL) {
MessageBox(NULL,"Window creation failed!","Err0r!",MB_OK);
return 0;
}
ShowWindow(wind1,CmdShow);
UpdateWindow(wind1);
ShowWindow(wind2,CmdShow);
UpdateWindow(wind2);
while(GetMessage(&msg,NULL,0,0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
I've been fooling with Win32 lately.
Just a moment ago I created two windows classes, each with their own window (because if the WM_DESTROY message is sent to the message queue then it finds the Window that sent the message and finds the Window Procedure related to that Window's class and destroys all those Windows of the class. Like a really long chain type... Thing) but unfortunately it had an error and it kept dying of Segmentation fault, so I deleted the second class and found the error afterwords, annoying.
I don't feel like recreating the other class either.
omg.
Playstation Network tag: muffin-noodle
the empty set