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
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st May 2006 14:16
If we're sticking to the two week time limit, then the deadline for this challenge is tomorrow - Tuesday 2nd May. I'm going to have a short burst on this challenge now just to see if I can come up with anything.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st May 2006 17:29
Wow, those 2 weeks flew by. So far, only CF has entered. I hate to say it, but it looks like this challenge fell way short of expectations. Looks like I'll never be allowed to choose again. I hope you manage to get something in Ric.


Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st May 2006 17:31 Edited at: 1st May 2006 17:31
I'm working on a stickman animation creator. The idea is that you draw your stickman by creating joints ('nodes') on the screen, then connect the nodes to draw the character. Then you move the nodes around and take snapshots of certain keyframe, and the code then 'tweens' the keyframes together making the animation. The animation can then be exported as self contained code.

The thinking behind this method is that, if desired, you could load a video clip of a person walking, for example, and draw your nodes over the top of the video clip, then advance the video on a few frames, adjust the nodes ect. - producing a basic motion capture technique.

This is how it looks so far:



Attachments

Login to view attachments
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 2nd May 2006 00:05
This challenge is something i'd really be interested in - I was gonna try to make some kind of stick man which used interpolation to kick a ball, but you use the mouse to control the swing of the leg. Ideally, i'd like to make some kind of Hackysack simulator...

BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 2nd May 2006 01:31 Edited at: 2nd May 2006 01:34
I'm working on my program also, just way behind, I think some burning of the midnight oil is needed to get something that at least works a little bit.

@Nicholas, hope you get something done, would love to see it.

@Ric, really looking good.

@Coding Fodder - I like the way your entry is coming along too.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 2nd May 2006 03:02
I'm not going to get a chance. I've had to setup my home server this weekend and its back to work tomorrow/today :-(

Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 2nd May 2006 03:28
Nice work Ric! Thats something I would use!

When in Trouble with anything visit here your number one stop for help
Coding Fodder
21
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 2nd May 2006 06:14
I have not ahd nearly enough time to work on this. but here is a working product.... that is to say it is tedious to use and does not Export ATM. Maybe if I still have time tomorrow.

(A) enters the animation editor
(L) Selects a limb 1-20
(K) Sets A KeyFrame.

Sorry about the UI. but any animation should be possible with this.



cheers

~Fodder

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 2nd May 2006 22:03 Edited at: 4th May 2006 00:47
I will post something later today as an entry, here is some code that I'm still working on.

Nothing works yet, just random dance moves.

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd May 2006 22:16
That's exactly how I dance.

I'm continuing with my code now. Will post later.

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd May 2006 01:43
Just incase I don't get time to finish this before deadline, here is my code so far. You can create a character, and you can animate it, but as yet, you can't save it.

The sequence for creating animations is:

1. Add nodes
2. Join nodes (click on source node (goes green) then target node (goes red) to join nodes with a line)
3. Move nodes to adjust to desired position
4. Save keyframe
5. Increase keyframe

then repeat steps 3 to 5 - moving the positions, saving the frame, then advancing the frame. You can go backwards and forwards through the keyframes adjusting positions as you like - just remember to save each keyframe if you're happy with it.

At any time, you can click 'play animation' to see how it looks.

It gets a bit complicated if you try to add extra nodes after you started, so try to add them all in the beginning before you start increasing the frames.



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd May 2006 02:49
Nice CF, lots of potential. Your sliders however, are a pain to use. And is there anyway to leave the animation editor after you enter it?

Bill, yours was quite enjoyable to watch.

If anyone thinks we should extend this, lemme know. Otherwise I'll judge tonight at midnight, 4:11 hours from this post.


BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 3rd May 2006 03:34
I will need longer than 4 hours, my day here in San Francisco, won't be over for another 10 hours, so I think everyone should have at least the rest of the day wherever they live.

You can judge them tomorrow. If others vote for an extension longer than that, I will go for that also.
Coding Fodder
21
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 3rd May 2006 04:14
Quote: "And is there anyway to leave the animation editor after you enter it?"


erm.. nope Other than ESC you mean. I know the sliders are annoying. I just took the easy way out for data entry. I will try to rectify some of the UI issues this evening.

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd May 2006 04:33 Edited at: 3rd May 2006 04:43
Ok - I'm done!

"Battle of the Square Heads"

(watch out for the dirty kick in the gonads!)




Here's my final animation: (this is the player code - just run it to see the animation).





The data statements are mainly just the x,y and z positions generated by the animation editor.

This is the editor I made to produce the animation:



Now when you click on 'save animation' it creates a file called 'animation.dba' containing all the data statements you need to copy and paste into the player code above. The only problem I had was it sometimes produced numbers like 11.4e-8 in the data statements, which the player code couldn't read properly, so I had to manually change those values to 0.

Attachments

Login to view attachments
Coding Fodder
21
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 3rd May 2006 04:51
that is a serious lot of data statements. can't you just save the key frames and interpolate. Other than that it is a nice fluid animation.

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 3rd May 2006 10:36 Edited at: 4th May 2006 00:34
Here is my entry - still working on it, but in case he judges before I get to post again, here it is.
The QWERTY poses are the keyframes, I tween between the different keyframe poses.



Press the QWERTY keys for dancing.
Pressing the keys back and forth before he finishes a pose, will make him stutter dance.
Press the Space bar for Random dance mode.
Sequential and Live mode didn't get finished yet.
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd May 2006 16:55
Quote: "that is a serious lot of data statements. can't you just save the key frames and interpolate."


It does that. The only data is keyframe data for each joint in the characters - the code interpolates ('tweens') the frames inbetween. The reason there's so much data is purely because it's a long animation - 30 keyframes, with 28 nodes in each keyframe, each requiring an x, y and z coordinate. If I had made a single stickman and animated him over just two or three keyframes, the data would have been a lot less - I just got a bit carried away!

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 3rd May 2006 17:37
Safe to say we have a winner there imho - thats fantastic!! Ric - you do know you can put more than 1 value per line when it comes to Data statements, dont you?

Ric - if you could get that down to under 20 lines, you'd be in for a winner there I think

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd May 2006 18:52
Cheers Nick. With a bit more thought I could probably have got the editor to output multiple data on the same line .... but it was 2.30am .... nuff said!! As for the 20 liner, I suppose there's nothing wrong with putting two thousand or so values on a single line, as the rules say 25 'commands' per line, although I think it may be pushing the rules a bit! Actually, come to think of it, aren't you allwed media in the 20 line challenge? I could just save the data to a file.

But hey - I already won the twenty liner once anyway!

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 3rd May 2006 19:13
Why not become champion of that too? (you're already leading these challenges!)

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 3rd May 2006 22:21
When is the deadline then? I'm gonna give this a go tonight...

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd May 2006 23:08
Bill, I keep seeing "ode end" in your code, which I have to keep removing when I run your codes.

Alright, deadline is here, sorry Nic.


BillR, I enjoyed the dancing, and each stage moved into the others very fluidly.

Ric, picking the guy up by the neck then pounding him across the screen really gave me that stickman kung fu feeling from all those flash videos online. The editor seemed great, but when I tried to play the animation inside the editor, all the nodes just popped into a single place overlapping each other. Never saw anything move.

CF, yours has a lot of potential in the way it was coded. It looks the easiest to reuse within future projects for anyone.

Runner-up


And the winner is....



Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 3rd May 2006 23:11
BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 4th May 2006 00:51
@Ric - Big cheers for your win with a cool program!

I would love to save & load a character though, so I wouldn't have to build from scratch each time.....hey something for you to do after you pick the next challenge...hehehe

So......what will the next challenge be....hmmmm
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th May 2006 01:40
First Suggestion:
Have we ever had one on some kind of virtual desktop or customisable GUI?

It'd be really cool if we could make medialess menu code for drop down menus (and submenu's?) which you can copy and paste into a project (maybe semi transparent too?)

Or alternatively, a Virtual Desktop which has effects like the OSX operating system (when you minimise, the window morphs shape in a kind of genie-in-a-lamp kind of way)


Second: Some kind of efficient Wave simulation. Either static or dynamic ripple effect? Could be 3D using vertex manipulation, 3D using a new mesh each time or 2D (using memblocks?)

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 4th May 2006 02:52
Woohoo - cheers Phaelax! Not sure what happened with the editor, although as I basically designed it for me to use, I didn't 'safety check' it to make sure you couldn't break it if you did things in, say, the wrong order.

@Bill - yeah, the save nodes feature would be really easy to add, I just ran out of time! I'll see if a can find time at the weekend.

As for the next challenge - I'll have a little think about it and post it tomorrow.

Coding Fodder
21
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 4th May 2006 04:47 Edited at: 4th May 2006 05:03
how about a pure coding challenge such as accomplish task A with the fewest commands or in the least calculating time. Why? because I am much better at that sort of thing than graphics and such and we have not done it since the primes and and mersenne primes challenges. (in another thread folks the one that started this one) anyone remember KimoSabe?

[edit] I found the tread http://forum.thegamecreators.com/?m=forum_view&t=47392&b=1
for an example

hmm could not find the mersenne prime challenge oh well

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 4th May 2006 04:59
Congats Ric!
I will resubmit my Idea
Quote: "I was going to suggest a level\world\map editing program"

PLEASE!!

When in Trouble with anything visit here your number one stop for help
The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 4th May 2006 05:18 Edited at: 4th May 2006 05:18
cmon ric, give us a good one!
plz dont let it b a editor.

stargate sg-1 the one show that never gets old

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2006 07:31
Darth, we've done a level editor before.

I suggest something simple, to regain some attention in the challenges. I did pick a rather difficult one and was happy to have gotten those 3 entries.


Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 4th May 2006 07:54
Really!? Let me have a look...

When in Trouble with anything visit here your number one stop for help
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2006 08:06 Edited at: 4th May 2006 08:18
Start flipping through pages then, cause I sure don't remember when it was. (i think in the 60's somewhere)

i was close, 50's.

http://forum.thegamecreators.com/?m=forum_view&t=48011&b=1&p=52

Starts there, and you can start to see some screenshots from us on page 53.


Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 4th May 2006 08:54
Thanks Phaelax!
Looks good, In fact this might just be what I am looking for!

When in Trouble with anything visit here your number one stop for help
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 5th May 2006 01:25
Right then, here's the next challenge. Thanks for the suggestions - I liked them all, but decided to go with CF's idea of getting 'back to basics'. No graphics, just pure logic.

___________________________________________________________________

-- The Challenge --

How many numbers below one million have increasing digits?

A number has increasing digits if each digit is not exceeded by the digit to its left and is said to be an increasing number; for example, 45579.

There are exactly 219 increasing numbers below one-thousand.

How many numbers below one million are increasing?

___________________________________________________________________

The winning code will be the one that calculates the correct answer in the least amount of code. I will be measuring the amount of code by counting the number of lines, and you may not stack code onto one line using the ':' symbol.

Deadline: one week from today - Thursday 11th May



The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 5th May 2006 01:38
i dont get it

stargate sg-1 the one show that never gets old

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 5th May 2006 01:44
Basically, an increasing number is one where the number to the left of each number is less than the current number - examples:
123456
111112
211111
654321

Better?

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 5th May 2006 02:07
Answer=5004



There was an easier way using strings and val$ but it was so slow that I suddenly had a brainwave.

I still think it can be optimized further by using recursion.

Boo!
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 5th May 2006 02:09 Edited at: 5th May 2006 02:17
Easy!

FIXED


At least farting ferrets are better than stinky stoats.
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 5th May 2006 02:10
Are you sure that's right? The answer sounds more likely than mine, but the method is wierd.


At least farting ferrets are better than stinky stoats.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 5th May 2006 02:19 Edited at: 5th May 2006 02:26
We'll see what Ric says.

Shorter code;



[EDIT] Last update up the night. EVEN shorter code but just remaining in bounds of rules by not stacking commands with :, but using if then structure;



Boo!
The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 5th May 2006 03:29
i think this calls for a harder challenge

stargate sg-1 the one show that never gets old

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th May 2006 03:30 Edited at: 5th May 2006 03:31
This is a naiive method using strings (as Spooky says, it's slow although it could be optimised by exiting the inner loop via the if - at the expense of another line or so):



This method has the slight advantage that you can get the answer easily for any integer other than 1000000, e.g. 3452227.

I liked Spooky's first suggestion. Recursion is nice - but harder to follow.

[Edited for silly typos.]
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 5th May 2006 03:43
certainly shorter than mine but i got 5004 also

Neofish
20
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 5th May 2006 03:53 Edited at: 5th May 2006 04:27
yay i've got a working app, now to cut it down lots

yeah i get that, im going to have to sacrifice speed for lines



9 lines < spookies :o

New site!
Neofish
20
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 5th May 2006 04:41
Ok this post deserves a new one, spooky you are wrong, it's 5005 :p

DBP:


C++: (thought i'd grace you all)


C++: (line optimised)


Neofish

New site!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th May 2006 04:43 Edited at: 5th May 2006 04:51
Do we really need 1 week for this? Perhaps 2 days would be sufficient?
Here's my first attempt, I wrote it before looking at anyone else's codes but they're all going to look pretty similar.

10 lines


Care to explain why you think its 5005? You counting 0?

Using val() is slower. (ran test twice at 1 million)
13.3 without val
15.9 with val


Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 5th May 2006 04:55 Edited at: 5th May 2006 04:59
8 lines...



I'll see if I can make it shorter...


Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 5th May 2006 06:05
Heres my try three lines of code!


I will win for sure!


When in Trouble with anything visit here your number one stop for help
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th May 2006 06:17
Thought I should mention, Spooky's super nested FOR loop method is by far the fastest. I'm sure there's a pattern in there somewhere to reduce the nesting and replace with recursion.


Login to post a reply

Server time is: 2024-11-24 20:26:49
Your offset time is: 2024-11-24 20:26:49