Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[Tutorial] whatdotcolor
Author Message
Andy

Posted: Sun Nov 30, 2003 10:48 pm   Post subject: [Tutorial] whatdotcolor

ok peeps, i know you all've waited a long time for the infamous whatdotcolor man [that's me incase you're wondering] to share the secret behind my powers so here it is.

what is whatdotcolor?
whatdotcolor is the nicest, prettiest, smartest, and the most unefficent way to solve a problem.

the general form for whatdotcolor is whatdotcolor(x,y), where x and y are integers. what the command does is check the color of a pixel.

 code: drawdot(2,2,blue) if whatdotcolor(2,2)=blue then     put "I know how to use whatdotcolor end if

the whatdotcolor in this case does return blue since pixel 2,2 is blue

now you're probably going wtf do i need this? and i dont blame you, it took me a while to realize the real use of whatdotcolor too. whatdotcolor is usually used with drawfill since you cant "drawfill" text. take a moment to think about it. when asked to do a problem involving a maze, what is the first thing that comes to you? double for loop? WRONG recursion? WRONG again:snooty:, whats with you ppl... whatdotcolor!!! if we were to solve a maze, recursion would work, but its no fun. you'd have to pass along which way you came from, and go seperate paths each time. however, with whatdotcolr, you simply plot the text maze they give you draw it out using for loops, then find the path and use drawfill! and you instantly solve the maze.

to help sink it in, i took the liberty to solve the J5 of last year of CCC using whatdotcolor... actualy i do these for fun with whatdotcolor cuz its cool

the question gives you a floor plan using "I" s and "."s. I being a wall and . being a floor. the first three inputs gives you the number of tiles, and how many rows and colums of input there are. the questions asks you to put the maximum number of rooms you can cover filling in the smallest first and then outputting how much tiles you have left over. if you were to do this quesiton using recursion, its not that hard, but i being so enriched used whatdot color.

 code: %open the window so i can close it later var window := Window.Open ("graphics:100,100,nobuttonbar,position: 1000;-1000") var file, rows, columns, wood, colorcount, temp, roomscovered := 2 open : file, "floor.in", get get : file, wood get : file, rows get : file, columns % my grid var grid : array 1 .. rows, 1 .. columns of string (1) %this basicly gets the data and draws it out using color 1 for wall and color 2 for floor for i : 1 .. rows     for j : 1 .. columns         get : file, grid (i, j) : 1         if grid (i, j) = "I" then             drawdot (j, maxy - i, 1)         else             drawdot (j, maxy - i, 2)         end if     end for     drawdot (columns + 1, maxy - i, 1)     drawdot (0, maxy - i, 1)     get : file, skip end for for i : 1 .. columns     drawdot (i, maxy - rows - 1, 1)     drawdot (i, maxy, 1) end for %now i check if the program can find color two anywhere within my boundry %if it does, i drawfill it with a different color so i dont count it again for i : 0 .. rows + 1     for j : maxy - columns - 1 .. maxy         if whatdotcolor (i, j) = 2 then             colorcount += 1             drawfill (i, j, colorcount, 1)         end if     end for end for %and now i create the size of each room with the upper boundry of array the number of times i drawfilled var roomsize : array 3 .. colorcount of int for i : 3 .. colorcount     roomsize (i) := 0 end for % now i just check the number of times each color occured for x : 3 .. colorcount     for i : 1 .. rows         for j : 1 .. columns             if whatdotcolor (j, maxy - i) = x then                 roomsize (x) += 1             end if         end for     end for end for Window.Close (window) %and now that i'm done with the window, i close it and do the rest of my calculations for i : 3 .. colorcount - 1     for j : i .. colorcount         if roomsize (j) > roomsize (i) then             temp := roomsize (i)             roomsize (i) := roomsize (j)             roomsize (j) := temp         end if     end for end for roomscovered := 0 for i : 3 .. colorcount     exit when roomsize (i) > wood     roomscovered += 1     wood -= roomsize (i) end for close (file) open : file, "floor.out", put put : file, roomscovered, " rooms, ", wood, " square meter(s) left over" close (file)

as you can see, its done very easily with whatdotcolor. when i have some time, i'll post a recursive solution too.
well thats all you need to know for whatdotcolor.
you too can become a whatdotcolor master, simply practice using it for program you do. trust me, every program can be done using whatdotcolor. if there isnt one, pm me, and i'll show you how to do it. except for ofcourse playing an mp3...

now bring on the bits mods... lol

Andy

Posted: Sun Nov 30, 2003 10:51 pm   Post subject: (No subject)

ok mods, this thing took 3500 characters, 859 words, 4 pages on ms word font times new roman, and 30 min of my time! i better get something worthy... you know, a bit for every 50 characters would make me a very very happy

[mod:7af3b9f15d]
well that was a intresting way of doing that CCC question so i think you deserve some bits for aleast that

+ a random amout of bits
[/mod:7af3b9f15d]
rizzix

Posted: Sun Nov 30, 2003 10:58 pm   Post subject: (No subject)

+1 bit

jkz u got 10 on top of dan's
AsianSensation

Posted: Sun Nov 30, 2003 11:00 pm   Post subject: Re: [Tutorial] whatdotcolor

dodge_tomahawk wrote:
...trust me, every program can be done using whatdotcolor. if there isnt one, pm me, and i'll show you how to do it. except for ofcourse playing an mp3...

sure you could

 code: var ans : string process Song     loop         Music.PlayFile ("Got Rice.mp3")     end loop end Song put "Do you want to play a song?" get ans if whatdotcolor (18, maxy - 24) = 7 then %because "yes" is longer than "no"     fork Song end if

hehehe
Andy

Posted: Mon Dec 01, 2003 11:38 am   Post subject: (No subject)

ok azn, u got skillz, i give you that... so you can do any problem using whatdotcolor. if you find one that i cant, i'll give you all my bits... lol
bugzpodder

Posted: Mon Dec 01, 2003 5:12 pm   Post subject: (No subject)

Make a program that draws a circle whenever it encounters whatdotcolor, and make it output "I cant dont this whis whatdotcolor"
Andy

Posted: Mon Dec 01, 2003 6:29 pm   Post subject: (No subject)

bugzpodder wrote:
"I cant dont this whis whatdotcolor"

umm that made no sense to me... what do you mean? if you'll tell me i'll use whatdotcolor to do it...
Martin

Posted: Tue Feb 24, 2004 3:44 pm   Post subject: (No subject)

Make a program that takes a line of text from a file and puts it below the line in reverse order, using whatdotcolour.

ex.
File.txt:
Hello

then you get this and file.txt becomes
Hello
olleH

Cervantes

Posted: Thu Feb 26, 2004 7:11 pm   Post subject: (No subject)

not hard darkness
 code: colourback (0) cls if whatdotcolour (1, 1) = 0 then %whatever the code is to do your text thingy end if

muhahaha whatdotcolour can be used for everything!
Andy

Posted: Thu Feb 26, 2004 8:03 pm   Post subject: (No subject)

dude, that wuz lame

 code: var fid : int open : fid, "text.txt", get var ch : string (1) var count := 0 loop     exit when eof (fid)     get : fid, ch : 1     count += 1     drawdot (count, 0, ord (ch)) end loop close : fid open : fid, "text.txt", put for decreasing i : count .. 1     put : fid, chr (whatdotcolor (i, 0)) .. end for
programer007

Posted: Sun Mar 07, 2004 4:38 pm   Post subject: (No subject)

how did you get the title: Whatdotcolor warrior??is it because you use it the most???? and taht program you posted.,... it wont wokr.. IO error for the files....cool deal tho.. i could use it in the future
Cervantes

Posted: Sun Mar 07, 2004 4:55 pm   Post subject: (No subject)

He got the whatdotcolour warrior title cuz he's a mod.
your post is spam. Try to keep the spam to the spam section alone. I advise you to look at the rules
Read em all, not just the part on spam.
AsianSensation

Posted: Sun Mar 07, 2004 6:54 pm   Post subject: (No subject)

programer007 wrote:
how did you get the title: Whatdotcolor warrior??is it because you use it the most???? and taht program you posted.,... it wont wokr.. IO error for the files....cool deal tho.. i could use it in the future

he got the title for whatdotcolor warrior because dodge is obsessed with it, and tries to do every single question with whatdotcolor.

As for the error, read up on File input and output, because the program he wrote deals with input and output from file. If you don't have a file with a specific name, of course you would get an error.
xmen

Posted: Mon Mar 29, 2004 10:07 pm   Post subject: (No subject)

ok i got a problem

u see i was using whatdotcolour for my screensaver, which happend to be few balls (or happy faces) flying and bouncing around the screen........i used a program from Cervantes n kinda modify....

anyway i also hav these 2 obstacles in the middle of screen......so the balls also bounce away once contact with those obstacles=>by using whatdotcolour

PROBLEM IS, the whatdotcolour only works for the x-axis n y-axis for each balls, therefore only four contact testing points........SO, if the ball was to hit the obstacle on the upperleft,upperrite,lowerleft,loweright corner, the balls will go straight into the obstacles n weird things happen

here is a copy of my program, anyone plzz take a look at it (let it run a while then u'll see what i mean)

anyone who knows how to fix this PLZZZZZZZZZZZ reply . Thankyou
Cervantes

Posted: Tue Mar 30, 2004 4:10 pm   Post subject: (No subject)

terrible sorry dodge, but on this one I have to side with asian.

in this type of situation, especially because you're ussing cirlces, don't use whatdotcolour. use Math.Distance (was it you that was asking what Math.Distance is? if so, just use the distance formula).

 code: if Math.Distance (smallhappyface_x, smallhappyface_y, bighappyface_x, bighappyface_y) < smallhappyface_radius + bighappyface_radius then

that's how you determine if there is a collision.

I also have a few suggestions. Since the smallhappyfaces are bouncing off the big happyfaces (both of which are circles) you should use the same colision data as between the smallhappyfaces, except transfer 100% energy to the smallhappyfaces.
also, drawing each part of your happyfaces each loop is not very efficient. I recommend drawing your happyfaces (both big and small) at the beginning of the program and then use Pic.New to grab the picture that you just drew and assign it a variable handle.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 4  [ 49 Posts ]
Goto page 1, 2, 3, 4  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: