The "IT DOESN'T WORK!" thread

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby Berengal » Sun May 02, 2010 2:12 pm UTC

tastelikecoke wrote:Why does Python assume octal numbers when the number follows a 0?
For the same reason it assumes hex numbers when it follows 0x, or floats when it precedes a dot. It's part of the syntax for numbers.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Rysto » Sun May 02, 2010 4:05 pm UTC

Berengal wrote:
tastelikecoke wrote:Why does Python assume octal numbers when the number follows a 0?
For the same reason it assumes hex numbers when it follows 0x, or floats when it precedes a dot. It's part of the syntax for numbers.

And it's a stupid syntax(that they copied from C). Octal numbers should be prefixed with 0o, for consistency with hex numbers and to not redefine the meaning of a leading zero.

User avatar
phlip
Restorer of Worlds
Posts: 7572
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby phlip » Mon May 03, 2010 7:44 am UTC

I think I may have a problem.
crap.png
That is not a small number. That is a big number.
crap.png (4.02 KiB) Viewed 6885 times
Clicking the [+] button crashed Eclipse.

Eh, screw it, I'm going home, I can figure out what I've set up wrong tomorrow.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Dason
Posts: 1311
Joined: Wed Dec 02, 2009 7:06 am UTC
Location: ~/

Re: The "IT DOESN'T WORK!" thread

Postby Dason » Mon May 03, 2010 1:39 pm UTC

phlip wrote:I think I may have a problem.
crap.png
Clicking the [+] button crashed Eclipse.

Eh, screw it, I'm going home, I can figure out what I've set up wrong tomorrow.

On the plus side: No warnings! Yayyy!
double epsilon = -.0000001;

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The "IT DOESN'T WORK!" thread

Postby TheChewanater » Mon May 03, 2010 4:32 pm UTC

I'm guessing some variableor function was removed, renamed, or made private, or otherwise messed with (IE: arguments or type or something). I sometimes get a ton of errors (not that many) when I decide that FooBar is a better name than Foo_Bar and I forget to reflect this change in the code.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Mon May 03, 2010 8:37 pm UTC

Gagh, my haskell irc tutorial bot won't connect at all: "connect: does not exist (No route to host)". I can ping the server fine, and I'm connected via my irc client.

Any suggestions?
73, de KE8BSL loc EN26.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby Berengal » Mon May 03, 2010 8:38 pm UTC

Check that your port is open.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Mon May 03, 2010 9:09 pm UTC

Berengal wrote:Check that your port is open.
Huh?
73, de KE8BSL loc EN26.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby Berengal » Mon May 03, 2010 9:11 pm UTC

The port you're using to connect. Check that your firewall doesn't block it somehow and that it's properly NATed.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Mon May 03, 2010 9:14 pm UTC

I'm able to connect to the same server (and port) via my irc client - is that not an indication that the port's open? Or am I missing something about the way connections work?
73, de KE8BSL loc EN26.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Rysto » Mon May 03, 2010 10:37 pm UTC

"No route to host" would indicate to me that you're trying to connect to the wrong IP address.

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: The "IT DOESN'T WORK!" thread

Postby headprogrammingczar » Mon May 03, 2010 11:09 pm UTC

How are you connecting to the server? My Haskell bot uses the following, which returns an IO Handle:

Code: Select all

connectTo "irc://irc.foonetic.net" (PortNumber 6667)
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
phlip
Restorer of Worlds
Posts: 7572
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby phlip » Mon May 03, 2010 11:32 pm UTC

TheChewanater wrote:I'm guessing some variableor function was removed, renamed, or made private, or otherwise messed with (IE: arguments or type or something). I sometimes get a ton of errors (not that many) when I decide that FooBar is a better name than Foo_Bar and I forget to reflect this change in the code.

Well, given it was a Python project which I only just set up (and I only just installed the Python plugin for Eclipse), and the first error in the list is "Undefined variable: False" (turns out it didn't crash when I clicked the plus, just hung for ages... it was open when I came in this morning)... I'm going to stick with my "didn't set it up right" guess.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The "IT DOESN'T WORK!" thread

Postby TheChewanater » Tue May 04, 2010 2:05 am UTC

As in, it thinks it's Java or something?
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
phlip
Restorer of Worlds
Posts: 7572
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby phlip » Tue May 04, 2010 2:23 am UTC

Turns out the plugin was defaulting to using Python 2.5 for libraries and binaries and such.

I have Python 2.6 installed.

Changed that, and now my list of errors is significantly reduced.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Tue May 04, 2010 12:58 pm UTC

headprogrammingczar wrote:How are you connecting to the server? My Haskell bot uses the following, which returns an IO Handle:

Code: Select all

connectTo "irc://irc.foonetic.net" (PortNumber 6667)

This is the simple version, c+p'd from http://haskell.org/haskellwiki/Roll_your_own_IRC_bot

Code: Select all

import Network
import System.IO
 
server = "irc.foonetic.net"
port   = 6667
 
main = do
    h <- connectTo server (PortNumber (fromIntegral port))
    hSetBuffering h NoBuffering
    t <- hGetContents h
    print t

Code: Select all

94:Desktop roadierich$ runhaskell 1.hs
1.hs: connect: does not exist (No route to host)


I tried adding in the "irc://", but it still errors, with

Code: Select all

94:Desktop roadierich$ runhaskell 1.hs
1.hs: getAddrInfo: does not exist (nodename nor servname provided, or not known)
73, de KE8BSL loc EN26.

User avatar
phlip
Restorer of Worlds
Posts: 7572
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby phlip » Tue May 04, 2010 11:32 pm UTC

Works for me (without the irc:// prefix, just copy/pasted from your post)... Sounds like you've got a problem at your end, not with the code. Maybe ghc is blocked by your firewall?

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Wed May 05, 2010 3:14 pm UTC

I tried after switching my firewall off: same result. The interpreter can access the net, even with the firewall on: a trivial modification successfully GETs freenode.net.

It seems that I'm able to connect if I use an ip address rather than the domain name. I'll probably stick with that for now.
73, de KE8BSL loc EN26.

Not_an_S
Posts: 25
Joined: Sun Feb 14, 2010 1:16 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Not_an_S » Fri May 07, 2010 12:22 am UTC

I'm having some trouble with C++ and SDL (ON THE HELLO WORLD EXAMPLE).
SDL_BlitSurface is returning a 2 on

Code: Select all

hello = SDL_LoadBMP("hello.bmp");
SDL_BlitSurface(hello,NULL,screen,NULL);

which is causing the program to simply close out with status 3 when SDL_Flip(screen); is declared

User avatar
Ephphatha
Posts: 625
Joined: Sat Sep 02, 2006 9:03 am UTC
Location: Bathurst, NSW, Australia

Re: The "IT DOESN'T WORK!" thread

Postby Ephphatha » Fri May 07, 2010 12:26 am UTC

If either of the surfaces were in video memory, and the blit returns -2, the video memory was lost, so it should be reloaded with artwork and re-blitted


I'm going to assume this is because "screen" was the display buffer and something has caused it to become invalid. What code do you have that retrieves the display buffer? Are you using double buffering and only grabbing the screen buffer at initialisation?

Edit: SDL_Flip implies double buffering, but not always.

So your code should look something like:

Code: Select all

screen = SDL_GetVideoSurface();
hello = SDL_LoadBMP("hello.bmp");
if(hello == NULL || screen == NULL)
{
    exit(-1);
}

do
{
    if(SDL_BlitSurface(hello,NULL,screen,NULL) == -2)
    {
        screen = SDL_GetVideoSurface();
        hello = SDL_LoadBMP("hello.bmp");
        if(hello == NULL || screen == NULL)
        {
            exit(-1);
        }
    }
}
while(SDL_FLip(screen) == 0);

Key points here would be to check that the file was loaded, you actually got both surfaces, and you haven't lost the surfaces after the blit.

EditEdit: Also, exit code 3 (on windows at least) implies that a path was not found. http://www.hiteksoftware.com/knowledge/articles/049.htm
I'm not lazy, I'm just getting in early for Christmas is all...

Not_an_S
Posts: 25
Joined: Sun Feb 14, 2010 1:16 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Not_an_S » Fri May 07, 2010 12:54 am UTC

Setting screen to GetVideoSurface was all that was necessary for some reason. (It was set to NULL beforehand, which may have made the blitting not work)
I should put in the other things as well, just in case it gives it off, but the while(SDL_Flip(screen) == 0); freezes the program, but while(SDL_Flip(screen)); doesn't, which kind of gets rid of the point of a do while loop. Also, using a while loop (instead of a do while) have sufficed?

EDIT: I just realized that I had typed it wrong and had not set screen equal to SDL_SetVideoMode. I feel like such an idiot for missing it.
Thanks anyway, I'll try to use some of the code as a fail-safe.

User avatar
Ephphatha
Posts: 625
Joined: Sat Sep 02, 2006 9:03 am UTC
Location: Bathurst, NSW, Australia

Re: The "IT DOESN'T WORK!" thread

Postby Ephphatha » Fri May 07, 2010 10:42 am UTC

Not_an_S wrote:Setting screen to GetVideoSurface was all that was necessary for some reason. (It was set to NULL beforehand, which may have made the blitting not work)

Blitting to a NULL pointer should do absolutely nothing, but in the worst case the OS will probably stop the attempt at overwriting random memory anyway.

Not_an_S wrote:the while(SDL_Flip(screen) == 0); freezes the program, but while(SDL_Flip(screen)); doesn't, which kind of gets rid of the point of a do while loop.

That would be because you're flipping the surfaces constantly, it will loop until SDL_Flip fails, which it wont because screen is a valid surface. This was only meant as a demonstration of what you need to check for.

Not_an_S wrote:Also, using a while loop (instead of a do while) have sufficed?

Yes, if the while loop was necessary in the first place :)
I'm not lazy, I'm just getting in early for Christmas is all...

User avatar
modularblues
Posts: 689
Joined: Sun Nov 08, 2009 8:33 am UTC
Location: Escher's Wonderland
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby modularblues » Sun May 16, 2010 3:00 am UTC

Hello,

My main problem right now is doing floating point arithmetic within a bash script, with variables.

Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.

I plan to
(1) create many folders inside [myExamples], that are named [example10] [example11]...
each containing an identical copy of (run_example),
(2) modify Line 172 of each copy of (run_example)...
in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)

How can I use the available calculator bc code to do floating point operations?
Thank you for your help!


My code is below -

Code: Select all

#!/bin/sh

# run from directory where this script is
cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname

# Make many folders containing executables of slightly different parameters...
for i in `seq 10 11`;
do
mkdir examples$i
done

# Copy the same file into all the folders where (run_example) and [examples{num}] are in ~/myExamples
for i in `ls -d */`;
do cp run_example "$i";
done;

# Replace... something... in (run_example) for each folder
bulksize=`expr 6.00`
half=$(( bulksize / 2)) # THIS LINE DOES NOT WORK

for i in `ls -d */`;
do
cat $i/run_example | sed -e '172 s/[0-9]*/\$half/' > $i/run_example # THIS LINE DOES NOT WORK
half=`expr $half + 0.05`; # THIS LINE DOES NOT WORK
done;




When I replaced
half=$(( bulksize / 2))
with
half=$bulksize/2 | bc

I got
expr: non-numeric argument


{SOLVED]
Actually I just solved it -
half=$(echo "scale=2; $bulksize / 2" | bc)
half=$(echo "scale=2; $half + 0.05" | bc)

User avatar
Ephphatha
Posts: 625
Joined: Sat Sep 02, 2006 9:03 am UTC
Location: Bathurst, NSW, Australia

Re: The "IT DOESN'T WORK!" thread

Postby Ephphatha » Sun May 16, 2010 4:18 pm UTC

Please note this is for a uni assignment, but the issue I'm having has nothing to do with the assignment criteria (that part works...).

I've got a camera class right? Moving works, however, I'm running into an issue when I try rotate.

Panning left/right (or hell, any rotation) causes the scene to rotate 180° every other frame (it seems, it's pretty damn fast in any case) while I'm turning the camera. By this I mean, every time I move the mouse, it will flicker back and forth for each MouseMotion event (as far as I can tell).

Here's the stupid thing. I tried to take screenshots, but when I grab the rotated scene it appears the right way up in theGIMP, but it's still upside down in my app window. The view matrix is almost identical in both cases, the up, forward, and side vectors are almost identical in both cases, the position is identical. I have no god damn idea why it's doing what it's doing.

Here are some screenshots, I had to modify the second one to show what it looks like.
Image Image

I'm using SDL if that may have anything to do with it. Relevant code snippets are below. The language is C++.

Code: Select all

static void handle_mouse_motion(Uint8 state, Uint16 x, Uint16 y, Sint16 xrel, Sint16 yrel)
{
    if(state & SDL_BUTTON(2))
    {
        if(boost::shared_ptr<Camera> camera = gCamera.lock())
        {
            camera->Pitch(Quaternion::DegreesToRadians(static_cast<float>(yrel) / 100.0f));
            camera->Pan(Quaternion(Quaternion::DegreesToRadians(static_cast<float>(xrel) / 100.0f), Vector3(0.0f, 1.0f, 0.0f)));
        }
    }
    return;
}


Code: Select all

void Camera::Pan(const Quaternion &rotation)
{   // Pitch() is just Pan(Quaternion(angle, Side()))
    this->forward *= rotation;
    this->side *= rotation;
    this->up *= rotation;
    CalculateMatrix();

    return;
}


Code: Select all

void Camera::CalculateMatrix(void)
{   //forward, up, side are Vector3s. Basically 3 floats with helper functions. matrix is an array of GLfloat[16]
    this->forward.Normalise();
    this->side = this->forward.Cross(this->up);
    this->side.Normalise();
    this->up = this->side.Cross(this->forward);
    this->up.Normalise();

    this->matrix[0] = this->side.x;
    this->matrix[4] = this->side.y;
    this->matrix[8] = this->side.z;
    this->matrix[12] = 0.0f;
    //------------------
    this->matrix[1] = this->up.x;
    this->matrix[5] = this->up.y;
    this->matrix[9] = this->up.z;
    this->matrix[13] = 0.0f;
    //------------------
    this->matrix[2] = -(this->forward.x);
    this->matrix[6] = -(this->forward.y);
    this->matrix[10] = -(this->forward.z);
    this->matrix[14] = 0.0f;
    //------------------
    this->matrix[3] = this->matrix[7] = this->matrix[11] = 0.0f;
    this->matrix[15] = 1.0f;

    return;
}


Code: Select all

static void render(void)
{   // Don't mind the globals, I'm making a deliberate point since my lecturer said my last assignment was too complex. Basically everything in one file except the classes I need to fulfill assignment functionality.
    // Clear the color and depth buffers.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // We don't want to modify the projection matrix.
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    //! \todo Move this code to a scene class.
    if(boost::shared_ptr<Camera> camera = gCamera.lock())
    {
        camera->SetView();
    }

    //! \todo Move this code to a BoxManager class.
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);
    glNormalPointer(GL_FLOAT, 0, Box::normals);
    glColorPointer(3, GL_FLOAT, 0, Box::colours);
    glVertexPointer(3, GL_FLOAT, 0, Box::vertices);

    if(boost::shared_ptr<Box> head = gHead.lock())
    {
        head->Draw();
    }

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);

    SDL_GL_SwapBuffers();

    return;
}


Edit:

Code: Select all

void Camera::SetView(void) const
{
    glMultMatrixf(this->matrix);
    glTranslatef(this->position.x, this->position.y, this->position.z);

    return;
}


EditEdit: I think I'm doing something seriously wrong. If I comment out the camera->Pitch() line in handle_mouse_move() I appear to be inverting the forward vector (The scene flickers in and out of existance, but if I turn 180° it's drawn behind me, as long as I stop moving while it's visible...). And if I uncomment that line, but comment out the camera-Pan() line instead, I can rotate the view 180° until I'm looking backwards and the scene is drawn correctly.

EditEditEdit: I knew I was doing something stupid. In trying to fix quaternion/vector multiplication I changed some of the constructors around, which meant in order to create a quaternion representing angle radians of rotation around an axis, I had to call Quaternion(axis, angle) (otherwise it interpreted the input as trying to create a precalculated quaternion with (w, xyz)). But I didn't make that change in the code.

Once I changed the call to pan to this:

Code: Select all

camera->Pan(Quaternion(Vector3(0.0f, 1.0f, 0.0f), Quaternion::DegreesToRadians(static_cast<float>(xrel) / 100.0f)));

(and fixed the helper functions), everything was golden.
Last edited by Ephphatha on Mon May 17, 2010 2:25 am UTC, edited 2 times in total.
I'm not lazy, I'm just getting in early for Christmas is all...

squareroot
Posts: 548
Joined: Tue Jan 12, 2010 1:04 am UTC
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby squareroot » Wed May 19, 2010 1:33 am UTC

Hey, can anyone help me with this? I wrote a Pong game at [url href=http://timeroot.zxq.net/games/pong.html]this webpage[/url], and it runs fine in Chrome, but in Firefox it's tragically slow. Why is this? Is there something different about the setInterval handling? I don't know, there weren't any error messages from either of them. Even worse, in FF, the AI Paddle is sometimes semi-transparent as well.

...help, please?
<signature content="" style="tag:html;" overused meta />
Good fucking job Will Yu, you found me - __ -

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The "IT DOESN'T WORK!" thread

Postby TheChewanater » Wed May 19, 2010 2:39 am UTC

The AI paddle is transparent in both FF and Chrome for me.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

squareroot
Posts: 548
Joined: Tue Jan 12, 2010 1:04 am UTC
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby squareroot » Wed May 19, 2010 4:11 am UTC

Strange... it's definitely not transparent here. What version of FF and Chrome are you running? What... OS? I'm running FF 3.5.9 and Chrome 5 beta on Windows 7. When I looked at it on FF, I think it was 3.6.3 or something, on Windows XP, it was really slow and the AI Paddle was transparent.

Anybody else's reports would be good. Thanks!
<signature content="" style="tag:html;" overused meta />
Good fucking job Will Yu, you found me - __ -

User avatar
Xanthir
My HERO!!!
Posts: 5410
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby Xanthir » Wed May 19, 2010 4:14 am UTC

squareroot wrote:Hey, can anyone help me with this? I wrote a Pong game at [url href=http://timeroot.zxq.net/games/pong.html]this webpage[/url], and it runs fine in Chrome, but in Firefox it's tragically slow. Why is this? Is there something different about the setInterval handling?


IIRC, yes. I can't recall exactly where I heard it, but Firefox has a relatively long minimum delay between setInterval(0) calls, while Chrome's minimum delay is smaller.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

squareroot
Posts: 548
Joined: Tue Jan 12, 2010 1:04 am UTC
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby squareroot » Wed May 19, 2010 4:38 am UTC

:-O There's a minimum delay? That explains it pretty well. I'll have to adjust it then.

...but that still doesn't explain the semi-transparency. :-S
<signature content="" style="tag:html;" overused meta />
Good fucking job Will Yu, you found me - __ -

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The "IT DOESN'T WORK!" thread

Postby TheChewanater » Wed May 19, 2010 6:12 pm UTC

When I said transparent, I mean invisible (as opposed to translucent).

I'm also pretty sure my Chrome is an older version, unless it updated itself in the last few months.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

squareroot
Posts: 548
Joined: Tue Jan 12, 2010 1:04 am UTC
Contact:

Re: The "IT DOESN'T WORK!" thread

Postby squareroot » Wed May 19, 2010 10:47 pm UTC

...even when you were playing in the AI mode? Note that the game begins in solo mode - you have to switch to AI mode by pressing the button. If it really is completely invisible, then I expect it will have something to do with globalAlpha or something. Tell me, can you see the green "glow" off to left side of the screen? What about the red "glow" off to the right when playing in AI mode?
<signature content="" style="tag:html;" overused meta />
Good fucking job Will Yu, you found me - __ -

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The "IT DOESN'T WORK!" thread

Postby TheChewanater » Wed May 19, 2010 10:55 pm UTC

Ah, that explains it.

The AI is perfectly opaque in Firefox 3.6.3
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
RahulKolasseri
Posts: 54
Joined: Tue Jun 09, 2009 1:19 pm UTC
Location: Singapore

Re: The "IT DOESN'T WORK!" thread

Postby RahulKolasseri » Thu May 27, 2010 1:25 pm UTC

Hey guys, so i was doing this voice recognition(just for the words 'yes' and 'no') script in pys60(its python 2.5, with a few extra symbian specific modules, iirc) and for a lack of a better idea, i did a byte for byte comparison. It worked okay at first but after that it keeps giving the percentage match of the input compared to 'yes' as 9-10 but the match for the input compared to 'no' as 0. The source code's attached below(its .zip, because xkcd apparently does not allow .py), maybe you guys know why this is happening.
Attachments
Voice.zip
The worst attempt at voice recognition in human history
(641 Bytes) Downloaded 80 times
Xeio wrote:Small amounts of cancer are definately worth the awesome.

User avatar
RoadieRich
The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: The "IT DOESN'T WORK!" thread

Postby RoadieRich » Thu May 27, 2010 5:05 pm UTC

I've got to say I'm extremely surprised you get any match at all. The slightest bit of background noise - up to 1 in 2**32* of the microphone's max input level, and you've got a different sample. (It looks a lot like you're working on samples, not bytes.) I don't know how speech recognition actually works, but I'd expect wikipedia to be able to provide enough information to get you started on the right road.

Apart from it being the worst example of "trying to write C in Python" I've seen in a long time, I can't really find any errors other than your basic premise being totally wrong.

*Assuming you're using 32bits per sample, which I'm pretty sure is the default.
73, de KE8BSL loc EN26.

User avatar
RahulKolasseri
Posts: 54
Joined: Tue Jun 09, 2009 1:19 pm UTC
Location: Singapore

Re: The "IT DOESN'T WORK!" thread

Postby RahulKolasseri » Thu May 27, 2010 6:55 pm UTC

RoadieRich wrote:I've got to say I'm extremely surprised you get any match at all. The slightest bit of background noise - up to 1 in 2**32* of the microphone's max input level, and you've got a different sample. (It looks a lot like you're working on samples, not bytes.) I don't know how speech recognition actually works, but I'd expect wikipedia to be able to provide enough information to get you started on the right road.



The thing is that i've just started off in python, and i don't really know how i would implement one of those algorithms. And i can't use
things like
dragonfly
because i would have to change a significant portion of it to get it to work on pys60. And some modules that are in the standard library of python isn't in pys60, to save space. And, like i said in the previous post, the thing actually gave me a good reading the first time(~40% match for 'yes', which was what i said, and ~10% match for 'no') and now just gives me the same output(10% for 'yes' and 0% for 'no') for anything i say.

RoadieRich wrote:Apart from it being the worst example of "trying to write C in Python" I've seen in a long time,

Yeah, i'm still a newbie to python, so i tend to write it like i'm writing C, which was my first language.
Xeio wrote:Small amounts of cancer are definately worth the awesome.

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Josephine » Fri May 28, 2010 2:11 am UTC

I'm still pretty new bad at python, and I was messing with lists. This is supposed to add 10 random numbers between 0 and 50 to a list. It complained at me, saying that ints aren't iterable. so I put the str() on top of the random.randrange(0,x,1). It doesn't give me errors anymore, but it doesn't do anything either.
Spoiler:

Code: Select all

import random

li = []

def rand_list(x,y):
    rand_gen = str(random.randrange(0,x,1))
    z = 0
    if z < y:
        li.extend ("rand_gen")
        z=z+1
    else:
        print li
   
   
rand_list(50,10)


What am I doing wrong here?
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

User avatar
e^iπ+1=0
Much, much better than Gooder
Posts: 2065
Joined: Sun Feb 15, 2009 9:41 am UTC
Location: Lancaster

Re: The "IT DOESN'T WORK!" thread

Postby e^iπ+1=0 » Fri May 28, 2010 2:44 am UTC

You're not looping. Your program only goes through the if/else once.


Also, you don't need quotation marks around rand_gen since it's already a string.

Code: Select all

>>> a=str(3)
>>> a
'3'

You could also use the quotation marks and get rid of the str() part earlier in the program.


Also, list.extend() doesn't do what you want. That takes a list and appends the items in that list to another list. For example:

Code: Select all

>>> list1=[1,2,3]
>>> list2=[4,5,6]
>>> list1.extend(list2)
>>> list1
[1, 2, 3, 4, 5, 6]


What you want is list.append()

Code: Select all

>>> list=[1,2,3]
>>> a=4
>>> list.append(a)
>>> list
[1, 2, 3, 4]
poxic wrote:You, sir, have heroic hair.
poxic wrote:I note that the hair is not slowing down. It appears to have progressed from heroic to rocking.

(Avatar by Sungura)

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Josephine » Fri May 28, 2010 3:06 am UTC

Alright, I got it. I got rid of the quotation marks, replaced extend with append, and replaced if with while. I also put the random.randrange inside the loop, as it was giving me the same result for every element of the list. Everything seems to work now.
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

User avatar
e^iπ+1=0
Much, much better than Gooder
Posts: 2065
Joined: Sun Feb 15, 2009 9:41 am UTC
Location: Lancaster

Re: The "IT DOESN'T WORK!" thread

Postby e^iπ+1=0 » Fri May 28, 2010 3:12 am UTC

Yes, random.randrange has to be inside the loop. Otherwise you're also only running that once and rand_gen would always be equal to the one value that you assigned it. By putting it in the loop, random.randrange generates a new number and rand_gen gets reassigned every time.
poxic wrote:You, sir, have heroic hair.
poxic wrote:I note that the hair is not slowing down. It appears to have progressed from heroic to rocking.

(Avatar by Sungura)

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: The "IT DOESN'T WORK!" thread

Postby Josephine » Sat May 29, 2010 7:59 am UTC

alright, I have another question about the same program. that last bit was a modified version of what's going into an extremely basic pseudo-genetic algorithm. It's partially done, here's what I have so far.
Spoiler:

Code: Select all

# initialize:generate random numbers from 0 to 9999

import random

li = []

def rand_list(x,y):
    z = 0
    while z < y:
        rand_gen = str(random.randrange(0,x,1))
        li.append (rand_gen)
        z=z+1
   
   
   
rand_list(9999,500)

# define goal: random number from 0 to 9999

goal = random.randrange(0,9999,1)

# evaluate: separate closest % to goal

nextgen = []
y = 500
n = 0
while n < y:
    if li[n] < goal + (y/10) or li[n] > goal - (y/10):
        nextgen.extend(li[n])
        n = n + 1

print nextgen

# repeat: generate random numbers in range defined by evaluation

# terminate: if all random numbers equal goal

the list nextgen spits out y number of 1 digit random numbers. What I want is y number of the original numbers that are near the goal. Looking at it again, the line

Code: Select all

 if li[n] < goal + (y/10) or li[n] > goal - (y/10):

and the requirement of y numbers close to goal seem to interfere. Any input on why this is happening?

EDIT: And yes, that is an ugly fix for the scope of y.
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 11 guests