[Game] Bulldozer

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: [GAME] Bulldozer

07 Aug 2018, 17:32

Reeree wrote:Can You please tell me how to get through level 163 on Bulldozer codezone. This level is really hard
Press SPACE to send step by step solution :shh: :angel:

Code: Select all

#ifwinactive Bulldozer - Level 163
keys:="UUrRddrruuLLLLLrddRRuurrddLdlUUdlluurRddddlUruuullddRluurrdDDldllLrrruulDrdLuuuurruullDldRRlddrruUdddlddldlluuuuRRuulDuururDlddddddLruurruuLrddlluUluurDDDurrdrruLddlldlUUUluurDldlddRlulld"
moves:=strsplit(keys)
m:=0
dir:={u:"up",d:"down",l:"left",r:"right"}

~space::
m++
send, % "{" dir[moves[m]] "}"
return

~f2::
m:=0
return

esc:: 
exitapp 
return
Cheers,
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [GAME] Bulldozer

07 Aug 2018, 17:51

@SpeedMaster,

Which Sokoban solver did you use? I'm interested in which is the best. I was going to create solution for all levels but the solvers I tried couldn't find solutions for many of the levels.
User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: [GAME] Bulldozer

07 Aug 2018, 19:00

TheDewd wrote:Which Sokoban solver did you use?
I used Sokoban Automatic Solver ver 7.2.2 (aka Takaken solver)
by Ken-ichiro Takahashi
TheDewd wrote:I'm interested in which is the best.
You may find some statistics here
http://sokobano.de/wiki/index.php?title ... Statistics
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [GAME] Bulldozer

14 Aug 2018, 14:19

Updated:

Revision 12 (2018-08-14)
  • Fixed 'Undo Last Move' not working for map strings containing only digits

A comparison check is performed in the MapUpdate function to determine if the Bulldozer has moved. This is done to avoid populating the 'UndoArray' array when the user moves the Bulldozer into a boundary, such as a wall or other immovable object.

According to the documentation:
"...a variable containing only digits (with an optional decimal point) is automatically interpreted as a number when a math operation or comparison requires it. (To improve performance, numbers are cached internally to avoid conversions to/from strings.)"

This was causing unexpected behavior when map data was being interpreted as a number instead of a string.

After investigating the issue by searching the forums, I found a suggestion from lexikos to include literal quotes after the variable name to force interpretation as a string.

Before

Code: Select all

If (TempMap <> UndoMap) {
	UndoArray.Push(Undo)
}
After

Code: Select all

If (TempMap "" <> UndoMap "") {
	UndoArray.Push(Undo)
}
I apologize for any inconvenience.
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

28 Aug 2018, 22:13

Updated:

Revision 13 (2018-08-28)
  • Added 'Boss Key' hotkey to quickly minimize game window using "Spacebar"
  • Added alternate 'Undo Last Move' hotkey using "Backspace"
  • Added "Page Up" & "Page Down" hotkeys to change levels
  • On-screen level number now indicates level completion status using colors
  • Minor changes to 'Level Select' screen layout
  • Automatically load last played level
  • Show levels from same collection as current level on opening 'Level Select'
  • Added 'Mouse Movement' to control the bulldozer movement with the mouse
  • Fixed level 179 to prevent bulldozer from moving outside of viewable area
  • Improved prevention of unintended tab switching of tab control
  • Fixed tab display issues when toggling menu items while not on game screen
  • Fixed 'Level Select' color status drawing issue
  • Added current level progress in the Titlebar
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

31 Aug 2018, 16:21

Updated:

Revision 14 (2018-08-31)
  • Changed hotkey prevention to use window handle instead of title
  • Fixed levels 64 & 127 not applying "missing target" hotfix after restart of level
  • Changed Titlebar progress to only check for update when moving an object
  • Added MIDI SOUND EFFECTS (Enable from options menu)
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: [Game] Bulldozer

01 Sep 2018, 08:15

Great work continues!

Don't have much time to play (currently at level 29 - btw.: I love "Automatically load last played level"), cause it's addictive. I did some tests though, here are my suggestions:
In my opinion you don't need to set midi volume every time you play the sound. Once after Midi Startup is sufficient e.g.

Code: Select all

; Midi Startup
	hMidi := DllCall("Kernel32.dll\LoadLibrary", "Str", "Winmm.dll")
	VarSetCapacity(strh_MIDIOut, (A_PtrSize = 8 ? 24 : 16), 0)
	DllCall("Winmm.dll\midiOutOpen", "UInt", &strh_MIDIOut, "UInt", 0, "UInt", 0, "UInt", 0, "UInt", 0, "UInt")
	h_MIDIOut := NumGet(strh_MIDIOut)
	Volume:=(100/100)*0xffff ; numerator could be set by GUI control
	DllCall("Winmm.dll\midiOutSetVolume", "UInt", h_MIDIOut, "UInt", Volume | Volume << 16)
After hitting the boundary with arrow key pressed there should be a sound too:

Code: Select all

MidiSound(Channel, Note, Velocity := 127) {
	Global ; Assume-global mode

	If (!Sound) {
		return
	}

	; Prevent repeating sound on boundary
	;~ If (KF_REPEAT && (RegExMatch(PosChrX2, "(2|3|8|9|A|B|C|D|E|F)") || RegExMatch(PosChrX1, "(8|9|A|B|C|D|E|F)"))) {
		;~ return
	;~ }
	
	if (Note=86) {
		DllCall("Winmm.dll\midiOutShortMsg", "UInt", h_MIDIOut, "UInt", 0x90 | Channel | (Note << 8) | (Velocity << 16), "UInt")
		keyWait vk%VK%
		return
	}	

	;~ Volume := (100 / 100) * 0xFFFF
	;~ DllCall("Winmm.dll\midiOutSetVolume", "UInt", h_MIDIOut, "UInt", Volume | Volume << 16)
	DllCall("Winmm.dll\midiOutShortMsg", "UInt", h_MIDIOut, "UInt", 0x90 | Channel | (Note << 8) | (Velocity << 16), "UInt")
}
bye!

Edit: Due to changes in MidiSound() function, I did changes in Move(x,y) function too e.g.:

Code: Select all

If (PosChrX1 = "3") { ; Target+Boulder
	If (RegExMatch(PosChrX2, "(2|3|8|9|A|B|C|D|E|F)")) { ; Boundaries
		MapUpdate(Bulldozer "|" PosNum)
		MidiSound(9, 86) ; Now penultimate line of the if statement (for all if statements in Move() function)
		return
	}
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: [Game] Bulldozer

28 Feb 2019, 15:19

Saw your post on Discord, sounds like you need route-finding, so I had a quick stab at an implementation - just a simple recursive function

Code: Select all

#SingleInstance force
OutputDebug DBGVIEWCLEAR
/*
Sample map
01 02 03
04    05
06 07 08
*/
dirs := ["N", "S", "E", "W"]
map := {1: {N: -1, E: 2, S: -1, W: -1}
		, 2: {N: -1, E: 3, S: -1, W: 1}
		, 3: {N: -1, E: -1, S: 5, W: 2}
		, 4: {N: 1, E: -1, S: 6, W: -1}
		, 5: {N: 3, E: -1, S: 8, W: -1}
		, 6: {N: 4, E: 7, S: -1, W: -1}
		, 7: {N: -1, E: 8, S: -1, W: 6}
		, 8: {N: 5, E: -1, S: -1, W: 7}}
; {N: -1, E: -1, S: -1, W: -1}

routes := FindRoute(4, 8)
for i, route in routes {
	str .= "Route found: " BuildHistory(route) "`n"
}
ToolTip %  str
clipboard := str

FindRoute(source, dest, history := 0){
	global map, dirs
	if (history == 0)
		history := []
	static routes := []
	nodeObj := map[source]
	history.Push(source)
	OutputDebug % "AHK| History: " BuildHistory(history)
	if (source == dest){
		OutputDebug % "AHK| FOUND ROUTE - " BuildHistory(history)
		routes.Push(history)
	} else {
		Loop 4 {
			dir := dirs[A_Index]
			nextNode := nodeObj[dir]
			if (nextNode != -1 && !IsInHistory(nextNode, history)){
				; If there is a path in this direction, and we have not visited that node before...
				OutputDebug % "AHK| CHECKING TO " dir
				FindRoute(nextNode, dest, history.Clone())
			}
		}
	}
	return routes
}

IsInHistory(node, history){
	for i, n in history {
		if (n == node)
			return true
	}
	return false
}

BuildHistory(history){
	max := history.Length()
	Loop % max {
		str .= history[A_Index]
		if (A_Index != max)
			str .= ", "
	}
	return str
}

^Esc::ExitApp

Code: Select all

Sample map
01 02 03
04    05
06 07 08

Routing from 4 to 8:
Route found: 4, 1, 2, 3, 5, 8
Route found: 4, 6, 7, 8
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

01 Mar 2019, 17:15

Updated:

Revision 15 (2019-03-01)
  • Fixed background color chooser not saving custom color selections
  • Fixed bugs with MidiSound() function
  • Added sound effects for "Undo Last Move"
  • Fixed tile layering issue for custom themes (Thanks, SpeedMaster!)
  • Added menu icons
  • Changed "Level Select" layout
  • Added "Taskbar Progress" option to enable taskbar progressbar updates
  • Added "Titlebar Progress" option to toggle completion status text in title
  • Added option to teleport with a single click if "Mouse Movement" enabled
  • Mark levels 'Solved' or 'Unsolved' by right clicking in "Level Select"
  • Minor UI Changes
User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: [Game] Bulldozer

04 Mar 2019, 20:14

Hello,

It's nice to see this game popping up again. :) 8-)
The pathfinding implementation for the game works very well. Thanks! :thumbup:

Suggestions:
  • In the level select menu, there is no indication that the flags can be modified with a right click (a help at the bottom of the page would be nice).
  • Possibility to encode the default background color in the theme name. (to avoid setting a new background color when you select a new theme).
for example: "R8EoAso_#83769C.png" (Theme Tanks)

Code: Select all

ThemeSet(Tileset, Update := 0) {
	Global ; Assume-global mode
	ThemeMatch := "" ; Initialize variable

	For ThemeName, ThemeString In Themes {
		If (ThemeName = (Theme := Tileset)) {
			Menu, ThemesMenu, Check, % (ThemeMatch := ThemeName)
		} Else {
			If (!FileExist(Tileset)) {
				Menu, ThemesMenu, Check, Color
			}

			Menu, ThemesMenu, Uncheck, % ThemeName
		}
	}

	pTheme := (FileExist(Tileset) ? GdipCreateFromPNG(Tileset) : GdipCreateFromBase64(Themes[(ThemeMatch ? ThemeMatch : (Theme := "Color"))]))

	Menu, ThemesMenu, % (!ThemeMatch && FileExist(Tileset) ? "Check" : "Uncheck"), &Custom...
	
	if regexmatch(tileset, "#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})", bkcolor)			;------> default background color for the theme
		BackgroundColorSet(substr(bkcolor,2))
	
	If (Update) {
		BackgroundLoad(TempMap)
	}
}

Regards
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

28 Mar 2019, 16:04

Updated:

Revision 16 (2019-03-28)
  • Added option to toggle tile layering for custom themes using transparency
  • Added hotkey F12 to save screenshot as PNG
  • Added documentation for game
  • INI Validation to ignore invalid settings
Check out the GitHub! Updating information and adding additional files there!
https://github.com/westoncampbell/BulldozerAHK
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

29 Apr 2019, 13:49

Updated:

Revision 17 (2019-04-29)
  • Restored Backspace hotkey as optional undo key (Sorry, it was removed in an earlier re-write and I forgot to add it again)
  • Fixed broken link in documentation for the "custom themes" URL to load an external page
  • Hold Ctrl while clicking the "Documentation..." menu item to force load external Github documentation webpage
  • Added text notice to right-click for more options on Level Select (Suggested by SpeedMaster)
  • Block screenshot hotkey when Level Select or About screen is displayed
  • Added level number to screenshot filename
  • Display notification when taking screenshot
https://github.com/westoncampbell/BulldozerAHK
User avatar
Drachenbauer
Posts: 46
Joined: 06 May 2019, 08:37
Contact:

Re: [Game] Bulldozer

07 May 2019, 15:20

Here is a little instruction, how to add your own levels:

1. create your level-design:
A level is made from a line of 320 chars (numbers and the letters A-F).
If you put this in a format of 20 chars length and 16 lines hight, you can see the level a bit.

declarations:

0: empty field
1: target
2: rock
3: rock on target
4: bulldozer on target
5: bulldozer

8, 9, A, B, C, D, E, F: the aight different wall-designs
in the classic theme "8" is the plain brickwall and "9" is the full square-block.
So i think, it´s a good idea to use the "9" as the actual edges of your room and the "8" to fill the rest of the window.
you also can decorate the areas of "8"-tiles with the other wall-types

The best way is to create it in the simple text-editor by squeezing the window until the lines break after the 20th char.

2. add your level to the game-code:
The levels are listed as "Maps [1]" - "Maps [180]" add it at the bottom of the list with the next following number in the suoare-brackets (you also can add multiple levels this way.).
Then serch above and below this list for all "180" and replace them with your highest level-number.

If you made a level, where the bulldozer starts on a target for a rock, look for things like this:

; HOTFIX: Levels where bulldozer begins on target tile
If (LevelNum = "64" || LevelNum = "127")

in evers piece of code, that holde exactly theese the level-numbers, add your levelnumber, separated with another "||" too.

Save your changes, and you can play your own custom level in this game.

I also made some theme-graphics of my own:

-Angry Birds (from the phone-game)
The bulldozer is replaced with a bird from the flock.
The rock is replaced with an egg and the target is a nest.
The walls are the typical blocks of the piggie-buildings (ice, stone and wood, each as solid and as frame-shape, but red bricks in both shapes too, to fit the aight wall-designs).
I already have Stella (pink bird), because che is my favorite character there, but i think, i´ll draw the rest of the flock, too (the same walls, eggs and nests, just different birds).
Image

-kites and butterfly
The bulldozer is replaced with a a kite (i have three slightly different shapes of kites) or a butterfly.
The rock is replaced with a balloon and the taget is a bevel-like outline of the balloon.
The walls are clouds with shapes, similar to the original-wall-decorations.
Image
Image

-abstract (colorful and monochrome)
The bulldozer is replaced with a squared structure with push-plates on all sides (with a rainbow-pattern un solorful variant).
The rock is replaced with a white ball and the target is a rainbow-version of the original target (in monochrome just black and white rings).
The walls are just bright colored or black-white patterned.

and some modifyed versions of the original graphics.

How do i add them to your online list, to share them with the community?
Last edited by Drachenbauer on 07 May 2019, 16:13, edited 2 times in total.
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

07 May 2019, 15:31

Drachenbauer wrote:(Custom Themes) How do i add them to your online list, to share them with the community?
Attach your images to your [edited] forum post reply, or use an online image hosting service like https://imgur.com/

Be sure to attach the images, or links to your images, to your post reply.

I will update the game's forum post, and Github, to include your images with proper credits.

https://github.com/westoncampbell/BulldozerAHK#custom-themes
User avatar
Drachenbauer
Posts: 46
Joined: 06 May 2019, 08:37
Contact:

Re: [Game] Bulldozer

07 May 2019, 16:02

if i put them in my post, i get "Image Broken Link for safety"
I uploaded them at Servimg.com
Why this happens?
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

Re: [Game] Bulldozer

07 May 2019, 16:06

Drachenbauer wrote:if i put them in my post, i get "Image Broken Link for safety". I uploaded them at Servimg.com. Why this happens?
I think it's protection against spammers posting links to malicious websites, and because you're a newly registered user on the forums.

Are the links not readable after being "broken"? I should be able to figure it out.

You can also email the images to me: Weston Campbell <[email protected]>
User avatar
Drachenbauer
Posts: 46
Joined: 06 May 2019, 08:37
Contact:

Re: [Game] Bulldozer

07 May 2019, 16:15

with imgur url´s I get the same result.
i tried to add them as an image preview.

if i edit my post, i see the image-links inside.
Last edited by Drachenbauer on 07 May 2019, 16:16, edited 1 time in total.
gregster
Posts: 8918
Joined: 30 Sep 2013, 06:48

Re: [Game] Bulldozer

07 May 2019, 16:16

You should be able to upload up to three images per post via the "Attachments" tab in the "Full Editor & Preview" (scroll down a bit), directly to the forum.
I can also fix broken links for you in your post...
(TheDewd is right, your problems stem from you being a newly registered user with restricted posting rights)


Attachments > Add files > (wait till uploaded) > Place inline
upload.png
upload.png (65.83 KiB) Viewed 4230 times
User avatar
Drachenbauer
Posts: 46
Joined: 06 May 2019, 08:37
Contact:

Re: [Game] Bulldozer

07 May 2019, 16:20

I think, sharing game-graphic-themes with the community should not be spam.

More graphics: more variety to choose from for the community
gregster
Posts: 8918
Joined: 30 Sep 2013, 06:48

Re: [Game] Bulldozer

07 May 2019, 16:25

Drachenbauer wrote:
07 May 2019, 16:20
I think, sharing game-graphic-themes with the community should not be spam.
Of course not, but since recently an idiotic spammer constantly posted images of headless corpses and other nonsense, we had to introduce stricter rules.
A related statement from the site admin: https://www.autohotkey.com/boards/viewtopic.php?f=3&t=62284

Some posts and images need to be approved now... like I said, I can fix your broken links, if you post them (or mail them to TheDewd).
(Edit:I now fixed the images in your post above)
Have you tried the direct upload to the forum, like I described?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: JoeWinograd, TOTAL and 131 guests