News:

A forum for users of LackeyCCG

Main Menu

Programming help, please

Started by netfirecat, February 27, 2010, 07:24:06 PM

Previous topic - Next topic

netfirecat

I know Python, but i prefer RAPTOR, i've used it for almost a year now. Out of boredom, i am trying to write a MTG thingy, basicly it reminds the user of effects that trigger during what phase of the turn. If anyone wants the new RAPTOR program, i'll upload it, i have it. Two questions:

1) Is there a way to make a sort of queu that the player may create while it is running and replay when asked?

2) I've been trying to find a way to negate the notice i get when i don't put in something for input. I found out about looping with x != "", but when i nestle that within a loop to make sure the user put in a sensible answer, it tells me it cannot compare the figures...

[attachment deleted by admin]

sneaselx

I don't know about RAPTOR, I've honestly never heard of it before, and would have to look at it for a while, but it would be pretty easy with Python. Just have two while loops, with the first asking for input and a phase activated, and storing them in a dictionary(or nested list), while the other section asks for phase input and returns the input linked to that phase. Then, you have a specific command that switches between the two loops. In python it would be:

While codeRunning == True:
   While loop1 == True:
        doStuff()
        if response == "switch":
              loop1 = False
               loop2 = True
  While loop2 == True:
        doStuff()
        if response == "switch":
               loop1=True
               loop2=False


This runs the two loops until you tell the codeRunning loop to quit. Each loop will repeat itself until you tell it to "switch", and then toggles the respective loop check. It would probably be easier to do this type of thing in RAPTOR as a flow-chart language.
Does RAPTOR have lists, or arrays? If not, you would have to use a seriously complicated series of variables, and that would be impossible.

On your problem, is x declared a string previously? If by default x is an int or boolean, then it would not be able to be compared to a string. If RAPTOR has the python system where any empty string is considered None, then you could just do "if x:".

netfirecat

RAPTOR is a programming program designed to help users outline their program, get out the kinks and can translate to other formats like C++. It has as little syntax as possible to help cut down on the amount of syntax the user must remember. In RAPTOR, when pressed with an input, if the user pushes enter without putting anything in, it replies (these values could not be compared ""). When i asked a programming teacher what to do to cut down those returns, she suggested taking that input and placing it within a loop that repeats as long as the user types in only what the input can use. Going by the attachments:

Attachment 1: It asks how old the user is, producing the variable (age). If the variable (age) comes back empty, (""), it loops back to right before the input and asks the user until the user actually puts something in.

Attachment 2: Taking the first loop, the second compares (age) to 0. If (age) is less than 0, the second returns the user to before the input, an age under 0 isn't possible, an answer as such wont be accepted.

The trouble is, if i remove the ("") loop, it compares (age) to 0 fine, if i remove the (age) loop, it compares (age) to ("") just fine, but together it wont...

sneaselx

#3
I think it's because > only works on numbers, and "" implies string. If there is no way to tell if a variable is empty, then you might want to try converting the variable to a number after the input, and then just check if it is greater than 0.
Or you could try to set the variable first to 0, and then ask for input until it is > than 0.

while runningCode==1:
    response=0
    response=raw_input("What is your age?")
    if response != 0:
           if response > 0:
                   doStuff()
#This inititaizes the variable response as 0, so you don't need to know if it was empty or not.
If there was not a value declared, it will come back as 0, and if there was, it will be that number.

I tried to install RAPTOR, but I don't run windows, so I couldn't. I would like to try it out, though. It looks interesting.

netfirecat

Now to do what I intended: I was asked to program a simple, text-only program, or programs if needed, for CCGs. I'm using MTG as a base. I'm using RAPTOR cause it's what i'm accustomed to. The intended user is one that can't use Lackey, MSW and such, they wont work. I'm currently working on the draw algorithim. The hand, grave, exiled and field is up to the user to keep up with. Connection, security and cheat provention is all unnessecary because the program is designed for unconnected play, the two players using text, a messenger or over the phone to convey moves and the whole card database so the players know the cards.

2 things:
I'll already be going over the list of effects and such that effect the deck, anything that others suggest? Ones i know: draw, return to the top/bottom of deck, reveal, scry, fateseal, remove selected card(whether target is grave, exile, hand or field).

With the deck taken care of and a life counter in the works, and remembering this is a text-only program, any other suggestions?