2048

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Dadido3
User
User
Posts: 52
Joined: Sat Jan 12, 2008 11:50 pm
Location: Hessen, Germany
Contact:

2048

Post by Dadido3 »

Hello,

I'm here to share my little clone of the game 2048.

It also includes some AIs, which are not really intelligent yet.
They mostly get to the 1024 Tile, sometimes 2048.
But thats where you are coming in, just try to write your own AI and upload the results here.
There is an example include for an AI which just randomly moves.
Just copy it, change the name and include it to the main file.

Image

Links Have Fun!
Last edited by Dadido3 on Sat Jul 02, 2016 1:54 pm, edited 1 time in total.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: 2048

Post by falsam »

Nice job. A suggestion: Sends a message when the game is blocked. Thank you Dadido3 :)

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
Fred
Administrator
Administrator
Posts: 16622
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: 2048

Post by Fred »

Good :)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: 2048

Post by davido »

Nice.
Thank you for sharing. :D
DE AA EB
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: 2048

Post by Kwai chang caine »

Great !!!
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: 2048

Post by Kwai chang caine »

Two hours of "Works" and only 3168 points with 256 max :oops:
Decidedly ...kcc is also strong in game than in programming :|
Again thanks for this code 8)
ImageThe happiness is a road...
Not a destination
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: 2048

Post by Poshu »

Just tried:
- with a few modifications, it works on OSx
- Did you change something to the random placement for the new tile? It felt much easier than the web version
- There is no message when you create the first 2048 tiles!
- Colors are different, and I felt lost...
User avatar
Dadido3
User
User
Posts: 52
Joined: Sat Jan 12, 2008 11:50 pm
Location: Hessen, Germany
Contact:

Re: 2048

Post by Dadido3 »

Poshu wrote:Just tried:
- with a few modifications, it works on OSx
- Did you change something to the random placement for the new tile? It felt much easier than the web version
- There is no message when you create the first 2048 tiles!
- Colors are different, and I felt lost...
Thanks for the feedback.

Could you give me the changes you made to make it work on OS X?
And do you also store the settings somewhere?
Or did you just commented out all the setting stuff?

Because of the random tile generation: I updated the game yesterday.
Now there is a 10% chance that a 4 will appear, and a 90% chance that a 2 will appear, the same behaviour as in the original version.
Before the update it was 50/50.

Regarding the message: If you want the message add it ;)
I see no real benefit in it, it's more annoying than helpful in my opinion.

Summary of the update:
  • The "Simple" Ai works now much better, it gets mostly to the 2048 tile and sometimes 4096
  • As mentioned above: A 2 will now spawn with a probability of 90%
  • Added a "Game Over" message
  • Added a highscore (only local)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: 2048

Post by davido »

Even better.
Thank you. :D
DE AA EB
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: 2048

Post by Poshu »

here it is (it's a lazy fix, because I just wanted it to work :p) :

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
	
	Procedure.s SHGetFolderPath(CSIDL)
	  Protected *String = AllocateMemory(#MAX_PATH+1)
	  SHGetFolderPath_(0, CSIDL, #Null, 0, *String)
	  Protected String.s = PeekS(*String)
	  FreeMemory(*String)
	  ProcedureReturn String
	EndProcedure
	
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
	#CSIDL_APPDATA = 0
	
	Procedure.s SHGetFolderPath(CSIDL)
		ProcedureReturn GetHomeDirectory() + "Library/Application Support/"
	EndProcedure
CompilerEndIf
Post Reply