PDA

View Full Version : 3-31-05 -> 4-13-05 Competition



TheTempest
03-30-2005, 06:45 PM
This compitition is a turn in a slightly new direction. We would like you to take the stance of the game designer (in our case, Blizzard). Now, I understand that most of you here don't know how to design a DirectDraw (or Direct3D) menu or anything like that, so designing a graphics engine is not part of the job description :)

The Rationale:
(Per Jakor and I)
As a gamehacker, one needs to be able to think like a game programmer. How can you modify something that you don't understand how it works in the first place? There are always several ways to go about finding a solution to a problem. Every game programmer uses structures on a regular basis. For this competition we are going to be working with a special sub-genre of structures, the "linked list." Linked lists are used to store a dynamic ammount of like data which can easily be sorted/searched/or manipulated based on the base address of each "node."

Program:
Unit Array

Description: (Per Jakor)
In order to keep this competition related to starcraft, we will use a (highly modified but) real example. We are going to strip out graphics from the competition too. We will be making a windows32 console application in which we will be implementing a linked lists to hold our definitions (Hp/Sp/XCoordinate/YCoordinate/ect.) for our units. We will need to create a new node, initialize the data it will contain, change certain values for a specific node, and add or remove units from the list.
TheTempest: Also, please add a flag for PlayerID (controlling player), raceID, as well as some status flags for perminate cloak, flyer, miner...etc.

Format:
I want the starting menu to look like this.



Hacking Competition Program Summition v1.0:
**************************************
1. Create Unit
2. Destory Unit
3. Query Unit
4. Exit

Under the CreateUnit case, I would like the menu to look like this:


Which Race:
*********
1. Protoss
2. Terran
3. Zerg


And of course, under (lets just say #1) something like this:


Which Unit:
********
1. Zealot
2. Dragon
3. Dark Templar
4. Light Templar
5. Light Archon
6. Dark Archon
7. you get the hint :)


Please include as many units as possible, consult SC for a list :) You will need to inilize the node with correct HP/Mana/status flags (ie. perm cloak, flyer...yatta...)

Duration:
Two weeks from today.

Helpful Functions:
cout
cin
printf
scanf
getch
getc

Helpful libraries
iostream.h
conio.h
stdlib.h
stdio.h

Helpful skills:
How to create/manage Linked Lists.
For those of you who don't know what LL are or how to impliment them, this is a great resource.
http://cslibrary.stanford.edu/103/LinkedListBasics.pdf

Good luck,
If you have any questions, as usual, please post them here. Just remember, everyone will be able to see the answer :)

laocoon
03-30-2005, 06:52 PM
And their OFF!!!! Even though I am not participating as a contestant, I am certainly available to help with some parts of the challenge either as a pm or instant message. Tempest has put together a good listing of libraries and functions for the C people around here. I'm going to see what I can come up with in assembly. ;) The last thing is that I will be working with the Tempest on a grading system to implement. It has not been finalized, but it will be a way for you to see where you can improve upon your skill. :)

LCS
03-30-2005, 07:41 PM
We will be making a windows32 console application
Can we use a text box, but still make it like a console?

laocoon
03-30-2005, 07:55 PM
Can we use a text box, but still make it like a console?
Up to tempest for the final word. But also checkout pipes. (CreateProcess after CreatePipe) I know you are using VB, but win api is same across all languages. Check out the comments for this tutorial. http://spiff.tripnet.se/~iczelion/tut21.html

llafnwod
03-30-2005, 08:04 PM
Is this a first-to-finish thing, or will all completions be rewarded? I don't have too much time over the weekdays.

LCS
03-30-2005, 08:06 PM
I'm kinda grounded right now but I'm studing ;), I'll be working on it either late nights, or I'll wait till Saturday :/:

laocoon
03-30-2005, 08:09 PM
Is this a first-to-finish thing, or will all completions be rewarded? I don't have too much time over the weekdays.
It will work like before, we will look at all submissions as of two weeks from now. And as I said I'm working with tempest on a grading/points system to find the winner, and also it will help breakdown what parts of the project were your weak points.

TheTempest
03-30-2005, 10:51 PM
Yes, you can use Text Boxes and make it Conesole-esk...but as Jakor said, check out CreatePRocess and CreatePipe, check under anonymous pipes :)

LCS
03-30-2005, 10:52 PM
Ok, thank you, I've already got started and I'm pretty far into it :).

CarrierZ
03-31-2005, 01:16 AM
I'm sure i did something like this with CS a time ago, probably could find that code somewhere on my computer...

K? Pŕo?ćtiόnŹ
03-31-2005, 09:29 AM
Ok so all you want us to do is make a program that doesnt really go into sc's memory, just make it create like the data and such for a new unit?

TheTempest
03-31-2005, 12:09 PM
yes, that is correct. I don't want you to even load SC...I just want you to mimik the functionality of creating an array of units :) A Linked List, to be more accurate.

bulk_4me
03-31-2005, 03:38 PM
Pretty cool that you learn the basics behind the STL.

A.H
03-31-2005, 03:47 PM
Can I use Java? Although that kind of would be a little too easy, since linked lists are incorporated into it already.

TheTempest
03-31-2005, 03:50 PM
There are no language restrictions. Though, I would like to see you write your own Linked List class. The idea is to learn how to think like the developer. LL are not complicated, I even provided a wonderful PDF on how to do it in C++. The idea is for you to know how to write it so when you go to disasemble it, you know what you're looking for :D

bulk_4me
03-31-2005, 03:51 PM
You can always create your own Linked List Package. :rolleyes:

A.H
03-31-2005, 03:58 PM
I see. I can use Java, but have to make my own linked list.
Thanks bulk, Tempest.

EDIT: What do you mean by Query Unit? Do you want it so when you select a certain player, a list of all their units is print out? or is it some other thing? Please elaborate.

laocoon
03-31-2005, 05:29 PM
I see. I can use Java, but have to make my own linked list.
Thanks bulk, Tempest.

EDIT: What do you mean by Query Unit? Do you want it so when you select a certain player, a list of all their units is print out? or is it some other thing? Please elaborate.
By Query we mean that you need to display the list of units. Who owns the unit would be a flag in the node. We will need to be able to "see" each node(unit) in the linked list, and retrieve the data contained in each node. We have to be able to make sure that you're linked list works! ;)

A.H
03-31-2005, 06:21 PM
Ok thanks Jakor. I understand now.

TheTempest
03-31-2005, 10:05 PM
Yup, that's the idea.

I would like it to look something like this:


Query Unit:
********

1. By UnitID
2. By PlayerID
3. By RaceID
4. All Units

Then simply iterate throught the LL and printout, in a nice fasion, hit points, shield points, and all flags...blah blah.

If you have any more questions, please ask.

K? Pŕo?ćtiόnŹ
03-31-2005, 11:22 PM
Arg Ima do mine in FreeBASIC and since Im still novice at it can I just make an array instead of a linked list. Like...


type Unit
name as string
hp as long
armor as long
damage as long
cloaked as long
speed as long
size as long
end type
dim UnitsList(1000) as Unit


Can I do it like that?

LCS
03-31-2005, 11:27 PM
Arg Ima do mine in FreeBASIC and since Im still novice at it can I just make an array instead of a linked list. Like...


type Unit
name as string
hp as long
armor as long
damage as long
cloaked as long
speed as long
size as long
end type
dim UnitsList(1000) as


Can I do it like that?
You need to make it support an infinate number of units.

laocoon
03-31-2005, 11:28 PM
Arg Ima do mine in FreeBASIC and since Im still novice at it can I just make an array instead of a linked list. Like...


type Unit
name as string
hp as long
armor as long
damage as long
cloaked as long
speed as long
size as long
end type
dim UnitsList(1000) as


Can I do it like that?

I don't know about FreeBasic, but check out:
http://www.codeproject.com/vbscript/how_to_do_pointers_in_visual_basic.asp

The point of this competition is to understand linked lists from a developers perspective. We will be expanding this to understanding linked lists from a game hackers perspective later, so you need the foundation first. ;)

This has come up for a couple vb programmers now, so check out that link!


EDIT: I'm going to add in a few basic things in VB here for reference:

You need a List.cls:



'Source Code for the List Class
Option Explicit

Public ListHead As Node
Public ListTail As Node

Private Sub Class_Initialize()
Set ListHead = Nothing
Set ListTail = Nothing
End Sub

Sub MakeNewNode (n1 as Integer, n2 As Integer)
Dim n As Node
Set n = New Node
n.X = n1
n.Y = n2
If ListHead Is Nothing Then
Set ListHead = n
Else
Set ListTail.NextNode = n
End If
Set ListTail = n
Set ListTail.NextNode = Nothing
End Sub

Sub TransferList (List2 as List)
Set list2 = New List
Set list2.ListHead = ListHead
Set list2.ListTail = ListTail
Set ListHead = Nothing
Set ListTail = Nothing
End Sub

Sub GetNode(Column As Integer, row As Integer)
Dim n As Node
If Not ListHead Is Nothing Then
Set n = ListHead
column = n.X
row = n.Y
Set ListHead = ListHead.NextNode
If ListHead Is Nothing The Set ListTail = Nothing
Set n = Nothing
End If
EndSub

Function HasNodes () As Boolean
HasNodes = Not ListHead Is Nothing
End Function

Sub ClearList()
Dim n As Node
While Not ListHead Is Nothing
Set n = ListHead
Set ListHead = ListHead.NextNode
Set n = Nothing
Wend
End Sub

Sub DisplayList()
Dim n As Node
Set n = ListHead
While Not n Is Nothing
Debug.Print "X: " & n.X & " Y: " & n.Y
Set n = n.NextNode
Wend
End Sub

And then you need a Node.cls


'Source code for the node class
Public X As Integer
Public Y As Integer
Public NextNode as Node

And then a way to test it...

'Testing the List Class
Option Explicit

Private Sub Form_Load()
Dim TestList As List
Dim i As Integer

Form1.ScaleMode = vbPixels
Form1.AutoRedraw = true
Set TestList = New List
For i = 1 to 10
TestList.MakeNewNode i, i*10
Next i
TestList.DisplayList
End Sub

And there you have a nice list in your debug screen looking like
X: 1 Y: 10
X: 2 Y: 20
X: 3 Y: 30
.....
X: 10 Y: 100


This is a simple linked list written in vb with all the main functions needed to maintain a linked list. I did take this out of a programming book that I have used on many occasions through the years, and due to the simplisity of they way it puts it, I thought it was a great resource. I can't find the cd right now, so I typed it all in by hand. I sure hope you like it, because it took me a while, and I should be asleep right now. ;)

EDIT: code tags around quotes for scroll bars. Yes, I could have just left it in code tags, but i wanted to give credit to the book as a quote. Mod can change if they want cause it looks bad, i'm too tired to right now.

TheTempest
04-01-2005, 07:37 AM
Arg Ima do mine in FreeBASIC and since Im still novice at it can I just make an array instead of a linked list. Like...


type Unit
name as string
hp as long
armor as long
damage as long
cloaked as long
speed as long
size as long
end type
dim UnitsList(1000) as


Can I do it like that?
As Jakor said, no...The objective here is to learn about linked lists.

K? Pŕo?ćtiόnŹ
04-01-2005, 08:15 AM
You need to make it support an infinate number of units.

Starcraft doesnt =P.

laocoon
04-01-2005, 05:19 PM
Starcraft doesnt =P.
Yes, the linked list by nature supports an infinite number of units. If you spent the next week playing toss vs toss and building only dark archons, and workers, You could keep mindcontroling over and over again to get to the point the map maxes, but not the Unit structure. ;)
They put in a safe guard so that starcraft doesn't consume ALL your computers resources. :P

Duke
04-01-2005, 07:14 PM
Yeah, there are limits for number of units, number of sprites (pictures), number of strings, you name it. So if you wanted to, you could spam a game into submission by reaching the string limit.

llafnwod
04-01-2005, 07:26 PM
Yeah, there are limits for number of units, number of sprites (pictures), number of strings, you name it. So if you wanted to, you could spam a game into submission by reaching the string limit.I've done this with Overlords and Larvae before, it pisses people off to no end.

A.H
04-02-2005, 07:20 AM
Hope you guys have the java plug-in cuz im finished! :)

I'll write a tutorial, if anyone wants one, later I got a class right now.....

EDIT: The destroy unit is a bit buggy(I know why, just too lazy). But that point is that it works!

(Right-Click, Save-As to Download)
Program (http://www.freewebs.com/ahbwhacks/Program.zip)
Source Code (http://www.freewebs.com/ahbwhacks/SourceCode.zip)

SubZero
04-02-2005, 03:01 PM
Is it me, or are the links leading to corrupted archives?

Titan
04-02-2005, 04:11 PM
If you left click, yes. You have to right click and Save-As.:)

laocoon
04-02-2005, 04:31 PM
Is it me, or are the links leading to corrupted archives?
I tried about 3 times (right click "Save link as" in firefox) And every time it says the zip is corrupt. I was going to wait till tonight to see if it got fixed. Left clicking sends me back to the competition page :lol:

A.H
04-02-2005, 04:58 PM
Uh, thats really weird, cuz I download just fine. I'll post the jar itself, its only a little bigger then the zip and shouldn't have the same problems(maybe).

Here's the link to the .jar (Right-Click, Save As)
Jar File (http://www.freewebs.com/ahbwhacks/LList.jar)

EDIT: To run the jar file, if you don't know how, double-click it. It should work if you have the Java JRE or plug-in, whatever you want to call it.

The source code, I'll link later.

TheTempest
04-03-2005, 09:36 AM
arg...damn java :( Let me take a look at it when I get some time. I hope to recieve some more entries soon.

Good luck guys.

A.H
04-03-2005, 10:45 AM
Im just wondering, but how will you guys judge this competition?

Also, has anybody gotten the program to work on their computer? It works fine on both my Win 98(laptop) and Win XP(desktop) comps, so if anybody has any problems, please tell me. The .zip files should work also, (compressed with winzip).

LCS
04-03-2005, 11:18 AM
A.H, you can't use list boxes, you have to have it like a console.
Heres what mine is like.
http://x2.putfile.com/4/9214175849.jpg
http://x2.putfile.com/4/9214180676.jpg
http://x2.putfile.com/4/9214181159.jpg

A.H
04-03-2005, 12:03 PM
You've got to be kidding me. I don't think i have to make it use a console-like gui. Isn't the purpose of this to create a working linked list? Whatever, i'll go convert it to a console-like gui. In fact, i'll include both. ARGHHHHH!!! :hammer:

LCS
04-03-2005, 12:05 PM
If you use a list box it is so much easier.

A.H
04-03-2005, 03:03 PM
Whew, i finished converting it to the console-gui :)

Heres the links, (Right-Click, Save As)
Program (Zipped) (http://www.freewebs.com/ahbwhacks/LList.zip)
Program (Jar File) (http://www.freewebs.com/ahbwhacks/LList.jar)
Source Code (Zipped) (http://www.freewebs.com/ahbwhacks/SourceCode.zip)

And some attached screenshots.

MarcX
04-06-2005, 12:21 AM
I ... can do this in 5 minutes? T_T

Is the competition still open?

dontnoshit
04-06-2005, 06:57 AM
.

TheTempest
04-06-2005, 10:54 AM
I ... can do this in 5 minutes? T_T
Is the competition still open?
Yes..check the timedates...4/13/05 =D



Hey im just starting on c++ can some one give me some tips on doing this in c++ I just would like to learn it. Thanks.

Wow...another pointless post could have been avoided if they would just search/read. If you read my 1st post, there is a link to a pdf that, i belive, explains the process beautifuly. Also, please check out our programming section. We have gone to great lengths to provide a full and comprehensive collection of tutorial links.

Thanks for your time.

SubZero
04-06-2005, 11:51 AM
I ... can do this in 5 minutes? T_T

Is the competition still open?

Replicating what you already see is not the point of this competition.

laocoon
04-11-2005, 09:00 PM
We are comming down to the end of the time period. How is it comming everyone?
What does everyone say to an irc chat to talk about this competition, including:


what is being done
what we have learned by doing this
how it is done
why we would want to know about this
who the winner is
and a look at future competitions
We would need to schedule this in advance. Let me know what you think, I don't want to know details about your schedule yet, just whether you would be available and willing to chat on the topic.

arpsmack
04-12-2005, 12:32 PM
I was originally going to post an entry in Java, but AH beat me to it. So I thought I would make a similar version to his, except that instead of typing the menu command you wanted into an input field and hitting a "Do" button, you would simply just press a key like 1, and it would do menu option 1.
I started work on it, but got sidetracked with 2 exams, a 10 page paper on Japanese feudalism, and my final project for my Java class. Sorry to say, it looks like I wont be completing my submission (it was sloppily done anyway).

l[Random]l
04-12-2005, 12:42 PM
damn you guys.... y cant you have competition that everyone can do. Like coloring^^ :w00t: :w00t: :cool:
me like coloring :pleased: :pleased: :pleased:

LCS
04-12-2005, 04:24 PM
l']damn you guys.... y cant you have competition that everyone can do. Like coloring^^ :w00t: :w00t: :cool:
me like coloring :pleased: :pleased: :pleased:
There is an art competition here is a link to the thread:
http://www.bwhacks.com/forums/showthread.php?t=3372
:P

laocoon
04-12-2005, 04:33 PM
l']damn you guys.... y cant you have competition that everyone can do. Like coloring^^ :w00t: :w00t: :cool:
me like coloring :pleased: :pleased: :pleased:
Then noone would be pressed to learn anything from these. The theory behind the linked list is rather simple. With the documentation provided, one with a decent understanding of c++/vb/(and apparently java :) ) would have no problem creating this program for the competition.
Did you read through the documentation at all random? If so, what part gave you troubles?


edit: lcsbssrhxxx: i was going to put that link in there, but you distracted me on aim when I was typing the post =p

A.H
04-12-2005, 04:55 PM
I was originally going to post an entry in Java, but AH beat me to it. So I thought I would make a similar version to his, except that instead of typing the menu command you wanted into an input field and hitting a "Do" button, you would simply just press a key like 1, and it would do menu option 1.
I started work on it, but got sidetracked with 2 exams, a 10 page paper on Japanese feudalism, and my final project for my Java class. Sorry to say, it looks like I wont be completing my submission (it was sloppily done anyway).

You get an 'A' for effort arpsmack. :)

And when is that irc chat gonna be? I won't be home til..... 6:00 PM Pacific (homework kills), but i guess you guys could start without me.

l[Random]l
04-13-2005, 01:41 PM
the only problem is i dont know how to do anything at all^^, im a lil slow learner :D
i try art contest :)

Gantznaught
04-13-2005, 04:14 PM
wait wait wait...competition ends today!! Where are the submissions and the results? And the winnar!?

hba
04-13-2005, 04:21 PM
I win by default. Now give me the gold. :D

Gantznaught
04-13-2005, 04:25 PM
I win by default. Now give me the gold. :D

apparently you have enough already in your teeth.

hba
04-13-2005, 04:27 PM
Nah, Lil Jon has Platinum and Diamond teeth plates, no gold.

A.H
04-13-2005, 07:11 PM
Nah, Lil Jon has Platinum and Diamond teeth plates, no gold.

To me, thats no different than gold.

blackkbot
04-16-2005, 06:43 PM
i hope this is still going on since i figure il finish it in java

nickolay
04-16-2005, 06:45 PM
3-31-05 -> 4-13-05 Competition

blackkbot
04-16-2005, 07:01 PM
yea i saw that but then again i don't see another competition and i haven't read about any finished products

laocoon
04-16-2005, 11:07 PM
I need to get with A.H. His links were all screwy and I will have to take a look at his source code. If he meets all of the requirements of manually building a linked list ect then he can be declared winner (due to not enough entries). Frankly, I hate programming in java. It is better than delphi though :P Tempest and I did have plans as to a final project to be building up to through the competition, but if linked lists were too hard to understand, we can take a step back/change the direction of the competitions. :)
Give us a week or two to get the next competition up.

Did anyone have any thoughts/questions/comments on this competition?

Incognito
04-17-2005, 03:23 AM
yes - it's 20 lines of code in perl ;)

blackkbot
04-17-2005, 06:49 AM
nah linked lists were no problem for me infact i wrote the class in about 2 seconds but then again java makes it really easy maybe next time you should make us use a recursive sort

A.H
04-17-2005, 07:19 AM
nah linked lists were no problem for me infact i wrote the class in about 2 seconds but then again java makes it really easy maybe next time you should make us use a recursive sort

im guessing you type at 300 words per sec? It also takes more then one class to make a true linked list in java.

Oh and Jakor, exactly when are you on MSN messenger?

laocoon
04-17-2005, 09:12 AM
im guessing you type at 300 words per sec? It also takes more then one class to make a true linked list in java. ;) Just from your response, i can tell you know what a linked list is. :lol:


Oh and Jakor, exactly when are you on MSN messenger?
I'm on most of the time (away, but trillian accepts all incoming transfers.) You could also email me.(same as my msn messanger e-mail)

MarcX
05-01-2005, 12:41 AM
A linked list in java?

No pointers? T_T

Wait... there are pointers, using '='. I believe if you assign a variable name to another, both will point to the same object instead of both being a different object with the same value. Argh, java's too easy/too hard ;p

BTW, I wrote a linked list class in c++ but I was too lazy to look up all the unit hp's and everything. Should I paste my code here?

[Edit]I just remembered, java already has a class like mine, I think it's named vector? You can just use that in java ;)

Incognito
05-01-2005, 03:50 AM
Java has a linked list implementation, a vector implementation and is generally quite simple as far as data structures go. If you like I'll write up and post a simple implementation... infact, this is 90% of what you need:


Public class Node {
Node _next;
type _data;

Public Node() {
_next = null;
}

Public Node(Node other) {
_next = other;
}
}

Now make a list class and some methods.

MarcX
05-01-2005, 03:06 PM
Myeah, figures.

A.H
05-01-2005, 03:23 PM
Yeah, you got the basics of it down Incognito. I just want to make something clear: Vectors and Linked lists are not the same. Vectors have a set length, and then expands as necessary to let more data in, while linked lists have no set length.

bulk_4me
05-01-2005, 03:37 PM
You need... mmmm... Node.java, List.java, LinkedList.java, and LinkedListDriver.java.. :P

Incognito
05-02-2005, 09:36 AM
You need... mmmm... Node.java, List.java, LinkedList.java, and LinkedListDriver.java.. :P
You *need* List.java and that's it. You *should* have a file for Node, for List and for something that uses it (driver, but I'm assuming u won't actually call it a driver since it would probably have actual use of a linked list). Don't know why you bothered with 2 list files...

It's obviously a very lame implementation - it has no methods and took me under 2 minutes. If you want a good one you can look it up or ask me nicely. ;)

And yes, a vector is not a list by any means. The implementation is very different and hence the efficiency and costs (both runtime and memory).

A.H
05-02-2005, 02:52 PM
You also could just check out my code(somewhere in this thread) which had been available for all to see for some time now.

I think what Bulk meant with the List.java is to use it as an interface. So that LinkedList.java implements List.java, and the two can be user interchangeably.

Incognito
05-03-2005, 02:12 AM
You also could just check out my code(somewhere in this thread) which had been available for all to see for some time now.

I think what Bulk meant with the List.java is to use it as an interface. So that LinkedList.java implements List.java, and the two can be user interchangeably.
Yeah, but then it should be ordered set, not list, but I see your point.