Jump to content


QuantumGrav's Content

There have been 36 items by QuantumGrav (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#114353 [Repost] [Learning Intelligence] [Game] Nim

Posted by QuantumGrav on 02 May 2013 - 12:39 AM in Programs

Learning Intelligence: Nim

QuantumGrav

http://pastebin.com/UP97racr



Learning Intelligence: Nim, is a program that learns how to play a simplified version of the game, Nim.

Nim begins with a number of objects and a maximum number of objects that can be taken on any one turn. The goal of this specific type of Nim is to force your opponent to take the last piece. The game is remarkably simple, and there is always one correct move in any position. This allows a trial and error approach to the game, searching for that one move and recording it when it's found.

The program picks from its available moves and records their success once the game is over, rating it +1 if the computer won, and -1 if the player did. It saves all its experiences to a file called "NimHistory." If you play perfect Nim against it, it learns quite quickly. Even if you don't, it will still eventually learn. I highly encourage you to pick a certain max and starting number, and then see how quickly you learn to play perfectly as opposed to it. I did so, and though at first I consistently beat it, it quickly learned, and destroyed me. The first time it beats you, it might sting just a little!

Also, you can have it play itself a number of times to have it improve it's abilities on its own.

Features: Both advanced and non-advanced computers supported, key and mouse compatible menu, a nice GUI, a self improvement system, and of course, it learns when playing you!

Screenshots:
Spoiler

This is a pretty cool concept, and could easily be applied to other simple games like tic-tac-toe, and maybe with some modification, more complex games like connect-four and checkers.

That does it! If you have any feedback, find a bug, or would like a feature added, let me know! The pastebin link is at the top and again below.




http://pastebin.com/UP97racr

Enjoy!




#114144 Boolean value randomly changes in program

Posted by QuantumGrav on 01 May 2013 - 11:23 AM in Ask a Pro

Line 69 in your program in this function:

function altCheckTree()
	    turtle.up()
isGrown = not turtle.forward()
if isGrown == false then
  repeat
		  turtle.back()
		  turtle.down()
   sleep(30)
   turtle.up()
   isGrown = turtle.foward()   -- This one here
  until isGrown == true
end --if
	    turtle.down()
end --growTree()

Is incorrect. the line should be:

isGrown = not turtle.forward()

exactly like the one a little ways before it. Remember proper spelling for "turtle.forward" and you should be fine I think. This might not be the only problem, but it was the only problem I caught looking through your code. Hope this helps!



#114136 A feature for an enchanting system w/ turtle

Posted by QuantumGrav on 01 May 2013 - 11:14 AM in Ask a Pro

In the "enchantBook()" function, change it to this, and simply input the number of what level you would like to enchant at.

function enchantBook()
	 turtle.select(1)
	 turtle.suckUp()
	 turtle.dropUp(turtle.getItemCount(1)-1)
	 while true do
	    term.write("How many levels should I enchant? : ")
	    nLevels = io.read()  -- Main line for getting input.  Look up a tutorial if you aren't familiar with io.read(), it's very useful!
	    if tonumber(nLevels) and tonumber(nLevels) > 0 and tonumber(nLevels) <= 30 then
		   nLevels = tonumber(nLevels)
		   break
	    end
	 end
	 m.enchant(nLevels)
	 turtle.dropUp()
end

If you want to not have to manually input a number every time, simply change the 30 in Direwolf's code to whatever level you would like. Hope that helps!



#113863 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 24 April 2013 - 09:47 AM in Programs

No worries! I look forward to seeing it in your OS!



#113552 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 23 April 2013 - 08:57 AM in Programs

@ Mackan90096
I downloaded a fresh copy of Craftogram and added what you say you did, and it works great for me. The capitalization does exactly what I thought it would, and like I said, I'm working on that. I would double check that adding the quote is all you changed. Otherwise, I'm not sure what the error is for!



#113460 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 23 April 2013 - 06:03 AM in Programs

Just by looking at what you added, I can't see an obvious error. I can't test anything right now, but I will sometime later today and see what I can do. Also, the program currently doesn't support capitalization after the first letter (Mackos is fine, MackOS is not). It shouldn't error, it should just leave the letters capitalized and not switch them. Since you're adding this to your OS though, I'll start work on adding support for it. Shouldn't be that hard.



#113101 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 22 April 2013 - 06:11 AM in Programs

View Posttheoriginalbit, on 22 April 2013 - 03:45 AM, said:

View PostQuantumGrav, on 21 April 2013 - 04:08 PM, said:

Thanks to the helpful people in Ask a Pro, here are some screenshots.

Spoiler

I'd love any feedback you all might have!
Screenshots are broken

So they are. They were working last night, so I'm not sure why they aren't now. I've re-uploaded them, but they might break again. Hopefully not! Thanks!



#113100 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 22 April 2013 - 06:08 AM in Programs

View PostMackan90096, on 22 April 2013 - 03:31 AM, said:

Very nice game. Mind if i use it in my OS and modify the code a bit?
Thanks, and sure! Modify it how you see fit. I'd like the comment at the top of the code with my name to remain, but otherwise feel free to do what you would like with it!



#112830 Missing pastebin program?

Posted by QuantumGrav on 21 April 2013 - 06:58 PM in Ask a Pro

To enable the HTTP API, follow the instructions on the wiki:
http://www.computerc...itle=HTTP_(API)
It's different if you're on a Mac, but if you're a PC guy, this should work.



#112800 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 21 April 2013 - 04:08 PM in Programs

Thanks to the helpful people in Ask a Pro, here are some screenshots.
Spoiler
I'd love any feedback you all might have!



#112799 [Forum] Adding a Screenshot to a Thread

Posted by QuantumGrav on 21 April 2013 - 04:04 PM in Forum Discussion

That's exactly what I was looking for. Thanks for the help!



#112768 [Forum] Adding a Screenshot to a Thread

Posted by QuantumGrav on 21 April 2013 - 02:26 PM in Forum Discussion

I have a thread that I would like to add some screenshots to. How do you do that? Thanks for the help!



#109818 [Game][Puzzle] Craftogram

Posted by QuantumGrav on 14 April 2013 - 06:11 AM in Programs

Craftogram

A ComputerCraft Puzzle Based on Cryptograms

http://pastebin.com/TDFyv9xf


What is Craftogram?
Craftogram is a game based on encrypting a word or phrase, and then guessing it. It is very similar to a cryptogram.

What does it do?
The program takes the alphabet and switches the letters around a number of times based on difficulty. It then writes a word or phrase taken randomly from a list in the new alphabet. Finally, you can switch letters, attempting to find the phrase.

What features does it offer?
Craftogram features a menu with mouse and key support, color, a clean interface, and phrase customization (if you don't mind peeking your head into the code). It is not currently compatible with non-advanced computers, but that may be added in a future update if the community asks for it.

Screenshots:

See the post just below this one.

How do I add my own phrases?
To do that, edit the code in your computer. Right at the top is a table called "Quotes." If you know how, just add your quote to the table. If you don't, at the bottom of that table, type this in:
[#] = "Your phrase here!" -- The # is the next number in the sequence.

Add a comma to the end of the quotes surrounding the phrase before yours, and you're good!

Any plans for Craftogram?
Not really. This was made in an afternoon as a break from a big project I'm working on, so I don't know if I'll ever really update this. If the community wants it though, I think I might take another break and add some things!

If I were to add anything, these are things I'm considering right now:
  • Ability to add phrases from inside the program.
  • Non-Advanced computer support.
  • Support for capitalization in the middle of phrases Added.
  • Got anything you would want? Let me know in a reply!
That about wraps it up! The pastebin link is at the top of the page and again below. Let me know of bugs, improvements, or features I should add!








Enjoy!

http://pastebin.com/TDFyv9xf




#108950 Accessing Data within Multiple Tables

Posted by QuantumGrav on 11 April 2013 - 01:54 PM in Ask a Pro

That's perfect! Great info all, thanks a bunch!



#108926 Accessing Data within Multiple Tables

Posted by QuantumGrav on 11 April 2013 - 01:05 PM in Ask a Pro

I am trying to get data stored in a multi-layer table, a snippet of which looks like:

table = {
  [1] = {
	[1] = "value";
	[2] = "value2"
  },
  [2] = {
	[1] = "value3";
	[2] = "value4"
  }
}

I would like to access the "value's" by using two numbers. For example, the number set 1,1 would return "value", and 2,1 would return "value3". I can do this by a very inelegant method:

-- Let x and y be the two numbers.
tHolder = table[x]
print(tHolder[y])

Is there a way to access the value with one line? Something like 'table[x].y'?

Thanks!



#108851 I'm not sure why this isn't working

Posted by QuantumGrav on 11 April 2013 - 11:01 AM in Ask a Pro

You are only calling io.read() once, so input is equal to "potato" and you're asking if it's equal to some numbers.

Here's what you have:

term.setCursorPos(15,13)
if input == "1" then
--etc.

Here's what it should be:

term.setCursorPos(15,13)
input = io.read()
if input == "1" then
--etc.

That should work I think!

Also, I would suggest putting that amount of code into a code brick and also a spoiler. Just makes it nicer to read!



#108764 [COMING] AX-OS

Posted by QuantumGrav on 11 April 2013 - 05:26 AM in Operating Systems

Cool preview, but I'd love some more information. What makes this OS unique and cool? Nice screenshot btw, I look forward to seeing it released.



#108763 ComputerCraft Games

Posted by QuantumGrav on 11 April 2013 - 05:23 AM in General

I'd be really happy to see this get off the ground. Unfortunately, I can't help out with coding or anything, I just don't know the languages. I'm curious as to the motivation for it though. We have the forums and pastebin, what is the benefit of having this site, besides being awesome?



#108760 Elevator

Posted by QuantumGrav on 11 April 2013 - 05:08 AM in Ask a Pro

@theoctagon: I really recommend putting code that large into a code and a spoiler, it's just nicer for others to read that way.

@Smiley43210: I'd also enjoy seeing that program! Sounds neat.

@Livebait: Have you gotten any of these programs to work how you want them to yet?



#107783 Xp turtle?

Posted by QuantumGrav on 08 April 2013 - 04:31 PM in Ask a Pro

There are also a few topics very similar to this in other threads, so if you want some inspiration or guidance on how to go about doing this, the forum's search bar and google are your friends! I once built this kind of system in my FTB world (now lost to a hard drive crash), and it's really fun seeing something you've programmed work exactly how you wanted it to! Keep learning and trying and you'll get it!



#107780 [Lua][Error]open:19: attempt to call nil

Posted by QuantumGrav on 08 April 2013 - 04:17 PM in Ask a Pro

Yep! The command read() or io.read() will give you a string no matter what is typed into it. The command 'tonumber(string)' is really helpful for this. If you use 'tonumber(read())' that will turn whatever is inputted into a number as soon as you get it. Pretty useful for a lot of things!



#107779 Help

Posted by QuantumGrav on 08 April 2013 - 04:02 PM in Ask a Pro

The code could look like:

turtle.select(1)
while true do
turtle.dig()
if turtle.getItemCount(1) == 64 then
rs.setOutput("back", true)
sleep(0.1)
rs.setOutput("back", false)
end
end

(Sorry for no code block. I'm working from a mobile.)

That should do what you would like!

I don't know if turtles can drop stuff to a barrel, but if they can, you could just change the barrel to below the turtle, then, instead of the setOuputs and sleep, just put 'turtle.dropDown()'. That would prevent having to use the filter and make the code a tad bit more efficient.

Hope that helps!



#107761 {lua} '=' error message dig turtle/drop issue

Posted by QuantumGrav on 08 April 2013 - 03:29 PM in Ask a Pro

Two ends actually, but other than that it looks great! Just make sure you call the function!



#107756 [Lua][Question] Multiple inputs in code? (IDK correct terminology)

Posted by QuantumGrav on 08 April 2013 - 03:23 PM in Ask a Pro

I'm not entirely sure why typing no number would error it, maybe somebody can explain why my code does that?

The command 'string.sub(string, starting character, ending character)' returns a sub-string or portion of the string you input, starting at the second argument and going to the third. For instance:

variable = "Test"
print(variable)
print(string.sub(variable, 1, 4))

This code will print "Test" twice. The first time is normal, then it prints a sub-string of variable starting at character 1 and going to character 4, which, in this case, is the entire string.

variable = "Test"
print(variable)
print(string.sub(variable, 1, 3))

This code will print "Test" and then "Tes." If you put the same number in the second and third arguments, it will give you the character at that point. print(string.sub(variable, 1, 1)) would print: "T".

'tonumber' is quite simple. It converts whatever is in its parentheses into a number if it can. The same works for 'tostring,' except it converts whatever is in its parentheses to a string. Very useful functions for when you are trying to convert input, a string, to a function that needs a number.
If a variable = "4", tonumber(variable) = 4.

In the code, variable = "star #". string.sub(variable, 6, 6) returns the 6th character of variable, which is the number. That is a string, and we need a number, so we use 'tonumber' to fix it.

I hope that clears things up!



#107730 [Lua][Question] Multiple inputs in code? (IDK correct terminology)

Posted by QuantumGrav on 08 April 2013 - 02:29 PM in Ask a Pro

I'm not positive this would work, but it should. I think io.read() can get more than one word, for instance "star 3". That will be stored to whatever variable you set io.read() to. The string.sub(string, starting character, ending character) function could be used to differentiate the words. For instance:

variable = io.read() -- the first word being "star" is assumed.
if string.sub(variable, 6, 6) == nil then -- string.sub(variable, 6, 6) returns either the number or nil.
number = 1
else
number = tonumber(string.sub(variable, 6, 6))
end
for i = 1, number do
print("star")
end

(Sorry about no code container, I'm working off a mobile device.)

That should do what you want. Hope that helps!

Edit: Suicidal's is much cleaner!