Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / - DBPro Coding Challenges -

Author
Message
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Dec 2008 13:28 Edited at: 8th Dec 2008 13:35
Sorry I will try a bit harder now, Im getting better at organising my time better so hopefully i can put together completed entries in the future.
Thanks BillR and everyone else who entered this challenge. I agree BillR its a great place to learn how to programme and ive already learnt how to do a lot more than i used to. Whats wrong with the array? Ill have a look and try to fix it. I dont understand why some codes work for some and not for other people...
A christmas related challenge sounds good but does anyone have any ideas...
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 8th Dec 2008 16:38 Edited at: 8th Dec 2008 16:47
Quote: "Glad to here from you RiiDii, hope you enter the next challenge"

Thanks. I hope I can enter one of these. Working and going to school leaves not much time.

I'm going to throw two cents in here. How about a Sim challenge?

The Basics - Sims, Buildings, and Resources:

Resources: These are values that help keep track of the resource needs within the Sim world. If something that requires a resource runs out of a resource, then something bad happens (Sim dies, building collapses, etc.). If a resource goes above a certain level, something good happens (building upgrades, Sim has a baby, etc.).
-Resources can be accomplished using a simple array variable (or UDT).

Sims: Are mobile entities and carry resources to other Sims or buildings. Sims often consume resources, but can produce them as well.
-Sims can either randomly walk around the world and pick up/drop off resources, or they can move from point to point using a simple AI pathing.

Buildings: Are non-mobile entities. Buildings often produce resources, but can consume them as well.
-To produce or consume resources, simply add or subtract to the resource array variables.

Edit:
One could also go back to the early sim text games. Basically, control resources and consumption on a very high level. For example; 200 people eat 600 units of food daily. It takes 10 people to run each farm at full production, which can produce 100 units of food each day. The player has to allocate enough farms and farmers in order for the population to stay alive. If the population has enough food (or more than enough) the population grows. Otherwise, the population is reduced.


Open MMORPG: It's your game!
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 8th Dec 2008 22:44 Edited at: 8th Dec 2008 23:03
A Sim challenge might be interesting.

If you wanted a Christmas challenge, you could use the same wrapping paper graphic they used last year. That would be the only media allowed.
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Dec 2008 22:49
Sounds interesting RiiDii,
Maybe we can try this and then start a christmas challenge in a couple of weeks...

Ok so New Challenge: Create a small Sims community

Just to make a little community of a few beings (creatures etc let loose your imaginiation), that can build buildings, and do various simple actions (again limited only by your creativity). Should have at least two resources, food and water, though more advanced codes should try to include more than two.
You will be judged on controlability of creatures and resources (ie can you start with more or less food to make it longer/shorter etc)
also on smoothness of play so that it all makes sense etc
and if you make really cool creatures or buildings then im sure that bonuses could be awarded.
Hope thats clear enough for everyone, if not do please look above at RiiDiis post as that outlines a rough sims environment.
I also look forward to the outcomes of your programming!

Deadline: Just under two weeks, midnight on this server on sunday 21st December
Have fun and let your imagination roam as free as your sims...
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 10th Dec 2008 06:21
I don't know if I will have time to enter, but I can throw some code out for folks to use. In a sim, it can be useful to be able to check for objects that are within a given range and then look for those objects within an array. This can be slow if you search straight through the array. This code snippet can help find an Object ID (Entity ID) quickly by using a binary search.




Open MMORPG: It's your game!
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 10th Dec 2008 18:39 Edited at: 10th Dec 2008 20:09
Erm... could anyone explain what RiiDiis code means, does or how it could be adapted?? I havent got a clue what a binary search is ... Or anywhere i could find out?
jason p sage
19
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Dec 2008 20:38
He's basically using math on the items in the array to get a "brief" numeric result that describes the "status" of elements in a brief way... and iterates through to see if the "status" math result is like what he's "binary searching" for.

I'm not knocking his method in any way - however I'm not sure how much time that technique would save you... so just look closely at how he still has a loop iterating through the array, he has a test condition - that if met causes the loop to cease - most likely on a search criteria "found".

Don't get to discouraged by not getting it right off. there are alot of tricks you may learn to do over time where you maybe write a loop - that seems to go a bit slow, and while trying to speed things up - you may notice that some lines can go before the loop - and having them in the loop is redundant. You may find little math tricks that get you an exact result by thinking out of the box to reach your goal with less CPU cycles.

Binary, as it relates to computers, is one of those words that can be misunderstood easily if not used in a context that really explains the meaning.

Try not to get to hung up on that. For example - there are Binary Trees (BTree) which binary is just a word and the "compound" phrase Binary Tree - implies a method of storing data that happens to be geared for quick searching etc. Searching a binary tree might be called a binary search... then again maybe not -

Hope I was somewhat helpful.
--Jason

BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 11th Dec 2008 01:00
Great challenge, I'm in!

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 11th Dec 2008 07:26 Edited at: 11th Dec 2008 07:30
Just use it like an array (you can worry about how it works later). The search features for large arrays will be faster than a straight For i=0 to Array Count(MyArray()) type search. Use the Add_Entity() function to add a new element into the array so it is place in ascending order. This way the search can find the element.

One could probably write a simpler version of this code, but I tried to make it very generic so anyone could use it for almost any code (with some modifications).

Edit: As far as how much time it can save is potentially a lot. To search through, say, a 10000 element array would be O(10000) or up to 10000 elements. This binary search will take a maximum of O(16), or up to 16 elements. Which do you think would be faster?


Open MMORPG: It's your game!
jason p sage
19
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Dec 2008 07:30
Does that code construct gain ya some speed there?

Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 17th Dec 2008 20:04 Edited at: 18th Dec 2008 19:55
Only 4 ish days left to deadline so I hope to start seeing some entries soon...

Ive tried to have a go at this challenge as well just to practise, though being fair im not that far really at the moment, nor is it that good. What i have at the moment is a sphere moving to and fro two boxes, hopefully a starting point for a sims challenge.



I know you all may be busy with your own entries but if anyone could take a look and possibly find out why it slows down when the sphere enters the cube. My suspicions lie in my code but its only 140 lines long so im not sure... (sorry guys, sorted, i had a wait command in )

RiiDii i will try to use your code but at the moment im just trying to get some code together and binary searches are out of my depth at the moment! Possibly one of many areas i am yet to learn about...

Good Luck with your entries and hope theyre coming on well.

Edit:
The code is as up to date as ive done and i think all i need to do is add resources and interactiveness.
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Dec 2008 23:51
Gah, only 4 days?! I'm going to have to work fast to get even the basic pathfinding, building, and resources systems down...

acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 18th Dec 2008 00:35
I haven't had much time to participate lately, been extra busy with work. I am trying to get something together for this comp on my lunch breaks. I will post an entry before the deadline, I promise.

(That promise is more for myself to make sure I get it done, now that I have posted, I must follow thru)

( 2b || !2b ), that is the question. The answer: true
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 19th Dec 2008 18:54
Does anyone know how to select an object on a screen?? I have my spheres moving well enough (more editing needed to be done) but i cant select them thus hindering the interactiveness... Any ideas welcome

This is what ive done so far...


The aiming is off at the mo as im trying to sort out the user control first. Thanx
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 19th Dec 2008 21:55
Have you tried PICK OBJECT?

Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 19th Dec 2008 22:05
I had a look at it on some code i had lying around but i coudlnt really figure out what the object start and object end were for... and the help file on it wasnt very good either.
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 19th Dec 2008 22:38
@Monk,
You obviously are not endowed with extra sensory power, and therefore are unable to interpret the DBP help screens.
When doing a PICK OBJECT, you specify a range of object IDs to check, so that you do not have to check every object in your program. This speeds up the command.
So, if you write your program so that the objects you wish to select on screen have an object number between 1 and 100, your object start=1, object end=100. The PICK OBJECT command then only checks object 1 thru 100 to see if you have PICKed one. If there are 900 objects in your program, this saves time by only checked 100 of those objects.

( 2b || !2b ), that is the question. The answer: true
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 20th Dec 2008 14:47 Edited at: 20th Dec 2008 15:21
Ah ha ! That makes so much more sense now. Cheers Accelepage Thats why you're soo much better than me...

(Im guessing that the screen x and screen y can be set to the mousex and mousey positions to make that work)
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 21st Dec 2008 12:37
Last day people!!
I hope to start seeing your entries today, even if you haven't finished still paste it here as you never know you might win!!!

Hope lots of people have entered...
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 21st Dec 2008 14:07
sorry to post again but acelepage, all my pick object commands keep returning a value of 0



and i havent a clue what im doing wrong because i have objects in that range, onscreen and nearby. In the sims case im pointing at them and it still returns a 0 and object number is invalid error...
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 21st Dec 2008 16:02
I'll have an entry this afternoon, I finally go A* to work, now I just need to make the sims follow the path...

Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 21st Dec 2008 16:13
Good bmaczero lets hope there are more entries on the way

I know i cant win coz i set the challenge but i thought id enter to have some fun so heres my attempt



Theres a few problems with the code for example if you add a house to increase the population, the current population run away so you end up with the exact number you had before, and you cant select any sims, you can only give them more places to randomly go to, but im happy with the attempt.

Ill judge all the entries tomorrow and let you know who the winner is!
Good luck all !!!
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 21st Dec 2008 17:09
@Monk,
Your code seems OK. One possibility is that you are using more than one camera. You have to set the current camera for the PICK to return correct data.
I have a PICK OBJECT in my code and it works for me. I am also using mousex and mousey. Perhaps you should start by specifying all of your objects, instead of a subset, in case your object numbers are not in the tange you are expecting. Example: pick object(mousex(),mousey(),1,220).
I will post my entry below, so you can see my application of the command.

( 2b || !2b ), that is the question. The answer: true
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 21st Dec 2008 17:16
Here is what I have so far. Blocks represent animals, and spheres represent plants. 2 colors of animals for the sexes. Block flashes red when attacking other animal. Little blocks are babies. If an animal dies, it turns grey and shrinks, causing plants to grow in its place.
Move the camera with cursor keys. Clicking on a block displays statistics for that animal.
(I'm not getting lunch breaks on the weekend so I don't think I'll be able to add any more code to it today, here it is with no warranties or guarantees)


( 2b || !2b ), that is the question. The answer: true
aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 22nd Dec 2008 03:23 Edited at: 22nd Dec 2008 06:55
*edit*

Here is my entry...Its not that great, but other than a buggy pong its my first game...its all text based, includes population growth, population decrease, food and water resources that are gained and lost according to population.

and you can lose... but I doubt anybody will...

*edit 2*
fixed a typo i found when I ran the code...text was messed up.. -_-



CnC welcome



Image thanks goes to bmaczero
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Dec 2008 05:56
Here's what I managed to hammer out.

The idea behind the game is that your sims will wander around, minding their own business, but you can influence their actions somewhat - for example, say "build this there!" and a couple will march over and build it. Features:

- A* Pathfinding
- Build buildings (actually only one type of building)

Yeah, it's still a little glitchy, and pretty simple as far as gameplay xD.



aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 22nd Dec 2008 06:16
bmaczero, I'm in awe of your sim....its kicks the tar out of mine....amazing job!



Image thanks goes to bmaczero
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 22nd Dec 2008 12:39
Im sorry that im not that smart but bmaczero when i try to play your sim game i come across two problems which are probably down to me more than you. The first that i get is that an error comes up and says that it "could not find field sex in type sim at lne 164", which seems to work fine when i get rid of the comment, and then when i place a warehouse the target x value for the sims jumps to minus one and they dont move...
I am very impressed by your code but as i say im sorry that im not brilliant at coding and havent a clue what ive done wrong...

@aarrowh i havent made many games either so its not all bad...
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Dec 2008 16:06 Edited at: 22nd Dec 2008 16:09
Thanks for the compliments .

@Monk
I'm betting that you have a different version of DBP than I do. I'm running 7.0 (1.007). You should check yours and see if you need to update it.
Your game seems to be coming along, my one big criticism is the controls. I had to scroll through the code to find what keys I had to use to build stuff - you should list the controls on-screen.

@aarrowh
I just got a chance to try yours. It could be a fun game to test people's typing skills . It's a good idea, but I agree that it's too hard to lose. All the player has to do is type "food" and "water" rapidly. I guess the deadline has passed, but if you wanted to keep working on it you should probably increase the rate of food and water use.

@acelepage
Great, as usual . The only way I could improve on that would be to add some user controlablity - let them set initial populations and such, like those population sim games.


EDIT: By the way, aarrowh, I didn't make the NaGaCreMo sig; AndrewT did.
EDIT: Also, Monk, if it still won't work for you, I could upload a compiled version.

Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 22nd Dec 2008 16:23 Edited at: 22nd Dec 2008 16:30
Gd point bmaczero i was running 1.052 which may or may not make a difference but ill update it to see what i can do. Would it be possible for you to upload a compiled version as well just in case? Cheers.

Edit:
hmm. Just installed version 7.1 and the compiler won't work so im going back to my older one, so could you put a compiled version up cheers bmaczero


@Bmaczero,
yeah i know i meant to but forgot.. sorry

@Aarrowh,
it may say something about my game playing skills but i lost at your game on my first go, i think i kept tripping and dropping the water

Once ive played your game bmaczero ill give my verdict
aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 22nd Dec 2008 17:03
@ Bmaczero,
Ya I've made it a lot harder to play now, also made it not just skip half of your work day if you type and un-recognized command. Oh..well i'll change the name then.

@ Monk
haha, its all good, my brother lost when tried it.



Image thanks goes to bmaczero
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Dec 2008 17:14
Okay, here it is.

Good luck to all!

aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 22nd Dec 2008 17:24 Edited at: 22nd Dec 2008 17:25
Hopefully I'll have a bit more than 2 days for the next challenge...

actually be able to come up with something 3d next time!!...depending on the challenge of couse...

Good luck to all!



Image thanks goes to AndrewT
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 22nd Dec 2008 23:12 Edited at: 22nd Dec 2008 23:14
Hooray! Decision made!

Sims challenge:

Bmaczero:
Nice entry, I like the way you've managed to make it look like the people are building the warehouse and I also like the fact that you've given them names Any chance you could explain A* pathing sometime? Lacks resources though which is a shame.

Aarrowh:
Nice text based entry, good to see variation on the challenge. Included resources, and though you said it was easy, i would disagree. Makes a nice game to start from and progress your learning with.

Acelepage:
Nice well made sim. I like the idea of putting plants and animals in a cycle, and having fights as well, i think it makes it more realistic. Doesn't score hugely on user controllability as you can only view status not change it.


Runners up:


Winner:



I hope that people may continue to develop these games as there is lots of promise seen here. And i look forward to see what you are going to do to yours, bmaczero, as part of NaGaCreMo '09.

Congratulations and looking forward to the next challenge.


P.S do i have to email the entries to someone at the end of the challenge?
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Dec 2008 23:16
That's very true, I got so caught up in the pathfinding that I didn't include the basic resources xD. Congrats, aarrowh!

I used this tutorial to learn about A*, I could write one specifically for DBP though:

http://www.policyalmanac.org/games/aStarTutorial.htm

aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 22nd Dec 2008 23:34
@ bmaczero,

Thanks! Ya I was wondering about the pathfinding as well...I DBP tut would be awesome!


Ok, So this was my first challenge, and I don't really have many ideas for any others...anybody got any ideas???



Image thanks goes to AndrewT
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 23rd Dec 2008 01:36
I was thinking of what the next challenge could be. I had in the back of my mind a physics bouncing ball challenge. I used to try and make a bouncing ball against floor wall and 45 degree slopes (all 2D, in QBasic). It would be challenging to have a ball bounce against a variable surface (2D or 3D), and against other bouncing balls. Maybe add some ramps, interactive gadgets.

( 2b || !2b ), that is the question. The answer: true
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 23rd Dec 2008 02:18
How about a train simulator? Simple 2D track, or more ambitious 3D track, like the traffic simulator we did a while back?

( 2b || !2b ), that is the question. The answer: true
aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 23rd Dec 2008 03:19
I like the bouncing ball idea.

Challenge: Physics bouncing ball

Entrants will create a ball that will bounce around the screen. 2d and 3d allowed. extra points awarded for physics, "gadgets" and such.

All entries due by 12:00pm of January 21st '09

(if time is too long or to short tell me...first time at this thing..)



Image thanks goes to AndrewT
flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 23rd Dec 2008 03:42
oh boy! I actually have a 2d physics hicup from awhile ago I could pull out and finally have a reason to finish.


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 23rd Dec 2008 05:27
ah! i'm definitely going to do this one.
aarrowh
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 23rd Dec 2008 07:12
I'm alowed to make an entry bit I just can't win correct???



Image thanks goes to AndrewT
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Dec 2008 08:33
Correct.


Open MMORPG: It's your game!
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 23rd Dec 2008 13:09 Edited at: 23rd Dec 2008 13:11
A variation of pong? Would that be allowed?

@bmaczero ,
A tutorial would be great if you wouldnt mind doing one, I think many people could learn a lot.
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Dec 2008 17:09
Here's one demo. It is a pinball game I wrote a long time ago. I am not entering it. It is just here so folks can see one way to do collision.




Open MMORPG: It's your game!
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 24th Dec 2008 20:23
Merry Christmas All!! Hope it's a happy white one!!!
Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 26th Dec 2008 03:17
Ohhh its been a while
I'll be entering this one for sure.

Pillarofire
22
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 27th Dec 2008 12:10
Quote: "Hope it's a happy white one!!!"


Well, I like the tropics, but thanks anyway.
Coldfire
17
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 28th Dec 2008 13:01 Edited at: 28th Dec 2008 13:58
Here is my bouncing ball... er balls... 10,000 to be exact. All have individual physics properties such as position,velocity, acceleration and restitution that can be edited at any given time. The only collision i have so far, however, is with an invisible ground plane. i still plan on adding mass,size, and local gravity properties, then I will release the code. If I have the time, I will update the collision as well. Here is the screenie I have so far...

http://www.flickr.com/photos/7336529@N04/3143204589/

On a side note, i have also set it up with functions in a very modular way so that it should be easy to use as the grounds of a physics engine, if you choose to do so

i've now added a video beacause i realize a picture of physics in action isnt worth very much, lol.

http://www.youtube.com/watch?v=tPprNNeBHPQ

"They say beer will make me dumb / It are go good with pizza" - Psychostick
Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 28th Dec 2008 18:21
Whoa! that looks cool!
Just a suggestion, would it be better in a cube rather than just bouncing across the ground? or would that just be too busy?

Login to post a reply

Server time is: 2026-07-05 05:45:46
Your offset time is: 2026-07-05 05:45:46